-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
41 lines (34 loc) · 1.39 KB
/
run.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@Author : Albert Gregus
@Email : [email protected]
"""
import argparse
import logging
from config import ConfigNamespace
from ml.solvers.hpo_solver import HPOSolver
from ml.solvers.ml_solver import MLSolver
from utils.device import DEVICE
from utils.init_random_seeds import set_random_seed
logging.basicConfig(format='[%(asctime)s %(levelname)s] %(message)s',
datefmt='%Y/%m/%d %H:%M:%S',
level=logging.INFO)
parser = argparse.ArgumentParser(description='Training script')
parser.add_argument('--id_tag', type=str, default='base', help='Id of the training in addition of the config name')
parser.add_argument('--mode', type=str, default='train', choices=['train', 'val', 'test', 'hpo'],
help='The mode of the running.')
parser.add_argument('-c', '--config', type=str, default='base', help='Config file name')
parser.add_argument('--save_preds', action='store_true')
parser.add_argument('-v', '--visualize', action='store_true')
args = parser.parse_args()
if __name__ == '__main__':
config = ConfigNamespace(args.config)
set_random_seed(config.env.random_seed)
logging.info(f'Using {DEVICE} for running.')
# run a simple training/val/test or an HPO
if args.mode == 'hpo':
solver = HPOSolver(config, args)
else:
solver = MLSolver(config, args)
solver.run()