diff --git a/main.py b/main.py index dd76b04..e2e56da 100644 --- a/main.py +++ b/main.py @@ -156,6 +156,7 @@ def main_train(param=None): logger.info("compile and train model") embedding.summary() model.summary() + logger.info(model.get_config()) model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'] + custom_metrics) diff --git a/models/pauls_networks.py b/models/pauls_networks.py index bb824fd..bd3f07a 100644 --- a/models/pauls_networks.py +++ b/models/pauls_networks.py @@ -68,10 +68,10 @@ def get_new_model(dropout, flow_features, domain_features, window_size, domain_l ipt_domains = Input(shape=(window_size, domain_length), name="ipt_domains") ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows") encoded = TimeDistributed(cnn)(ipt_domains) - - y2 = Dense(1, activation="sigmoid", name="server")(encoded) - merged = keras.layers.concatenate([encoded, ipt_flows, y2], -1) - + merged = keras.layers.concatenate([encoded, ipt_flows], -1) + y = Dense(dense_dim, activation="relu")(merged) + y2 = Dense(1, activation="sigmoid", name="server")(y) + # CNN processing a small slides of flow windows y = Conv1D(cnn_dims, kernel_size, activation='relu', diff --git a/models/renes_networks.py b/models/renes_networks.py index 1f485c1..96b684d 100644 --- a/models/renes_networks.py +++ b/models/renes_networks.py @@ -51,14 +51,16 @@ def get_new_model(dropout, flow_features, domain_features, window_size, domain_l ipt_domains = Input(shape=(window_size, domain_length), name="ipt_domains") ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows") encoded = TimeDistributed(cnn)(ipt_domains) - - y2 = Dense(1, activation="sigmoid", name="server")(encoded) - merged = keras.layers.concatenate([encoded, ipt_flows, y2], -1) - - y = Conv1D(cnn_dims, - kernel_size, - activation='relu', - input_shape=(window_size, domain_features + flow_features))(merged) + merged = keras.layers.concatenate([encoded, ipt_flows], -1) + y = Dense(dense_dim, activation="relu")(merged) + y2 = Dense(1, activation="sigmoid", name="server")(y) + # CNN processing a small slides of flow windows + y = Conv1D(filters=cnn_dims, kernel_size=kernel_size, activation='relu', padding="same", + input_shape=(window_size, domain_features + flow_features))(y) + y = MaxPool1D(pool_size=3, strides=1)(y) + y = Conv1D(filters=cnn_dims, kernel_size=kernel_size, activation='relu', padding="same")(y) + y = MaxPool1D(pool_size=3, strides=1)(y) + y = Conv1D(filters=cnn_dims, kernel_size=kernel_size, activation='relu', padding="same")(y) # remove temporal dimension by global max pooling y = GlobalMaxPooling1D()(y) y = Dropout(dropout)(y) diff --git a/run.sh b/run.sh index f6a14da..65778eb 100644 --- a/run.sh +++ b/run.sh @@ -4,30 +4,29 @@ python main.py --mode train \ --train /tmp/rk/currentData.csv \ --model /tmp/rk/results/simple_both \ --epochs 25 \ - --hidden_char_dims 128 \ + --embd 64 \ + --hidden_chaar_dims 128 \ --domain_embd 32 \ --batch 256 \ --balanced_weights \ --model_output both -python main.py --mode test --batch 512 --model /tmp/rk/results/simple_both --test /tmp/rk/futureData.csv --model_output both - python main.py --mode train \ --train /tmp/rk/currentData.csv \ --model /tmp/rk/results/simple_client \ --epochs 25 \ + --embd 64 \ --hidden_char_dims 128 \ --domain_embd 32 \ --batch 256 \ --balanced_weights \ --model_output client -python main.py --mode test --batch 512 --model /tmp/rk/results/simple_client --test /tmp/rk/futureData.csv --model_output client - python main.py --mode train \ --train /tmp/rk/currentData.csv \ --model /tmp/rk/results/simple_new_both \ --epochs 25 \ + --embd 64 \ --hidden_char_dims 128 \ --domain_embd 32 \ --batch 256 \ @@ -35,17 +34,65 @@ python main.py --mode train \ --model_output both \ --new_model -python main.py --mode test --batch 512 --model /tmp/rk/results/simple_new_both --test /tmp/rk/futureData.csv --model_output both - python main.py --mode train \ --train /tmp/rk/currentData.csv \ --model /tmp/rk/results/simple_new_client \ --epochs 25 \ + --embd 64 \ --hidden_char_dims 128 \ --domain_embd 32 \ --batch 256 \ --balanced_weights \ --model_output client \ --new_model +## +## +python main.py --mode train \ + --train /tmp/rk/currentData.csv \ + --model /tmp/rk/results/simple_both \ + --epochs 25 \ + --embd 64 \ + --hidden_chaar_dims 128 \ + --domain_embd 32 \ + --batch 256 \ + --balanced_weights \ + --model_output both \ + --type rene -python main.py --mode test --batch 512 --model /tmp/rk/results/simple_new_client --test /tmp/rk/futureData.csv --model_output client \ No newline at end of file +python main.py --mode train \ + --train /tmp/rk/currentData.csv \ + --model /tmp/rk/results/simple_client \ + --epochs 25 \ + --embd 64 \ + --hidden_char_dims 128 \ + --domain_embd 32 \ + --batch 256 \ + --balanced_weights \ + --model_output client \ + --type rene + +python main.py --mode train \ + --train /tmp/rk/currentData.csv \ + --model /tmp/rk/results/simple_new_both \ + --epochs 25 \ + --embd 64 \ + --hidden_char_dims 128 \ + --domain_embd 32 \ + --batch 256 \ + --balanced_weights \ + --model_output both \ + --new_model \ + --type rene + +python main.py --mode train \ + --train /tmp/rk/currentData.csv \ + --model /tmp/rk/results/simple_new_client \ + --epochs 25 \ + --embd 64 \ + --hidden_char_dims 128 \ + --domain_embd 32 \ + --batch 256 \ + --balanced_weights \ + --model_output client \ + --new_model \ + --type rene diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..ffe15f7 --- /dev/null +++ b/test.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_both --test /tmp/rk/futureData.csv --model_output both --type paul +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_client --test /tmp/rk/futureData.csv --model_output client --type paul +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_new_both --test /tmp/rk/futureData.csv --model_output both --type paul +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_new_client --test /tmp/rk/futureData.csv --model_output client --type paul + +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_both --test /tmp/rk/futureData.csv --model_output both --type rene +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_client --test /tmp/rk/futureData.csv --model_output client --type rene +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_new_both --test /tmp/rk/futureData.csv --model_output both --type rene +python main.py --mode test --batch 1024 --model /tmp/rk/results/simple_new_client --test /tmp/rk/futureData.csv --model_output client --type rene \ No newline at end of file diff --git a/visualize.py b/visualize.py index 6d1ec1f..0c7b7cd 100644 --- a/visualize.py +++ b/visualize.py @@ -2,7 +2,7 @@ import os import matplotlib.pyplot as plt import numpy as np -from keras.utils import plot_model +from keras.utils.vis_utils import plot_model from sklearn.decomposition import TruncatedSVD from sklearn.metrics import ( auc, classification_report, confusion_matrix, fbeta_score, precision_recall_curve,