-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntime.py
75 lines (50 loc) · 2.46 KB
/
runtime.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from trainer import Trainer
import argparse
from PIL import Image
import os
parser = argparse.ArgumentParser()
parser.add_argument('--input_dir', type=str, default='./datasets',
help='input directory for visual question answering.')
parser.add_argument('--log_dir', type=str, default='./logs',
help='directory for logs.')
parser.add_argument('--model_dir', type=str, default='./models',
help='directory for saved models.')
parser.add_argument('--max_qst_length', type=int, default=30,
help='maximum length of question. \
the length in the VQA dataset = 26.')
parser.add_argument('--max_num_ans', type=int, default=10,
help='maximum number of answers.')
parser.add_argument('--embed_size', type=int, default=1024,
help='embedding size of feature vector \
for both image and question.')
parser.add_argument('--word_embed_size', type=int, default=300,
help='embedding size of word \
used for the input in the LSTM.')
parser.add_argument('--num_layers', type=int, default=2,
help='number of layers of the RNN(LSTM).')
parser.add_argument('--hidden_size', type=int, default=512,
help='hidden_size in the LSTM.')
parser.add_argument('--lr', type=float, default=0.001,
help='learning rate for training.')
parser.add_argument('--step_size', type=int, default=10,
help='period of learning rate decay.')
parser.add_argument('--gamma', type=float, default=0.1,
help='multiplicative factor of learning rate decay.')
parser.add_argument('--num_epochs', type=int, default=300,
help='number of epochs.')
parser.add_argument('--batch_size', type=int, default=256,
help='batch_size.')
parser.add_argument('--num_workers', type=int, default=0,
help='number of processes working on cpu.')
parser.add_argument('--save_step', type=int, default=1,
help='save step of model.')
parser.add_argument("--demo", default=False, action='store_true')
parser.add_argument("--l1_coef", default=50, type=float)
parser.add_argument("--l2_coef", default=100, type=float)
parser.add_argument("--save_path", default='')
args = parser.parse_args()
trainer = Trainer(args)
if not args.demo:
trainer.train()
else:
trainer.demo()