forked from KunpengLi1994/VSRN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opts.py
148 lines (130 loc) · 4.44 KB
/
opts.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import argparse
def parse_opt():
parser = argparse.ArgumentParser()
# Data input settings
parser.add_argument(
'--input_json',
type=str,
default='data/videodatainfo_2017.json',
help='path to the json file containing video info')
parser.add_argument(
'--info_json',
type=str,
default='data/info.json',
help='path to the json file containing additional info and vocab')
parser.add_argument(
'--caption_json',
type=str,
default='data/caption.json',
help='path to the processed video caption json')
parser.add_argument(
'--feats_dir',
nargs='*',
type=str,
default=['data/feats/resnet152/'],
help='path to the directory containing the preprocessed fc feats')
parser.add_argument('--c3d_feats_dir', type=str, default='data/c3d_feats')
parser.add_argument(
'--with_c3d', type=int, default=0, help='whether to use c3d features')
parser.add_argument(
'--cached_tokens',
type=str,
default='msr-all-idxs',
help='Cached token file for calculating cider score \
during self critical training.')
# Model settings
parser.add_argument(
"--model", type=str, default='S2VTModel', help="with model to use")
parser.add_argument(
"--max_len",
type=int,
default=28,
help='max length of captions(containing <sos>,<eos>)')
parser.add_argument(
"--bidirectional",
type=int,
default=0,
help="0 for disable, 1 for enable. encoder/decoder bidirectional.")
parser.add_argument(
'--dim_hidden',
type=int,
default=512,
help='size of the rnn hidden layer')
parser.add_argument(
'--num_layers', type=int, default=1, help='number of layers in the RNN')
parser.add_argument(
'--input_dropout_p',
type=float,
default=0.2,
help='strength of dropout in the Language Model RNN')
parser.add_argument(
'--rnn_type', type=str, default='gru', help='lstm or gru')
parser.add_argument(
'--rnn_dropout_p',
type=float,
default=0.5,
help='strength of dropout in the Language Model RNN')
parser.add_argument(
'--dim_word',
type=int,
default=512,
help='the encoding size of each token in the vocabulary, and the video.'
)
parser.add_argument(
'--dim_vid',
type=int,
default=2048,
help='dim of features of video frames')
# Optimization: General
parser.add_argument(
'--epochs', type=int, default=6001, help='number of epochs')
parser.add_argument(
'--batch_size', type=int, default=128, help='minibatch size')
parser.add_argument(
'--grad_clip',
type=float,
default=5, # 5.,
help='clip gradients at this value')
parser.add_argument(
'--self_crit_after',
type=int,
default=-1,
help='After what epoch do we start finetuning the CNN? \
(-1 = disable; never finetune, 0 = finetune from start)'
)
parser.add_argument(
'--learning_rate', type=float, default=4e-4, help='learning rate')
parser.add_argument(
'--learning_rate_decay_every',
type=int,
default=200,
help='every how many iterations thereafter to drop LR?(in epoch)')
parser.add_argument('--learning_rate_decay_rate', type=float, default=0.8)
parser.add_argument(
'--optim_alpha', type=float, default=0.9, help='alpha for adam')
parser.add_argument(
'--optim_beta', type=float, default=0.999, help='beta used for adam')
parser.add_argument(
'--optim_epsilon',
type=float,
default=1e-8,
help='epsilon that goes into denominator for smoothing')
parser.add_argument(
'--weight_decay',
type=float,
default=5e-4,
help='weight_decay. strength of weight regularization')
parser.add_argument(
'--save_checkpoint_every',
type=int,
default=50,
help='how often to save a model checkpoint (in epoch)?')
parser.add_argument(
'--checkpoint_path',
type=str,
default='save',
help='directory to store checkpointed models')
parser.add_argument(
'--gpu', type=str, default='0', help='gpu device number')
args = parser.parse_args()
return args