-
Notifications
You must be signed in to change notification settings - Fork 26
/
main.py
36 lines (25 loc) · 823 Bytes
/
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
# -*- coding: utf-8 -*-
# ---------------------
import click
import torch.backends.cudnn as cudnn
from conf import Conf
from trainer import Trainer
cudnn.benchmark = True
@click.command()
@click.argument('exp_name', type=str, default='default')
@click.option('--seed', type=int, default=None)
def main(exp_name, seed):
# type: (str, int) -> None
# if `exp_name` contains a '@' character,
# the number following '@' is considered as
# the desired random seed for the experiment
split = exp_name.split('@')
if len(split) == 2:
seed = int(split[1])
exp_name = split[0]
cnf = Conf(seed=seed, exp_name=exp_name)
print(f'\n▶ Starting Experiment \'{exp_name}\' [seed: {cnf.seed}]')
trainer = Trainer(cnf=cnf)
trainer.run()
if __name__ == '__main__':
main()