-
Notifications
You must be signed in to change notification settings - Fork 64
/
main.py
74 lines (54 loc) · 1.73 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
71
72
from config.configurator import configs
from trainer.trainer import init_seed
from models.bulid_model import build_model
from trainer.logger import Logger
from data_utils.build_data_handler import build_data_handler
from trainer.build_trainer import build_trainer
from trainer.tuner import Tuner
def main():
# First Step: Create data_handler
init_seed()
data_handler = build_data_handler()
data_handler.load_data()
# Second Step: Create model
model = build_model(data_handler).to(configs['device'])
# Third Step: Create logger
logger = Logger()
# Fourth Step: Create trainer
trainer = build_trainer(data_handler, logger)
# Fifth Step: training
best_model = trainer.train(model)
# Sixth Step: test
trainer.test(best_model)
def tune():
# First Step: Create data_handler
init_seed()
data_handler = build_data_handler()
data_handler.load_data()
# Second Step: Create logger
logger = Logger()
# Third Step: Create tuner
tuner = Tuner(logger)
# Fourth Step: Create trainer
trainer = build_trainer(data_handler, logger)
# Fifth Step: Start grid search
tuner.grid_search(data_handler, trainer)
def test():
# First Step: Create data_handler
init_seed()
data_handler = build_data_handler()
data_handler.load_data()
# Second Step: Create model
model = build_model(data_handler).to(configs['device'])
# Third Step: Create logger
logger = Logger()
# Fourth Step: Create trainer
trainer = build_trainer(data_handler, logger)
# Fifth Step: load model from pretrain_path
best_model = trainer.load(model)
# Sixth Step: test
trainer.test(best_model)
if not configs['tune']['enable']:
main()
else:
tune()