change model - add dense before server output in new model

add some new run scripts
This commit is contained in:
René Knaebel 2017-08-05 09:33:07 +02:00
parent 6e7dc1297c
commit 5a02f582cd
6 changed files with 82 additions and 21 deletions

View File

@ -156,6 +156,7 @@ def main_train(param=None):
logger.info("compile and train model") logger.info("compile and train model")
embedding.summary() embedding.summary()
model.summary() model.summary()
logger.info(model.get_config())
model.compile(optimizer='adam', model.compile(optimizer='adam',
loss='binary_crossentropy', loss='binary_crossentropy',
metrics=['accuracy'] + custom_metrics) metrics=['accuracy'] + custom_metrics)

View File

@ -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_domains = Input(shape=(window_size, domain_length), name="ipt_domains")
ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows") ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows")
encoded = TimeDistributed(cnn)(ipt_domains) encoded = TimeDistributed(cnn)(ipt_domains)
merged = keras.layers.concatenate([encoded, ipt_flows], -1)
y2 = Dense(1, activation="sigmoid", name="server")(encoded) y = Dense(dense_dim, activation="relu")(merged)
merged = keras.layers.concatenate([encoded, ipt_flows, y2], -1) y2 = Dense(1, activation="sigmoid", name="server")(y)
# CNN processing a small slides of flow windows
y = Conv1D(cnn_dims, y = Conv1D(cnn_dims,
kernel_size, kernel_size,
activation='relu', activation='relu',

View File

@ -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_domains = Input(shape=(window_size, domain_length), name="ipt_domains")
ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows") ipt_flows = Input(shape=(window_size, flow_features), name="ipt_flows")
encoded = TimeDistributed(cnn)(ipt_domains) encoded = TimeDistributed(cnn)(ipt_domains)
merged = keras.layers.concatenate([encoded, ipt_flows], -1)
y2 = Dense(1, activation="sigmoid", name="server")(encoded) y = Dense(dense_dim, activation="relu")(merged)
merged = keras.layers.concatenate([encoded, ipt_flows, y2], -1) y2 = Dense(1, activation="sigmoid", name="server")(y)
# CNN processing a small slides of flow windows
y = Conv1D(cnn_dims, y = Conv1D(filters=cnn_dims, kernel_size=kernel_size, activation='relu', padding="same",
kernel_size, input_shape=(window_size, domain_features + flow_features))(y)
activation='relu', y = MaxPool1D(pool_size=3, strides=1)(y)
input_shape=(window_size, domain_features + flow_features))(merged) 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 # remove temporal dimension by global max pooling
y = GlobalMaxPooling1D()(y) y = GlobalMaxPooling1D()(y)
y = Dropout(dropout)(y) y = Dropout(dropout)(y)

63
run.sh
View File

@ -4,30 +4,29 @@ python main.py --mode train \
--train /tmp/rk/currentData.csv \ --train /tmp/rk/currentData.csv \
--model /tmp/rk/results/simple_both \ --model /tmp/rk/results/simple_both \
--epochs 25 \ --epochs 25 \
--hidden_char_dims 128 \ --embd 64 \
--hidden_chaar_dims 128 \
--domain_embd 32 \ --domain_embd 32 \
--batch 256 \ --batch 256 \
--balanced_weights \ --balanced_weights \
--model_output both --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 \ python main.py --mode train \
--train /tmp/rk/currentData.csv \ --train /tmp/rk/currentData.csv \
--model /tmp/rk/results/simple_client \ --model /tmp/rk/results/simple_client \
--epochs 25 \ --epochs 25 \
--embd 64 \
--hidden_char_dims 128 \ --hidden_char_dims 128 \
--domain_embd 32 \ --domain_embd 32 \
--batch 256 \ --batch 256 \
--balanced_weights \ --balanced_weights \
--model_output client --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 \ python main.py --mode train \
--train /tmp/rk/currentData.csv \ --train /tmp/rk/currentData.csv \
--model /tmp/rk/results/simple_new_both \ --model /tmp/rk/results/simple_new_both \
--epochs 25 \ --epochs 25 \
--embd 64 \
--hidden_char_dims 128 \ --hidden_char_dims 128 \
--domain_embd 32 \ --domain_embd 32 \
--batch 256 \ --batch 256 \
@ -35,17 +34,65 @@ python main.py --mode train \
--model_output both \ --model_output both \
--new_model --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 \ python main.py --mode train \
--train /tmp/rk/currentData.csv \ --train /tmp/rk/currentData.csv \
--model /tmp/rk/results/simple_new_client \ --model /tmp/rk/results/simple_new_client \
--epochs 25 \ --epochs 25 \
--embd 64 \
--hidden_char_dims 128 \ --hidden_char_dims 128 \
--domain_embd 32 \ --domain_embd 32 \
--batch 256 \ --batch 256 \
--balanced_weights \ --balanced_weights \
--model_output client \ --model_output client \
--new_model --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 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

11
test.sh Normal file
View File

@ -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

View File

@ -2,7 +2,7 @@ import os
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np 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.decomposition import TruncatedSVD
from sklearn.metrics import ( from sklearn.metrics import (
auc, classification_report, confusion_matrix, fbeta_score, precision_recall_curve, auc, classification_report, confusion_matrix, fbeta_score, precision_recall_curve,