This repository has been archived by the owner on Oct 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_url.py
47 lines (38 loc) · 1.59 KB
/
do_url.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import tensorflow as tf
from argparse import ArgumentParser
from libs.DataHandler import URL
from libs.ExperimentWrapper import ExperimentWrapper
from libs.constants import add_standard_arguments, ALARM_SMALL, ALARM_BIG
# Reduce the hunger of TF when we're training on a GPU
try:
tf.config.experimental.set_memory_growth(tf.config.list_physical_devices("GPU")[0], True)
except IndexError:
tf.config.run_functions_eagerly(True)
pass # No GPUs available
# Configuration
this_parse = ArgumentParser(description="Train ARGUE on URL")
add_standard_arguments(this_parse)
this_args = this_parse.parse_args()
experiment_config = [
URL(
random_state=this_args.random_seed, y_normal=['0', '1'],
y_anomalous=["Defacement", "malware", "phishing", "spam"],
n_train_anomalies=this_args.n_train_anomalies, p_pollution=this_args.p_contamination
)
]
DIM_TARGET = (100, 80, 60, 40, 20, 10)
DIM_ALARM = ALARM_BIG
BATCH_SIZE = 64
A4RGUE_CLUSTERS = 3
if __name__ == '__main__':
this_experiment = ExperimentWrapper(
save_prefix="URL", data_setup=experiment_config,
random_seed=this_args.random_seed, out_path=this_args.model_path,
p_contamination=this_args.p_contamination, is_override=this_args.is_override
)
this_experiment.do_everything(
dim_target=DIM_TARGET, dim_alarm=DIM_ALARM,
learning_rate=this_args.learning_rate, batch_size=BATCH_SIZE, n_epochs=this_args.n_epochs,
out_path=this_args.result_path, evaluation_split=this_args.data_split,
train_devnet=this_args.n_train_anomalies > 0, a4rgue_clusters=A4RGUE_CLUSTERS
)