-
Notifications
You must be signed in to change notification settings - Fork 3
/
hpsearch_config_resnet_avb_pf.py
274 lines (245 loc) · 10 KB
/
hpsearch_config_resnet_avb_pf.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
#!/usr/bin/env python3
# Copyright 2019 Christian Henning
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# title :probabilistic/prob_cifar/hpsearch_config_zenke_avb_pf.py
# author :ch
# contact :[email protected]
# created :02/03/2020
# version :1.0
# python_version :3.6.8
"""
Hyperparameter-search configuration for CIFAR-Zenke using Prior-Focused AVB
---------------------------------------------------------------------------
A configuration file for our custom hyperparameter search script. This
configuration is meant for hyperparameter searches of the simulation defined by
:mod:`probabilistic.prob_cifar.train_zenke_avb_pf`.
Note, the experiment has been originally proposed in
Zenke et al., "Continual Learning Through Synaptic Intelligence", 2017,
https://arxiv.org/abs/1703.04200
"""
from probabilistic.prob_mnist import hpsearch_config_split_bbb as hpsplitbbb
from probabilistic.prob_mnist import hpsearch_config_split_avb as hpsplitavb
from probabilistic.prob_mnist import hpsearch_config_split_avb_pf as \
hpsplitavbpf
##########################################
### Please define all parameters below ###
##########################################
# Define a dictionary with parameter names as keys and a list of values for
# each parameter. For flag arguments, simply use the values [True, False].
# Note, the output directory is set by the hyperparameter search script.
#
# Example: {'option1': [12, 24], 'option2': [0.1, 0.5],
# 'option3': [True]}
# This disctionary would correspond to the following 4 configurations:
# python3 SCRIPT_NAME.py --option1=12 --option2=0.1 --option3
# python3 SCRIPT_NAME.py --option1=12 --option2=0.5 --option3
# python3 SCRIPT_NAME.py --option1=24 --option2=0.1 --option3
# python3 SCRIPT_NAME.py --option1=24 --option2=0.5 --option3
#
# If fields are commented out (missing), the default value is used.
# Note, that you can specify special conditions below.
grid = {
### Continual learning options ###
#'train_from_scratch' : [False],
'cl_scenario' : [1], # 1, 2 or 3
#'split_head_cl3' : [False],
#'num_tasks' : [6],
#'num_classes_per_task': [10],
#'skip_tasks': [0],
### Training options ###
#'batch_size' : [256],
#'n_iter' : [2000],
#'epochs' : [80],
#'lr' : [0.0001],
#'momentum' : [0.],
#'weight_decay' : [0],
'use_adam' : [True],
#'adam_beta1' : [0.9],
#'use_rmsprop' : [False],
#'use_adadelta' : [False],
#'use_adagrad' : [False],
#'clip_grad_value' : [-1],
#'clip_grad_norm' : [-1],
#'plateau_lr_scheduler': [False],
#'lambda_lr_scheduler': [False],
#'train_sample_size' : [1],
#'prior_variance' : [1.],
#'kl_scale' : [1.],
#'kl_schedule': [0],
#'num_kl_samples': [1],
#'training_set_size': [-1],
#'coreset_size': [-1],
#'per_task_coreset': [False],
#'coreset_reg': [1.],
#'coreset_batch_size': [-1],
#'past_and_future_coresets': [False],
### Main network options ###
#'net_type': ['resnet'], # 'resnet', 'wrn', 'iresnet', 'lenet', 'zenke',
# 'mlp'
#'mlp_arch': ['"400,400"'],
#'lenet_type' : ['cifar'],
#'resnet_block_depth': [5],
#'resnet_channel_sizes': ['"16,16,32,64"'],
#'wrn_block_depth': [4],
#'wrn_widening_factor': [10],
#'wrn_use_fc_bias': [False],
#'iresnet_use_fc_bias': [False],
#'iresnet_channel_sizes': ['"64,64,128,256,512"'],
#'iresnet_blocks_per_group': ['"2,2,2,2"'],
#'iresnet_bottleneck_blocks': [False],
#'iresnet_projection_shortcut': [False],
#'no_bias' : [False],
#'dropout_rate' : [-1],
#'no_batchnorm': [False],
#'bn_no_running_stats': [False],
#'bn_no_stats_checkpointing': [False],
### Discriminator options ###
#'dis_net_type' : ['mlp'],
#'dis_mlp_arch' : ['"100,100"'],
#'dis_cmlp_arch' : ['"10,10"'],
#'dis_cmlp_chunk_arch' : ['"10,10"'],
#'dis_cmlp_in_cdim' : [100],
#'dis_cmlp_out_cdim' : [10],
#'dis_cmlp_cemb_dim' : [8],
#'dis_net_act' : ['relu'],
#'dis_dropout_rate' : [-1],
#'dis_batchnorm' : [False],
#'dis_specnorm' : [False],
#'dis_no_bias' : [False],
### Implicit-hypernet options ###
'imp_hnet_type' : ['hmlp'], # 'hmlp', 'chunked_hmlp', 'structured_hmlp',
# 'hdeconv', 'chunked_hdeconv'
#'imp_hmlp_arch' : ['"125,250,500"'],
#'imp_chmlp_chunk_size' : [1500],
#'imp_chunk_emb_size' : ['"32"'],
#'imp_hdeconv_shape' : ['"512,512,3"'],
#'imp_hdeconv_num_layers' : [5],
#'imp_hdeconv_filters' : ['"128,512,256,128"'],
#'imp_hdeconv_kernels': ['"5"'],
#'imp_hdeconv_attention_layers': ['"1,3"'],
#'imp_hnet_net_act': ['sigmoid'],
#'imp_hnet_no_bias': [False],
#'imp_hnet_dropout_rate': [-1],
#'imp_hnet_specnorm': [False],
### Network initialization options ###
#'normal_init' : [False],
#'std_normal_init' : [0.02],
#'std_normal_temb' : [1.],
#'std_normal_emb' : [1.],
#'hyper_fan_init' : [False],
### Data-specific options ###
'disable_data_augmentation' : [True], # RELATED WORK - True
### Evaluation options ###
#'val_iter' : [500],
#'val_batch_size' : [1000],
#'val_set_size' : [0],
#'full_test_interval' : [-1],
#'val_sample_size' : [100],
### Miscellaneous options ###
#'no_cuda' : [False],
#'deterministic_run': [True],
#'random_seed': [42],
#'mnet_only': [False],
#'store_final_model': [False],
#'during_acc_criterion': ['"-1"'],
#'no_hhnet': [False],
#'no_dis': [False],
### Implicit Distribution options ###
#'latent_dim' : [8],
#'latent_std' : [1.],
'full_support_perturbation' : [-1],
### AVB options ###
#'dis_lr' : [-1.],
#'dis_batch_size' : [1],
#'num_dis_steps' : [1],
#'no_dis_reinit' : [False],
#'use_batchstats' : [False],
#'no_adaptive_contrast' : [False],
#'num_ac_samples' : [100],
### Probabilistic CL Options ###
#'calibrate_temp': [False],
#'cal_temp_iter': [1000],
#'cal_sample_size': [-1],
}
# Sometimes, not the whole grid should be searched. For instance, if an SGD
# optimizer has been chosen, then it doesn't make sense to search over multiple
# beta2 values of an Adam optimizer.
# Therefore, one can specify special conditions.
# NOTE, all conditions that are specified here will be enforced. Thus, they
# overwrite the grid options above.
#
# How to specify a condition? A condition is a key value tuple: whereas as the
# key as well as the value is a dictionary in the same format as in the grid
# above. If any configurations matches the values specified in the key dict,
# The values specified in the values dict will be searched instead.
#
# Note, if arguments are commented out above but appear in the conditions, the
# condition will be ignored.
conditions = [
# Note, we specify a particular set of base conditions below that should
# always be enforces: "_BASE_CONDITIONS".
### Add your conditions here ###
#({'clip_grad_value': [1.]}, {'clip_grad_norm': [-1]}),
#({'clip_grad_norm': [1.]}, {'clip_grad_value': [-1]}),
]
####################################
### DO NOT CHANGE THE CODE BELOW ###
####################################
conditions = conditions + hpsplitbbb._BASE_CONDITIONS + \
hpsplitavb._AVB_CONDITIONS
# Name of the script that should be executed by the hyperparameter search.
# Note, the working directory is set seperately by the hyperparameter search
# script.
_SCRIPT_NAME = 'train_resnet_avb_pf.py'
# This file is expected to reside in the output folder of the simulation.
_SUMMARY_FILENAME = hpsplitavb._SUMMARY_FILENAME
# These are the keywords that are supposed to be in the summary file.
# A summary file always has to include the keyword "finished"!.
_SUMMARY_KEYWORDS = hpsplitavbpf._SUMMARY_KEYWORDS
# The name of the command-line argument that determines the output folder
# of the simulation.
_OUT_ARG = 'out_dir'
# In case you need a more elaborate parser than the default one define by the
# function :func:`hpsearch.hpsearch._get_performance_summary`, you can pass a
# function handle to this attribute.
# Value `None` results in the usage of the default parser.
_SUMMARY_PARSER_HANDLE = None # Default parser is used.
#_SUMMARY_PARSER_HANDLE = _get_performance_summary # Custom parser is used.
# A function handle, that is used to evaluate the performance of a run.
_PERFORMANCE_EVAL_HANDLE = hpsplitbbb._PERFORMANCE_EVAL_HANDLE
# A key that must appear in the `_SUMMARY_KEYWORDS` list. If `None`, the first
# entry in this list will be selected.
# The CSV file will be sorted based on this keyword. See also attribute
# `_PERFORMANCE_SORT_ASC`.
_PERFORMANCE_KEY = 'acc_avg_final'
assert(_PERFORMANCE_KEY is None or _PERFORMANCE_KEY in _SUMMARY_KEYWORDS)
# Whether the CSV should be sorted ascending or descending based on the
# `_PERFORMANCE_KEY`.
_PERFORMANCE_SORT_ASC = False
# FIXME: This attribute will vanish in future releases.
# This attribute is only required by the `hpsearch_postprocessing` script.
# A function handle to the argument parser function used by the simulation
# script. The function handle should expect the list of command line options
# as only parameter.
# Example:
# >>> from probabilistic.prob_mnist import train_args as targs
# >>> f = lambda argv : targs.parse_cmd_arguments(mode='split_mnist_bbb',
# ... argv=argv)
# >>> _ARGPARSE_HANDLE = f
import probabilistic.prob_mnist.train_args as targs
_ARGPARSE_HANDLE = lambda argv : targs.parse_cmd_arguments( \
mode='cifar_resnet_avb_pf', argv=argv)
if __name__ == '__main__':
pass