-
Notifications
You must be signed in to change notification settings - Fork 1
/
input_args.py
379 lines (376 loc) · 9.81 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
import argparse
def parse_args(args=None):
parser = argparse.ArgumentParser()
parser.add_argument(
'--cuda_num',
type=int,
default=0,
)
parser.add_argument(
'--hierarchical',
action='store_true',
default=False,
help='whether to train with the hierarchical OT algo',
)
parser.add_argument(
'--batchwise_lava',
action='store_true',
default=False,
help='whether to train with an independent LAVA run per train/val batch.',
)
parser.add_argument(
'--random_seed',
type=int,
default=2021,
)
parser.add_argument(
'--tag',
type=str,
default='',
help='unique tag',
)
parser.add_argument(
'--corruption_type',
required=True,
type=str,
help='corruption type, in {shuffle, feature, trojan_sq, poison_frogs}',
)
parser.add_argument(
'--cache_l2l',
action='store_true',
default=False,
help='whether cache label-2-label distances.',
)
parser.add_argument(
'--hot_batch_size',
type=int,
default=1024,
help='hierarchical ot batch size.',
)
parser.add_argument(
'--corrupt_por',
type=float,
default=0.0,
help='fraction of corrupted data.',
)
parser.add_argument(
'--prune_perc',
type=float,
default=0.1,
help='fraction of data remove from the dataset.',
)
parser.add_argument(
'--smoketest',
action='store_true',
default=False,
help='whether to run a tesr run.',
)
parser.add_argument(
'--disable_wandb',
action='store_true',
default=False,
help='whether to stop wandb logging.',
)
parser.add_argument(
'--train_net',
action='store_true',
default=False,
help='whether to run training of a model with pruned dataset.',
)
parser.add_argument(
'--feat_repr',
action='store_true',
default=False,
help='whether to use the feat dim or the output dim for LAVA.',
)
parser.add_argument(
'--poison_frogs_feat_repr',
action='store_true',
default=False,
help='whether to use the feat dim or the output dim repr for poison frogs attack.',
)
parser.add_argument(
'--train_dataset_sizes',
nargs="+",
type=int,
required=False,
default = [500, 1000, 2000, 5000, 10000, 20000, 50000],
help='training set sizes to loop over.',
)
parser.add_argument(
'--remake_data',
action='store_true',
default=False,
help='whether to reset the data creation process for poison frogs attack.',
)
parser.add_argument(
'--cache_tag',
type=str,
default='',
help='unique tag',
)
parser.add_argument(
'--data_gen_force_cpu',
action='store_true',
default=False,
help='whether to use the cpu for data gen only useful for avoiding poison frogs seg faults.',
)
parser.add_argument(
'--stratified',
action='store_true',
default=False,
help='whether to train stratified sampling (each class is sampled evenly within a batch).',
)
parser.add_argument(
'--visualise_hot',
action='store_true',
default=False,
help='whether to cache artifacts from HOT/SAVA algorithm.',
)
parser.add_argument(
'--val_dataset_size',
type=int,
default = 10000,
help='val/test set size.',
)
parser.add_argument(
'--evaluate',
action='store_true',
default=False,
help='whether to run on the test set versus the valid.',
)
args = parser.parse_known_args(args=args)[0]
return args
def nonstat_args(args=None):
parser = argparse.ArgumentParser()
parser.add_argument(
'--cuda_num',
type=int,
default=0,
)
parser.add_argument(
'--hierarchical',
action='store_true',
default=False,
help='whether to train with the hierarchical OT algo',
)
parser.add_argument(
'--random_seed',
type=int,
default=2021,
)
parser.add_argument(
'--tag',
type=str,
default='',
help='unique tag',
)
parser.add_argument(
'--corruption_type',
required=True,
type=str,
help='corruption type, in {shuffle, feature, trojan_sq, poison_frogs}',
)
parser.add_argument(
'--cache_l2l',
action='store_true',
default=False,
help='whether cache label-2-label distances.',
)
parser.add_argument(
'--hot_batch_size',
type=int,
default=1024,
help='hierarchical ot batch size.',
)
parser.add_argument(
'--corrupt_por',
type=float,
default=0.0,
help='fraction of corrupted data.',
)
parser.add_argument(
'--prune_perc',
type=float,
default=0.1,
help='fraction of data remove from the dataset.',
)
parser.add_argument(
'--smoketest',
action='store_true',
default=False,
help='whether to run a tesr run.',
)
parser.add_argument(
'--resume',
action='store_true',
default=False,
help='whether resume the non stationary loop',
)
parser.add_argument(
'--resume_inds_path',
type=str,
default='output/indices/',
help='path to the resume inds',
)
parser.add_argument(
'--resume_checkpoint_path',
type=str,
default='output/checkpoint/',
help='path to the resume inds',
)
parser.add_argument(
'--resume_epoch',
type=int,
default=50,
help='epoch to resume, needs corresponding model checkpoint.',
)
parser.add_argument(
'--knn_sv',
action='store_true',
default=False,
help='whether to run knn sv valuation and pruning.',
)
parser.add_argument(
'--k',
type=int,
default=10,
)
parser.add_argument(
'--output_repr',
action='store_true',
default=False,
help='whether to use the feature space or the output repr.',
)
parser.add_argument(
'--val_dataset_size',
type=int,
default=10000,
help='val set size.',
)
args = parser.parse_known_args(args=args)[0]
return args
def parse_args_clothing1m(args=None):
parser = argparse.ArgumentParser(description='PyTorch Clothing1M')
parser.add_argument(
'--seed',
type=int,
default=2021,
)
parser.add_argument(
'--cuda_num',
type=int,
help='number of cuda in the server',
)
parser.add_argument(
'--n_gpu',
type=int,
default=2,
help='number of gpu to use',
)
parser.add_argument(
'--root',
type=str,
default='data/clothing1M/',
help='root of dataset',
)
parser.add_argument(
'--value_batch_size',
type=int,
default=1024,
help='hierarchical ot / EL2N batch size.',
)
parser.add_argument(
'--train_batch_size',
type=int,
default=256,
help='training batch size.',
)
parser.add_argument(
'--tag',
type=str,
default='',
help='unique tag',
)
parser.add_argument(
'--disable_wandb',
action='store_true',
default=False,
help='whether to disable wandb logging - useful for smoketest.',
)
parser.add_argument(
'--smoketest',
action='store_true',
default=False,
help='whether to run the scrtip in smoketest mode.',
)
parser.add_argument(
'--hot',
action='store_true',
default=False,
help='whether to run the scrtip with hot/sava data valuation or random pruning.',
)
parser.add_argument(
'--el2n',
action='store_true',
default=False,
help='whether to run the scrtip with e2ln data valuation.',
)
parser.add_argument(
'--el2n_value_model_seed',
type=int,
default=10,
help='init seed of the el2n model, which are used for valuation.',
)
parser.add_argument(
'--el2n_value_num_models',
type=int,
default=10,
help='num el2n models to do mc expectation over weights.',
)
parser.add_argument(
'--prune_percs',
nargs="+",
type=float,
required=False,
default = [0.0, 0.1, 0.2, 0.3, 0.4],
help='pruning percentages to loop over.',
)
parser.add_argument(
'--preact_resnet',
action='store_true',
default=False,
help='Train a preact resnet instead of normal resnet.',
)
parser.add_argument(
'--wd',
type=float,
default=5e-4,
help='weight decay coef.',
)
parser.add_argument(
'--prune_interval',
type=str,
default='right',
help='For EL2N, defines the pruning interval of the vlaues.',
)
parser.add_argument(
'--values_tag',
type=str,
default='',
help='Filename SAVA/EL2N/SLP values.',
)
parser.add_argument(
'--slp',
action='store_true',
default=False,
help='whether to run the scrtip with supervised prototypes value pruning.',
)
parser.add_argument(
'--batch_lava',
action='store_true',
default=False,
help='whether to run the scrtip with batch-wise LAVA value pruning.',
)
args = parser.parse_known_args(args=args)[0]
return args