-
Notifications
You must be signed in to change notification settings - Fork 58
/
main.py
42 lines (36 loc) · 1.44 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
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Albert Berenguel
## Computer Vision Center (CVC). Universitat Autonoma de Barcelona
## Email: [email protected]
## Copyright (c) 2017
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import importlib
from option import Options
from logger import Logger
import numpy as np
# Import params from Config
# Parse other options
args = Options().parse()
# load config info for task, data, and model
opt = {}
opt = importlib.import_module(args.task).params(opt)
opt = importlib.import_module(args.data).params(opt)
opt = importlib.import_module(args.model).params(opt)
if not args.test == '-':
opt = importlib.import_module(args.test).params(opt)
LOG_DIR = args.log_dir + '/task_{}_data_{}_model_{}' \
.format(args.task,args.data,args.model)
# create logger
logger = Logger(LOG_DIR)
# Print options
print('Training with options:')
for key in sorted(opt.iterkeys()):
print "%s: %s" % (key, opt[key])
# set up meta-train, meta-validation and meta-test datasets
data = importlib.import_module(opt['dataLoader']).getData(opt)
# Run the training, validation and test.
results = importlib.import_module(opt['metaLearner']).run(opt,data)
print('Task: %s. Data: %s. Model: %s' % (args.task,args.data,args.model) )