-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (35 loc) · 1.15 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
import json
import argparse
from trainer import train
def main():
args = setup_parser().parse_args()
param = load_json(args.config)
args = vars(args) # Converting argparse Namespace to a dict.
args.update(param) # Add parameters from json
# debug setting
if args['debug']:
for k in args.keys():
if 'epoch' in k:
args[k] = 2
if 'num_workers' in k:
args[k] = 0
args['device'] = [args['device'][0]]
train(args)
def load_json(settings_path):
with open(settings_path) as data_file:
param = json.load(data_file)
return param
def setup_parser():
parser = argparse.ArgumentParser(
description='Reproduce of multiple continual learning algorthms.')
parser.add_argument('--config',
type=str,
default='./exps/finetune.json',
help='Json file of settings.')
parser.add_argument('--debug',
default=False,
action='store_true',
help='Debug mode.')
return parser
if __name__ == '__main__':
main()