replace softmax by sigmoid in final layer, also adjust dataset for that
This commit is contained in:
@@ -43,7 +43,6 @@ def get_model(cnnDropout, flow_features, domain_features, window_size, domain_le
|
||||
ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows")
|
||||
merged = keras.layers.concatenate([encoded, ipt_flows], -1)
|
||||
# CNN processing a small slides of flow windows
|
||||
# TODO: add more layers?
|
||||
y = Conv1D(cnn_dims,
|
||||
kernel_size,
|
||||
activation='relu',
|
||||
@@ -52,8 +51,8 @@ def get_model(cnnDropout, flow_features, domain_features, window_size, domain_le
|
||||
y = GlobalMaxPooling1D()(y)
|
||||
y = Dropout(cnnDropout)(y)
|
||||
y = Dense(dense_dim, activation='relu')(y)
|
||||
y1 = Dense(2, activation='softmax', name="client")(y)
|
||||
y2 = Dense(2, activation='softmax', name="server")(y)
|
||||
y1 = Dense(1, activation='sigmoid', name="client")(y)
|
||||
y2 = Dense(1, activation='sigmoid', name="server")(y)
|
||||
|
||||
return Model(inputs=[ipt_domains, ipt_flows], outputs=(y1, y2))
|
||||
|
||||
@@ -64,7 +63,7 @@ def get_new_model(dropout, flow_features, domain_features, window_size, domain_l
|
||||
ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows")
|
||||
encoded = TimeDistributed(cnn)(ipt_domains)
|
||||
|
||||
y2 = Dense(2, activation="softmax", name="server")(encoded)
|
||||
y2 = Dense(1, activation="sigmoid", name="server")(encoded)
|
||||
merged = keras.layers.concatenate([encoded, ipt_flows, y2], -1)
|
||||
|
||||
y = Conv1D(cnn_dims,
|
||||
@@ -76,7 +75,7 @@ def get_new_model(dropout, flow_features, domain_features, window_size, domain_l
|
||||
y = Dropout(dropout)(y)
|
||||
y = Dense(dense_dim, activation='relu')(y)
|
||||
|
||||
y1 = Dense(2, activation='softmax', name="client")(y)
|
||||
y1 = Dense(1, activation='sigmoid', name="client")(y)
|
||||
model = Model(inputs=[ipt_domains, ipt_flows], outputs=(y1, y2))
|
||||
|
||||
return model
|
||||
|
@@ -9,13 +9,9 @@ def get_embedding(vocab_size, embedding_size, input_length,
|
||||
x = y = Input(shape=(input_length,))
|
||||
y = Embedding(input_dim=vocab_size, output_dim=embedding_size)(y)
|
||||
y = Conv1D(filter_size, kernel_size=5, activation='relu')(y)
|
||||
# NOTE: max pooling destroys information flow for embedding
|
||||
# y = MaxPool1D(pool_size=3, strides=1)(y)
|
||||
y = Conv1D(filter_size, kernel_size=3, activation='relu')(y)
|
||||
# y = MaxPool1D(pool_size=3, strides=1)(y)
|
||||
y = Conv1D(filter_size, kernel_size=3, activation='relu')(y)
|
||||
y = GlobalAveragePooling1D()(y)
|
||||
# y = Dropout(drop_out)(y)
|
||||
y = Dense(hidden_dims, activation="relu")(y)
|
||||
return Model(x, y)
|
||||
|
||||
@@ -38,8 +34,8 @@ def get_model(cnnDropout, flow_features, domain_features, window_size, domain_le
|
||||
y = Dropout(cnnDropout)(y)
|
||||
y = Dense(dense_dim, activation='relu')(y)
|
||||
y = Dense(dense_dim // 2, activation='relu')(y)
|
||||
y1 = Dense(2, activation='softmax', name="client")(y)
|
||||
y2 = Dense(2, activation='softmax', name="server")(y)
|
||||
y1 = Dense(1, activation='sigmoid', name="client")(y)
|
||||
y2 = Dense(1, activation='sigmoid', name="server")(y)
|
||||
|
||||
return Model(inputs=[ipt_domains, ipt_flows], outputs=(y1, y2))
|
||||
|
||||
@@ -50,7 +46,7 @@ def get_new_model(dropout, flow_features, domain_features, window_size, domain_l
|
||||
ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows")
|
||||
encoded = TimeDistributed(cnn)(ipt_domains)
|
||||
|
||||
y2 = Dense(2, activation="softmax", name="server")(encoded)
|
||||
y2 = Dense(1, activation="sigmoid", name="server")(encoded)
|
||||
merged = keras.layers.concatenate([encoded, ipt_flows, y2], -1)
|
||||
|
||||
y = Conv1D(cnn_dims,
|
||||
@@ -62,7 +58,7 @@ def get_new_model(dropout, flow_features, domain_features, window_size, domain_l
|
||||
y = Dropout(dropout)(y)
|
||||
y = Dense(dense_dim, activation='relu')(y)
|
||||
|
||||
y1 = Dense(2, activation='softmax', name="client")(y)
|
||||
y1 = Dense(1, activation='sigmoid', name="client")(y)
|
||||
model = Model(inputs=[ipt_domains, ipt_flows], outputs=(y1, y2))
|
||||
|
||||
return model
|
||||
|
Reference in New Issue
Block a user