-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
70 lines (60 loc) · 1.56 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!usr/bin/bash python
# coding: utf-8
import argparse
import yaml
from torch.utils.data import DataLoader
import anomaly_detection
import utils.data as od
from hyperspace.utils import *
from train import train
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="HypAD")
parser.add_argument(
"-c",
"--config",
type=str,
required=True,
default="/your_default_config_file_path",
)
params = parser.parse_args()
config_path = params.config
params = yaml.load(open(params.config), Loader=yaml.FullLoader)
params = argparse.Namespace(**params)
print("dataset: {}, signal: {}".format(params.dataset, params.signal))
print(params)
train_dataset, test_dataset, read_path = od.dataset_selection(params)
batch_size = params.batch_size
train_loader = DataLoader(
train_dataset,
batch_size=batch_size,
drop_last=True,
shuffle=True,
num_workers=2,
)
test_loader = DataLoader(
test_dataset,
batch_size=batch_size,
drop_last=False,
shuffle=False,
num_workers=2,
)
"""
TRAINING
"""
encoder, decoder, critic_x, critic_z, path = train(
train_loader, params, config_path
)
"""
ANOMALY DETECTOR
"""
anomaly_detection.test_tadgan(
test_loader,
encoder,
decoder,
critic_x,
read_path=read_path,
signal=params.signal,
path=path,
signal_shape=params.signal_shape,
params=params,
)