-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinput_args.py
341 lines (333 loc) · 11.4 KB
/
input_args.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
import argparse
from continualworld.tasks import TASK_SEQS
from continualworld.utils.enums import BufferType
from continualworld.utils.utils import float_or_str, sci2int, str2bool
def cl_parse_args(args=None):
parser = argparse.ArgumentParser(description="Continual World")
task_group = parser.add_mutually_exclusive_group()
task_group.add_argument(
"--tasks",
type=str,
choices=TASK_SEQS.keys(),
default=None,
help="Name of the sequence you want to run",
)
task_group.add_argument(
"--task_list",
nargs="+",
default=None,
help="List of tasks you want to run, by name or by the MetaWorld index",
)
parser.add_argument(
"--logger_output",
type=str,
nargs="+",
choices=["neptune", "tensorboard", "tsv"],
default=["tsv"],
help="Types of logger used.",
)
parser.add_argument(
"--group_id",
type=str,
default="default_group",
help="Group ID, for grouping logs from different experiments into common directory",
)
parser.add_argument("--seed", type=int, help="Seed for randomness")
parser.add_argument(
"--steps_per_task", type=sci2int, default=int(1e6), help="Numer of steps per task"
)
parser.add_argument(
"--log_every",
type=sci2int,
default=int(2e4),
help="Number of steps between subsequent evaluations and logging",
)
parser.add_argument(
"--replay_size", type=sci2int, default=int(1e6), help="Size of the replay buffer"
)
parser.add_argument(
"--batch_size", type=int, default=128, help="Minibatch size for the optimization"
)
parser.add_argument(
"--hidden_sizes",
type=int,
nargs="+",
default=[256, 256, 256, 256],
help="Hidden sizes list for the MLP models",
)
parser.add_argument(
"--buffer_type",
type=str,
default="fifo",
choices=[b.value for b in BufferType],
help="Strategy of inserting examples into the buffer",
)
parser.add_argument(
"--reset_buffer_on_task_change",
type=str2bool,
default=True,
help="If true, replay buffer is reset on each task change",
)
parser.add_argument(
"--reset_optimizer_on_task_change",
type=str2bool,
default=True,
help="If true, optimizer is reset on each task change",
)
parser.add_argument(
"--reset_critic_on_task_change",
type=str2bool,
default=False,
help="If true, critic model is reset on each task change",
)
parser.add_argument(
"--activation", type=str, default="lrelu", help="Activation kind for the models"
)
parser.add_argument(
"--use_layer_norm",
type=str2bool,
default=True,
help="Whether or not use layer normalization",
)
parser.add_argument("--lr", type=float, default=1e-3, help="Learning rate for the optimizer")
parser.add_argument("--gamma", type=float, default=0.99, help="Discount factor")
parser.add_argument(
"--alpha",
default="auto",
help="Entropy regularization coefficient. "
"Can be either float value, or 'auto', in which case it is dynamically tuned.",
)
parser.add_argument(
"--target_output_std",
type=float,
default=0.089,
help="If alpha is 'auto', alpha is dynamically tuned so that standard deviation "
"of the action distribution on every dimension matches target_output_std.",
)
parser.add_argument(
"--cl_method",
type=str,
choices=[None, "l2", "ewc", "mas", "vcl", "packnet", "agem"],
default=None,
help="If None, finetuning method will be used. If one of 'l2', 'ewc', 'mas', 'vcl',"
"'packnet', 'agem', respective method will be used.",
)
parser.add_argument(
"--packnet_retrain_steps",
type=int,
default=0,
help="Number of retrain steps after network pruning, which occurs after each task",
)
parser.add_argument(
"--regularize_critic",
type=str2bool,
default=False,
help="If True, both actor and critic are regularized; if False, only actor is",
)
parser.add_argument(
"--cl_reg_coef",
type=float,
default=0.0,
help="Regularization strength for continual learning methods. "
"Valid for 'l2', 'ewc', 'mas' continual learning methods.",
)
parser.add_argument(
"--vcl_first_task_kl",
type=str2bool,
default=False,
help="If True, use KL regularization also for the first task in 'vcl' continual learning"
"method.",
)
parser.add_argument(
"--episodic_mem_per_task",
type=int,
default=0,
help="Number of examples to keep in additional memory per task. Valid for 'agem' continual"
"learning method.",
)
parser.add_argument(
"--episodic_batch_size",
type=int,
default=0,
help="Minibatch size to compute additional loss in 'agem' continual learning method.",
)
parser.add_argument(
"--multihead_archs", type=str2bool, default=True, help="Whether use multi-head architecture"
)
parser.add_argument(
"--hide_task_id",
type=str2bool,
default=True,
help="if True, one-hot encoding of the task will not be appended to observation",
)
parser.add_argument("--clipnorm", type=float, default=None, help="Value for gradient clipping")
parser.add_argument(
"--agent_policy_exploration",
type=str2bool,
default=False,
help="If True, uniform exploration for start_steps steps is used only in the first task"
"(in continual learning). Otherwise, it is used in every task",
)
return parser.parse_args(args=args)
def mt_parse_args(args=None):
parser = argparse.ArgumentParser(description="Continual World")
task_group = parser.add_mutually_exclusive_group()
task_group.add_argument(
"--tasks",
type=str,
choices=TASK_SEQS.keys(),
default=None,
help="Name of the sequence you want to run",
)
task_group.add_argument(
"--task_list",
nargs="+",
default=None,
help="List of tasks you want to run, by name or by the MetaWorld index",
)
parser.add_argument(
"--logger_output",
type=str,
nargs="+",
choices=["neptune", "tensorboard", "tsv"],
default=["tsv"],
help="Types of logger used.",
)
parser.add_argument(
"--group_id",
type=str,
default="default_group",
help="Group ID, for grouping logs from different experiments into common directory",
)
parser.add_argument("--seed", type=int, help="Seed for randomness")
parser.add_argument(
"--steps_per_task", type=sci2int, default=int(1e6), help="Numer of steps per task"
)
parser.add_argument(
"--log_every",
type=sci2int,
default=int(2e4),
help="Number of steps between subsequent evaluations and logging",
)
parser.add_argument(
"--replay_size", type=sci2int, default=int(1e6), help="Size of the replay buffer"
)
parser.add_argument(
"--batch_size", type=int, default=128, help="Minibatch size for the optimization"
)
parser.add_argument(
"--hidden_sizes",
type=int,
nargs="+",
default=[256, 256, 256, 256],
help="Hidden sizes list for the MLP models",
)
parser.add_argument(
"--activation", type=str, default="lrelu", help="Activation kind for the models"
)
parser.add_argument(
"--use_layer_norm",
type=str2bool,
default=True,
help="Whether or not use layer normalization",
)
parser.add_argument("--lr", type=float, default=1e-4, help="Learning rate for the optimizer")
parser.add_argument("--gamma", type=float, default=0.99, help="Discount factor")
parser.add_argument(
"--alpha",
default="auto",
help="Entropy regularization coefficient. "
"Can be either float value, or 'auto', in which case it is dynamically tuned.",
)
parser.add_argument(
"--target_output_std",
type=float,
default=0.089,
help="If alpha is 'auto', alpha is dynamically tuned so that standard deviation "
"of the action distribution on every dimension matches target_output_std.",
)
parser.add_argument(
"--use_popart", type=str2bool, default=True, help="Whether use PopArt normalization"
)
parser.add_argument(
"--popart_beta",
type=float,
default=3e-4,
help="Beta parameter for updating statistics in PopArt",
)
parser.add_argument(
"--multihead_archs", type=str2bool, default=True, help="Whether use multi-head architecture"
)
parser.add_argument(
"--hide_task_id",
type=str2bool,
default=True,
help="if True, one-hot encoding of the task will not be appended to observation",
)
return parser.parse_args(args=args)
def single_parse_args(args=None):
parser = argparse.ArgumentParser(description="Run single task")
parser.add_argument("--task", type=str, help="Name of the task")
parser.add_argument(
"--logger_output",
type=str,
nargs="+",
choices=["neptune", "tensorboard", "tsv"],
default=["tsv"],
help="Types of logger used.",
)
parser.add_argument(
"--group_id",
type=str,
default="default_group",
help="Group ID, for grouping logs from different experiments into common directory",
)
parser.add_argument("--seed", type=int, default=0, help="Seed for randomness")
parser.add_argument(
"--steps", type=sci2int, default=int(1e6), help="Number of steps the algorithm will run for"
)
parser.add_argument(
"--log_every",
type=sci2int,
default=int(2e4),
help="Number of steps between subsequent evaluations and logging",
)
parser.add_argument(
"--replay_size", type=sci2int, default=int(1e6), help="Size of the replay buffer"
)
parser.add_argument(
"--batch_size", type=int, default=128, help="Minibatch size for the optimization"
)
parser.add_argument(
"--hidden_sizes",
type=int,
nargs="+",
default=[256, 256, 256, 256],
help="Hidden sizes list for the MLP models",
)
parser.add_argument(
"--activation", type=str, default="lrelu", help="Activation kind for the models"
)
parser.add_argument(
"--use_layer_norm",
type=str2bool,
default=True,
help="Whether or not use layer normalization",
)
parser.add_argument("--lr", type=float, default=1e-3, help="Learning rate for the optimizer")
parser.add_argument("--gamma", type=float, default=0.99, help="Discount factor")
parser.add_argument(
"--alpha",
type=float_or_str,
default="auto",
help="Entropy regularization coefficient. "
"Can be either float value, or 'auto', in which case it is dynamically tuned.",
)
parser.add_argument(
"--target_output_std",
type=float,
default=0.089,
help="If alpha is 'auto', alpha is dynamically tuned so that standard deviation "
"of the action distribution on every dimension matches target_output_std.",
)
return parser.parse_args(args=args)