-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_experiment.py
23 lines (19 loc) · 1005 Bytes
/
run_experiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import torch
import argparse
import importlib
import logging
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('expname', type = str)
parser.add_argument('-v', '--verbose', action = 'store_true', help='set logging level = INFO')
parser.add_argument('--debug', action = 'store_true', help='set logging level = DEBUG')
parser.add_argument('-nw', '--no-warning', action = 'store_true', help='ignore warning, set logging level = ERROR')
parser.add_argument('--log', type=str, default = '')
parser.add_argument('-nt', '--num-threads', type=int, default=4)
args = parser.parse_args()
torch.set_num_threads(args.num_threads)
if args.debug: logging.basicConfig(level = logging.DEBUG)
if args.verbose: logging.basicConfig(level = logging.INFO)
if args.no_warning: logging.basicConfig(level = logging.ERROR)
if args.log != '': logging.basicConfig(filename = args.log)
importlib.import_module('experiments.' + args.expname)