-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
executable file
·311 lines (305 loc) · 8.85 KB
/
config.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#!/usr/bin/env python
# coding: utf-8
#!/usr/bin/env python3
# command-line arguments with their default values
PARAMS_CONFIG = {
# env-specific
'env_params': {
'--run-name': {
'type': str,
'default': 'run',
'help': 'run name',
'dest': 'run_name'
},
'--output-dir': {
'type': str,
'default': 'outputs',
'help': 'output dir',
'dest': 'output_dir'
},
},
'rl_params': {
'--ent-coef': {
'type': float,
'default': 3e-3,
'help': 'entropy coefficient',
'dest': 'ent_coef'
},
'--soft-temp': {
'type': float,
'default': 5e-3,
'help': 'soft temperature of entropy regularization',
'dest': 'soft_temp'
},
'--gamma': {
'type': float,
'default': 0.96,
'help': 'reward discount factor',
'dest': 'gamma'
},
'--nsteps': {
'type': int,
'default': 10,
'help': 'GAE rolling out steps',
'dest': 'nsteps'
},
'--lam': {
'type': float,
'default': 0.98,
'help': 'lam for General Advantage Estimation',
'dest': 'lam'
},
'--target-entropy': {
'type': float,
'default': -0.6,
'help': 'position target entropy for entropy regularization',
'dest': 'tgt_entropy'
},
},
# model-specific
'model_params': {
'--hid-sz': {
'type': int,
'default': 128,
'help': 'hidden size (i.e. model size)',
'dest': 'hidden_size'
},
'--inner-hid-sz': {
'type': int,
'default': 512,
'help': 'inner hidden size of FF layer',
'dest': 'inner_hidden_size'
},
'--encoder-layers': {
'type': int,
'default': 3,
'help': 'number of layers',
'dest': 'encoder_layers'
},
'--decoder-layers': {
'type': int,
'default': 1,
'help': 'number of layers',
'dest': 'decoder_layers'
},
'--critic-encoder-layers': {
'type': int,
'default': 3,
'help': 'number of layers',
'dest': 'c_encoder_layers'
},
'--critic-decoder-layers': {
'type': int,
'default': 1,
'help': 'number of layers',
'dest': 'c_decoder_layers'
},
'--block-sz': {
'type': int,
'default': 20,
'help': 'block size '
'(the length of sequence to process in parallel)',
'dest': 'block_size'
},
'--nheads': {
'type': int,
'default': 8,
'help': 'number of self-attention heads',
'dest': 'nb_heads'
},
'--attn-span': {
'type': int,
'default': 20,
'help': 'length of the attention span',
'dest': 'attn_span'
},
'--dropout': {
'type': float,
'default': 0.0,
'help': 'dropout rate of ReLU and attention',
'dest': 'dropout'
},
'--normalization': {
'type': str,
'default': 'batch',
'help': 'Normalization type,'
'batch or instance or layer',
'dest': 'normalization'
},
'--head-hid': {
'type': int,
'default': 128,
'help': 'head hidden dim(select and rotate)',
'dest': 'head_hidden'
},
'--head-hid-pos': {
'type': int,
'default': 512,
'help': 'position head hidden dim',
'dest': 'head_hidden_pos'
},
},
# problem
'problem_params':{
'--problem-type': {
'type': str,
'default': 'pack3d',
'help': 'problem type (2d or 3d)',
'dest': 'problem_type'
},
'--online': {
'action': 'store_true',
'default': False,
'help': 'on-line packing',
'dest': 'on_line'
},
'--noquery': {
'type': bool,
'default': False,
'help': 'no query model',
'dest': 'no_query'
},
'--block-num': {
'type': int,
'default': 10,
'help': 'number of boxes in each instance',
'dest': 'block_num'
},
'--position-options': {
'type': int,
'default': 128,
'help': 'position options',
'dest': 'p_options'
},
'--size-p1': {
'type': float,
# 'default': 0.02, # 2d
'default': 0.2, # 3d
'help': 'box mean for normal distribution sampling'
'box size high bound for uniform distribution sampling',
'dest': 'size_p1'
},
'--size-p2': {
'type': float,
# 'default': 0.4, # 2d
'default': 0.8, # 3d
'help': 'box variance for normal distribution sampling'
'box size high bound for uniform distribution sampling',
'dest': 'size_p2'
},
'--data-distribution': {
'type': str,
'default': 'uniform',
'help': 'Data distribution to use during training',
'dest': 'distribution'
},
},
# optimization-specific
'optim_params': {
'--actor-lr': {
'type': float,
'default': 4e-5,
'help': 'actor learning rate',
'dest': 'actor_lr'
},
'--critic-lr': {
'type': float,
'default': 1e-4,
'help': 'critic learning rate',
'dest': 'critic_lr'
},
'--lr-warmup': {
'type': int,
'default': 100,
'help': 'linearly increase LR from 0 '
'during first lr_warmup updates'
'warmup_epochs=lr_warmup/(block_size/nsteps)',
'dest': 'lr_warmup'
},
'--grad-clip': {
'type': float,
'default': 5,
'help': 'clip gradient of each module parameters by a given '
'value',
'dest': 'grad_clip'
},
},
# trainer-specific
'trainer_params': {
'--batch-sz': {
'type': int,
'default': 128,
'help': 'batch size',
'dest': 'batch_size'
},
'--niter': {
'type': int,
'default': 100000,
'help': 'number of iterations to train',
'dest': 'nb_iter'
},
'--log-interval': {
'type': int,
'default': 5,
'help': 'number of epoch per command-line print log',
'dest': 'log_interval'
},
'--checkpoint-interval': {
'type': int,
'default': 200,
'help': 'number of epoch per checkpoint',
'dest': 'checkpoint_interval'
},
'--no-tensorboard': {
'action': 'store_true',
'default': False,
'help': 'disable tensorboard.',
'dest': 'no_tensorboard'
},
'--checkpoint': {
'type': str,
'default': '',
'help': 'path to save/load model',
'dest': 'checkpoint_path'
},
'--full-eval-mode': {
'action': 'store_true',
'default': False,
'help': 'do evaluation on the whole validation and the test data',
'dest': 'full_eval_mode'
},
},
# adaptive attention span specific params
'adapt_span_params': {
'--adapt-span': {
'action': 'store_true',
'default': False,
'help': 'enable adaptive attention span',
'dest': 'adapt_span_enabled'
},
'--adapt-span-loss': {
'type': float,
'default': 0,
'help': 'the loss coefficient for span lengths',
'dest': 'adapt_span_loss'
},
'--adapt-span-ramp': {
'type': int,
'default': 16,
'help': 'ramp length of the soft masking function',
'dest': 'adapt_span_ramp'
},
'--adapt-span-init': {
'type': float,
'default': 0,
'help': 'initial attention span ratio',
'dest': 'adapt_span_init'
},
'--adapt-span-cache': {
'action': 'store_true',
'default': False,
'help': 'adapt cache size as well to reduce memory usage',
'dest': 'adapt_span_cache'
},
},
}