-
Notifications
You must be signed in to change notification settings - Fork 1
/
defaults.py
213 lines (205 loc) · 14.7 KB
/
defaults.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
import argparse
def use_default(default_arg):
parser = argparse.ArgumentParser(description='PyTorch DAJAT Adversarial Training')
if default_arg == "CIFAR10_RN18":
parser.add_argument('--arch', type=str, default='ResNet18')
parser.add_argument('--batch-size', type=int, default=128, metavar='N',
help='input batch size for training (default: 128)')
parser.add_argument('--test-batch-size', type=int, default=128, metavar='N',
help='input batch size for testing (default: 128)')
parser.add_argument('--epochs', type=int, default=200, metavar='N',
help='number of epochs to train')
parser.add_argument('--start_epoch', type=int, default=1, metavar='N',
help='retrain from which epoch')
parser.add_argument('--data', type=str, default='CIFAR10', choices=['CIFAR10', 'CIFAR100'])
parser.add_argument('--data-path', type=str, default='./data',
help='where is the dataset CIFAR-10')
parser.add_argument('--weight-decay', '--wd', default=5e-4,
type=float, metavar='W')
parser.add_argument('--lr', type=float, default=0.2, metavar='LR',
help='learning rate')
parser.add_argument('--momentum', type=float, default=0.9, metavar='M',
help='SGD momentum')
parser.add_argument('--no-cuda', action='store_true', default=False,
help='disables CUDA training')
parser.add_argument('--norm', default='l_inf', type=str, choices=['l_inf', 'l_2'],
help='The threat model')
parser.add_argument('--train_budget', default='high', type=str, choices=['low', 'high'],
help='The compute budget for training. High budget would mean larger number of atatck iterations')
parser.add_argument('--epsilon', default=8, type=float,
help='perturbation')
parser.add_argument('--beta', default=11.0, type=float,
help='regularization, i.e., 1/lambda in TRADES')
parser.add_argument('--seed', type=int, default=1, metavar='S',
help='random seed (default: 1)')
parser.add_argument('--LS', type=int, default=0, metavar='S',
help='make 1 is want to use Label Smoothing. DAJAT uses LS only for CIFAR100 dataset')
parser.add_argument('--model-dir', default='./model-cifar-ResNet',
help='directory of model for saving checkpoint')
parser.add_argument('--resume-model', default='', type=str,
help='directory of model for retraining')
parser.add_argument('--resume-optim', default='', type=str,
help='directory of optimizer for retraining')
parser.add_argument('--save-freq', '-s', default=1, type=int, metavar='N',
help='save frequency')
parser.add_argument('--num_auto', default=2, type=int, metavar='N',
help='Number of autoaugments to use for training')
parser.add_argument('--JS_weight', default=2, type=int, metavar='N',
help='The weight of the JS divergence term')
parser.add_argument('--awp-gamma', default=0.005, type=float,
help='whether or not to add parametric noise')
parser.add_argument('--awp-warmup', default=10, type=int,
help='We could apply AWP after some epochs for accelerating.')
elif default_arg == "CIFAR10_WRN":
parser.add_argument('--arch', type=str, default='WideResNet34')
parser.add_argument('--batch-size', type=int, default=128, metavar='N',
help='input batch size for training (default: 128)')
parser.add_argument('--test-batch-size', type=int, default=128, metavar='N',
help='input batch size for testing (default: 128)')
parser.add_argument('--epochs', type=int, default=200, metavar='N',
help='number of epochs to train')
parser.add_argument('--start_epoch', type=int, default=1, metavar='N',
help='retrain from which epoch')
parser.add_argument('--data', type=str, default='CIFAR10', choices=['CIFAR10', 'CIFAR100'])
parser.add_argument('--data-path', type=str, default='./data',
help='where is the dataset CIFAR-10')
parser.add_argument('--weight-decay', '--wd', default=5e-4,
type=float, metavar='W')
parser.add_argument('--lr', type=float, default=0.2, metavar='LR',
help='learning rate')
parser.add_argument('--momentum', type=float, default=0.9, metavar='M',
help='SGD momentum')
parser.add_argument('--no-cuda', action='store_true', default=False,
help='disables CUDA training')
parser.add_argument('--norm', default='l_inf', type=str, choices=['l_inf', 'l_2'],
help='The threat model')
parser.add_argument('--train_budget', default='high', type=str, choices=['low', 'high'],
help='The compute budget for training. High budget would mean larger number of atatck iterations')
parser.add_argument('--epsilon', default=8, type=float,
help='perturbation')
parser.add_argument('--beta', default=10.0, type=float,
help='regularization, i.e., 1/lambda in TRADES')
parser.add_argument('--seed', type=int, default=1, metavar='S',
help='random seed (default: 1)')
parser.add_argument('--LS', type=int, default=0, metavar='S',
help='make 1 is want to use Label Smoothing. DAJAT uses LS only for CIFAR100 dataset')
parser.add_argument('--model-dir', default='./model-cifar-ResNet',
help='directory of model for saving checkpoint')
parser.add_argument('--resume-model', default='', type=str,
help='directory of model for retraining')
parser.add_argument('--resume-optim', default='', type=str,
help='directory of optimizer for retraining')
parser.add_argument('--save-freq', '-s', default=1, type=int, metavar='N',
help='save frequency')
parser.add_argument('--num_auto', default=2, type=int, metavar='N',
help='Number of autoaugments to use for training')
parser.add_argument('--JS_weight', default=3, type=int, metavar='N',
help='The weight of the JS divergence term')
parser.add_argument('--awp-gamma', default=0.005, type=float,
help='whether or not to add parametric noise')
parser.add_argument('--awp-warmup', default=10, type=int,
help='We could apply AWP after some epochs for accelerating.')
elif default_arg == "CIFAR100_WRN":
parser.add_argument('--arch', type=str, default='WideResNet34')
parser.add_argument('--batch-size', type=int, default=128, metavar='N',
help='input batch size for training (default: 128)')
parser.add_argument('--test-batch-size', type=int, default=128, metavar='N',
help='input batch size for testing (default: 128)')
parser.add_argument('--epochs', type=int, default=200, metavar='N',
help='number of epochs to train')
parser.add_argument('--start_epoch', type=int, default=1, metavar='N',
help='retrain from which epoch')
parser.add_argument('--data', type=str, default='CIFAR100', choices=['CIFAR10', 'CIFAR100'])
parser.add_argument('--data-path', type=str, default='./data',
help='where is the dataset CIFAR-10')
parser.add_argument('--weight-decay', '--wd', default=5e-4,
type=float, metavar='W')
parser.add_argument('--lr', type=float, default=0.2, metavar='LR',
help='learning rate')
parser.add_argument('--momentum', type=float, default=0.9, metavar='M',
help='SGD momentum')
parser.add_argument('--no-cuda', action='store_true', default=False,
help='disables CUDA training')
parser.add_argument('--norm', default='l_inf', type=str, choices=['l_inf', 'l_2'],
help='The threat model')
parser.add_argument('--train_budget', default='high', type=str, choices=['low', 'high'],
help='The compute budget for training. High budget would mean larger number of atatck iterations')
parser.add_argument('--epsilon', default=8, type=float,
help='perturbation')
parser.add_argument('--beta', default=9.0, type=float,
help='regularization, i.e., 1/lambda in TRADES')
parser.add_argument('--seed', type=int, default=1, metavar='S',
help='random seed (default: 1)')
parser.add_argument('--LS', type=int, default=1, metavar='S',
help='make 1 is want to use Label Smoothing. DAJAT uses LS only for CIFAR100 dataset')
parser.add_argument('--model-dir', default='./model-cifar-ResNet',
help='directory of model for saving checkpoint')
parser.add_argument('--resume-model', default='', type=str,
help='directory of model for retraining')
parser.add_argument('--resume-optim', default='', type=str,
help='directory of optimizer for retraining')
parser.add_argument('--save-freq', '-s', default=1, type=int, metavar='N',
help='save frequency')
parser.add_argument('--num_auto', default=2, type=int, metavar='N',
help='Number of autoaugments to use for training')
parser.add_argument('--JS_weight', default=2, type=int, metavar='N',
help='The weight of the JS divergence term')
parser.add_argument('--awp-gamma', default=0.005, type=float,
help='whether or not to add parametric noise')
parser.add_argument('--awp-warmup', default=10, type=int,
help='We could apply AWP after some epochs for accelerating.')
elif default_arg == "CIFAR100_RN18":
parser.add_argument('--arch', type=str, default='ResNet18')
parser.add_argument('--batch-size', type=int, default=128, metavar='N',
help='input batch size for training (default: 128)')
parser.add_argument('--test-batch-size', type=int, default=128, metavar='N',
help='input batch size for testing (default: 128)')
parser.add_argument('--epochs', type=int, default=200, metavar='N',
help='number of epochs to train')
parser.add_argument('--start_epoch', type=int, default=1, metavar='N',
help='retrain from which epoch')
parser.add_argument('--data', type=str, default='CIFAR100', choices=['CIFAR10', 'CIFAR100'])
parser.add_argument('--data-path', type=str, default='./data',
help='where is the dataset CIFAR-10')
parser.add_argument('--weight-decay', '--wd', default=5e-4,
type=float, metavar='W')
parser.add_argument('--lr', type=float, default=0.2, metavar='LR',
help='learning rate')
parser.add_argument('--momentum', type=float, default=0.9, metavar='M',
help='SGD momentum')
parser.add_argument('--no-cuda', action='store_true', default=False,
help='disables CUDA training')
parser.add_argument('--norm', default='l_inf', type=str, choices=['l_inf', 'l_2'],
help='The threat model')
parser.add_argument('--train_budget', default='high', type=str, choices=['low', 'high'],
help='The compute budget for training. High budget would mean larger number of atatck iterations')
parser.add_argument('--epsilon', default=8, type=float,
help='perturbation')
parser.add_argument('--beta', default=9.0, type=float,
help='regularization, i.e., 1/lambda in TRADES')
parser.add_argument('--seed', type=int, default=1, metavar='S',
help='random seed (default: 1)')
parser.add_argument('--LS', type=int, default=1, metavar='S',
help='make 1 is want to use Label Smoothing. DAJAT uses LS only for CIFAR100 dataset')
parser.add_argument('--model-dir', default='./model-cifar-ResNet',
help='directory of model for saving checkpoint')
parser.add_argument('--resume-model', default='', type=str,
help='directory of model for retraining')
parser.add_argument('--resume-optim', default='', type=str,
help='directory of optimizer for retraining')
parser.add_argument('--save-freq', '-s', default=1, type=int, metavar='N',
help='save frequency')
parser.add_argument('--num_auto', default=2, type=int, metavar='N',
help='Number of autoaugments to use for training')
parser.add_argument('--JS_weight', default=2, type=int, metavar='N',
help='The weight of the JS divergence term')
parser.add_argument('--awp-gamma', default=0.005, type=float,
help='whether or not to add parametric noise')
parser.add_argument('--awp-warmup', default=10, type=int,
help='We could apply AWP after some epochs for accelerating.')
else:
print("Use_default not Found")
exit
parser.add_argument('--use_defaults', type=str, default='CIFAR10_RN18' ,choices=['NONE','CIFAR10_RN18', 'CIFAR10_WRN','CIFAR100_WRN', 'CIFAR100_RN18'],help='Use None is want to use the hyperparamters passed in the python training command else use the desired set of default hyperparameters')
args = parser.parse_args()
return args