-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhyperparameters.py
498 lines (401 loc) · 23.4 KB
/
hyperparameters.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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
"""Parameters used for the experiments of the paper."""
import tensorflow as tf
import numpy as np
from deepsphere import utils
def get_params(ntrain, EXP_NAME, order, Nside, architecture="FCN", verbose=True):
"""Parameters for the cgcnn and cnn2d defined in deepsphere/models.py"""
n_classes = 2
params = dict()
params['dir_name'] = EXP_NAME
# Types of layers.
params['conv'] = 'chebyshev5' # Graph convolution: chebyshev5 or monomials.
params['pool'] = 'max' # Pooling: max or average.
params['activation'] = 'relu' # Non-linearity: relu, elu, leaky_relu, softmax, tanh, etc.
params['statistics'] = 'mean' # Statistics (for invariance): None, mean, var, meanvar, hist.
# Architecture.
params['F'] = [16, 32, 64, 64, 64, n_classes] # Graph convolutional layers: number of feature maps.
params['K'] = [5] * 6 # Polynomial orders.
params['batch_norm'] = [True] * 6 # Batch normalization.
params['M'] = [] # Fully connected layers: output dimensionalities.
# Pooling.
nsides = [Nside, Nside//2, Nside//4, Nside//8, Nside//16, Nside//32, Nside//32]
params['nsides'] = nsides
params['indexes'] = utils.nside2indexes(nsides, order)
# params['batch_norm_full'] = []
if architecture == "CNN":
# Classical convolutional neural network.
# Replace the last graph convolution and global average pooling by a fully connected layer.
# That is, change the classifier while keeping the feature extractor.
params['F'] = params['F'][:-1]
params['K'] = params['K'][:-1]
params['batch_norm'] = params['batch_norm'][:-1]
params['nsides'] = params['nsides'][:-1]
params['indexes'] = params['indexes'][:-1]
params['statistics'] = None
params['M'] = [n_classes]
elif architecture == "FCN":
pass
else:
raise ValueError('Unknown architecture {}.'.format(architecture))
# Regularization (to prevent over-fitting).
params['regularization'] = 0 # Amount of L2 regularization over the weights (will be divided by the number of weights).
params['dropout'] = 1 # Percentage of neurons to keep.
# Training.
params['num_epochs'] = 80 # Number of passes through the training data.
params['batch_size'] = max(8 * order, 1) # Constant quantity of information (#pixels) per step (invariant to sample size).
# Optimization: learning rate schedule and optimizer.
params['scheduler'] = lambda step: tf.train.exponential_decay(2e-4, step, decay_steps=1, decay_rate=0.999)
params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=1e-8)
# Number of model evaluations during training (influence training time).
n_evaluations = 80
params['eval_frequency'] = int(params['num_epochs'] * ntrain / params['batch_size'] / n_evaluations)
if verbose:
print('#sides: {}'.format(nsides))
# print('#pixels: {}'.format([(nside//order)**2 for nside in nsides]))
# Number of pixels on the full sphere: 12 * nsides**2.
print('#samples per batch: {}'.format(params['batch_size']))
# print('=> #pixels per batch (input): {:,}'.format(params['batch_size']*(Nside//order)**2))
# print('=> #pixels for training (input): {:,}'.format(params['num_epochs']*ntrain*(Nside//order)**2))
n_steps = params['num_epochs'] * ntrain // params['batch_size']
lr = [params['scheduler'](step).eval(session=tf.Session()) for step in [0, n_steps]]
print('Learning rate will start at {:.1e} and finish at {:.1e}.'.format(*lr))
return params
def get_params_shrec17(ntrain, EXP_NAME, Nside, n_classes, nfeat_in=6, architecture="FCN", verbose=True):
"""
:param ntrain: int, number of elements in the training set
:param EXP_NAME: string, name of experiment
:param n_classes: int, number of classes present in SHREC17 dataset
:param Nside: int, parameter of HEALpix
:param architecture: string, type of NN
:param verbose: bool, print info
:return: parameters needed to create a deepsphere model
"""
params = dict()
params['dir_name'] = EXP_NAME
params['num_feat_in'] = nfeat_in
# Types of layers.
params['conv'] = 'chebyshev5' # Graph convolution: chebyshev5 or monomials.
params['pool'] = 'max' # Pooling: max or average.
params['activation'] = 'relu' # Non-linearity: relu, elu, leaky_relu, softmax, tanh, etc.
params['statistics'] = 'mean' # Statistics (for invariance): None, mean, var, meanvar, hist.
# Architecture.
params['F'] = [100, 100, n_classes]
params['K'] = [5] * 3 # Polynomial orders.
# params['K'] = [np.ceil(np.sqrt(3)*Nside).astype(int),
# np.ceil(np.sqrt(3)*Nside//4).astype(int),
# np.ceil(np.sqrt(3)*Nside//8).astype(int)]
params['batch_norm'] = [True] * 3 # Batch normalization.
params['M'] = [] # Fully connected layers: output dimensionalities.
# Pooling.
nsides = [Nside, Nside//4, Nside//8, Nside//8]
params['nsides'] = nsides
params['indexes'] = None
if architecture == "CNN":
# Replace the last graph convolution and global average pooling by a fully connected layer.
# That is, change the classifier while keeping the feature extractor.
params['F'] = params['F'][:-1]
params['K'] = params['K'][:-1]
params['nsides'] = params['nsides'][:-1]
params['batch_norm'] = params['batch_norm'][:-1]
params['statistics'] = 'mean'
params['M'] = [n_classes]
elif architecture != "FCN":
raise ValueError('Unknown architecture {}.'.format(architecture))
# Regularization (to prevent over-fitting).
params['regularization'] = 0 # Amount of L2 regularization over the weights (will be divided by the number of weights).
params['dropout'] = 1 # Percentage of neurons to keep.
# Training.
params['num_epochs'] = 100 # Number of passes through the training data.
params['batch_size'] = 32 # Constant quantity of information (#pixels) per step (invariant to sample size).
# Optimization: learning rate schedule and optimizer.
params['scheduler'] = lambda step: tf.train.exponential_decay(5e-1, step, decay_steps=5, decay_rate=1)#0.999)
#params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=1e-8)
params['optimizer'] = lambda lr: tf.train.GradientDescentOptimizer(lr)
# Number of model evaluations during training (influence training time).
n_evaluations = 200
params['eval_frequency'] = int(params['num_epochs'] * ntrain / params['batch_size'] / n_evaluations)
if verbose:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
print('#sides: {}'.format(nsides))
print('#pixels: {}'.format([12 * (nside)**2 for nside in nsides]))
# Number of pixels on the full sphere: 12 * nsides**2.
print('#samples per batch: {}'.format(params['batch_size']))
print('=> #pixels per batch (input): {:,}'.format(params['batch_size']*12*(Nside)**2))
print('=> #pixels for training (input): {:,}'.format(params['num_epochs']*ntrain*12*(Nside)**2))
n_steps = params['num_epochs'] * ntrain // params['batch_size']
lr = [params['scheduler'](step).eval(session=tf.Session(config=config)) for step in [0, n_steps]]
print('Learning rate will start at {:.1e} and finish at {:.1e}.'.format(*lr))
return params
def get_params_shrec17_optim(ntrain, EXP_NAME, Nside, n_classes, nfeat_in=6, architecture="FCN", verbose=True):
"""
:param ntrain: int, number of elements in the training set
:param EXP_NAME: string, name of experiment
:param n_classes: int, number of classes present in SHREC17 dataset
:param Nside: int, parameter of HEALpix
:param architecture: string, type of NN
:param verbose: bool, print info
:return: parameters needed to create a deepsphere model
"""
params = dict()
params['dir_name'] = EXP_NAME
params['num_feat_in'] = nfeat_in
# Types of layers.
params['conv'] = 'chebyshev5' # Graph convolution: chebyshev5 or monomials.
params['pool'] = 'max' # Pooling: max or average.
params['activation'] = 'relu' # Non-linearity: relu, elu, leaky_relu, softmax, tanh, etc.
params['statistics'] = 'mean' # Statistics (for invariance): None, mean, var, meanvar, hist.
# Architecture.
params['F'] = [16, 32, 64, 128, 256, n_classes] # Graph convolutional layers: number of feature maps.
params['K'] = [4] * 6 # Polynomial orders.
# params['K'] = [np.ceil(np.sqrt(3)*Nside).astype(int),
# np.ceil(np.sqrt(3)*Nside//4).astype(int),
# np.ceil(np.sqrt(3)*Nside//8).astype(int)]
params['batch_norm'] = [True] * 6 # Batch normalization.
params['M'] = [] # Fully connected layers: output dimensionalities.
# Pooling.
nsides = [Nside, Nside//2, Nside//4, Nside//8, Nside//16, Nside//32, Nside//32]
params['nsides'] = nsides
params['indexes'] = None
if architecture == "CNN":
# Replace the last graph convolution and global average pooling by a fully connected layer.
# That is, change the classifier while keeping the feature extractor.
params['F'] = params['F'][:-1]
params['K'] = params['K'][:-1]
params['nsides'] = params['nsides'][:-1]
params['batch_norm'] = params['batch_norm'][:-1]
params['statistics'] = 'mean'
params['M'] = [n_classes]
elif architecture != "FCN":
raise ValueError('Unknown architecture {}.'.format(architecture))
# Regularization (to prevent over-fitting).
params['regularization'] = 0 # Amount of L2 regularization over the weights (will be divided by the number of weights).
params['dropout'] = 1 # Percentage of neurons to keep.
params['dropFilt'] = 1 # percentage of filter to keep in each layer
# Training.
params['num_epochs'] = 30 #30 # Number of passes through the training data.
params['batch_size'] = 32 # Constant quantity of information (#pixels) per step (invariant to sample size).
# Optimization: learning rate schedule and optimizer.
params['scheduler'] = lambda step: tf.train.exponential_decay(5e-2, step, decay_steps=5, decay_rate=1)#decay_steps=7000, decay_rate=0.1, staircase=True)#0.999)
params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=0.1)
#params['optimizer'] = lambda lr: tf.train.GradientDescentOptimizer(lr)
#params['optimizer'] = lambda lr: tf.train.RMSPropOptimizer(lr, decay=0.9, momentum=0.)
# Number of model evaluations during training (influence training time).
n_evaluations = 60
params['eval_frequency'] = int(params['num_epochs'] * ntrain / params['batch_size'] / n_evaluations)
if verbose:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
print('#sides: {}'.format(nsides))
print('#pixels: {}'.format([12 * (nside)**2 for nside in nsides]))
# Number of pixels on the full sphere: 12 * nsides**2.
print('#samples per batch: {}'.format(params['batch_size']))
print('=> #pixels per batch (input): {:,}'.format(params['batch_size']*12*(Nside)**2))
print('=> #pixels for training (input): {:,}'.format(params['num_epochs']*ntrain*12*(Nside)**2))
n_steps = params['num_epochs'] * ntrain // params['batch_size']
lr = [params['scheduler'](step).eval(session=tf.Session(config=config)) for step in [0, n_steps]]
print('Learning rate will start at {:.1e} and finish at {:.1e}.'.format(*lr))
return params
def get_params_shrec17_equiangular(ntrain, EXP_NAME, n_classes, nfeat_in=6, architecture="FCN", verbose=True):
"""
:param ntrain: int, number of elements in the training set
:param EXP_NAME: string, name of experiment
:param n_classes: int, number of classes present in SHREC17 dataset
:param Nside: int, parameter of HEALpix
:param architecture: string, type of NN
:param verbose: bool, print info
:return: parameters needed to create a deepsphere model
"""
params = dict()
params['dir_name'] = EXP_NAME
params['num_feat_in'] = nfeat_in
params['sampling'] = 'equiangular'
# Types of layers.
params['conv'] = 'chebyshev5' # Graph convolution: chebyshev5 or monomials.
params['pool'] = 'max' # Pooling: max or average.
params['activation'] = 'relu' # Non-linearity: relu, elu, leaky_relu, softmax, tanh, etc.
params['statistics'] = 'mean' # Statistics (for invariance): None, mean, var, meanvar, hist.
# Architecture.
params['F'] = [16, 32, 64, 128, 256, n_classes] # Graph convolutional layers: number of feature maps.
params['K'] = [4] * 6 # Polynomial orders.
params['batch_norm'] = [True] * 6 # Batch normalization.
params['M'] = [] # Fully connected layers: output dimensionalities.
# Pooling.
bandwidth = [64, 32, 16, 8, 4, 2, 2]
params['nsides'] = bandwidth
params['indexes'] = None
if architecture == "CNN":
# Replace the last graph convolution and global average pooling by a fully connected layer.
# That is, change the classifier while keeping the feature extractor.
params['F'] = params['F'][:-1]
params['K'] = params['K'][:-1]
params['nsides'] = params['nsides'][:-1]
params['batch_norm'] = params['batch_norm'][:-1]
params['statistics'] = 'mean'
params['M'] = [n_classes]
elif architecture != "FCN":
raise ValueError('Unknown architecture {}.'.format(architecture))
# Regularization (to prevent over-fitting).
params['regularization'] = 0#1e-4 # Amount of L2 regularization over the weights (will be divided by the number of weights).
params['dropout'] = 1 # Percentage of neurons to keep.
params['dropFilt'] = 1 # percentage of filter to keep in each layer
# Training.
params['num_epochs'] = 30 # Number of passes through the training data.
params['batch_size'] = 32 # Constant quantity of information (#pixels) per step (invariant to sample size).
# Optimization: learning rate schedule and optimizer.
params['scheduler'] = lambda step: tf.train.exponential_decay(5e-1, step, decay_steps=5, decay_rate=1)#0.999)
#params['scheduler'] = lambda step: tf.train.exponential_decay(5e-5, step, decay_steps=5, decay_rate=0.999)
#params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=1e-8)
params['optimizer'] = lambda lr: tf.train.GradientDescentOptimizer(lr)
# Number of model evaluations during training (influence training time).
n_evaluations = 40
params['eval_frequency'] = int(params['num_epochs'] * ntrain / params['batch_size'] / n_evaluations)
if verbose:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
print('bandwidth: {}'.format(bandwidth[0]))
print('#pixels: {}'.format([4 * (bw)**2 for bw in bandwidth]))
print('#samples per batch: {}'.format(params['batch_size']))
print('=> #pixels per batch (input): {:,}'.format(params['batch_size']*4*(bandwidth[0])**2))
print('=> #pixels for training (input): {:,}'.format(params['num_epochs']*ntrain*4*(bandwidth[0])**2))
n_steps = params['num_epochs'] * ntrain // params['batch_size']
lr = [params['scheduler'](step).eval(session=tf.Session(config=config)) for step in [0, n_steps]]
print('Learning rate will start at {:.1e} and finish at {:.1e}.'.format(*lr))
return params
def get_params_mn40_optim(ntrain, EXP_NAME, Nside, n_classes, nfeat_in=6, architecture="FCN", verbose=True):
"""
:param ntrain: int, number of elements in the training set
:param EXP_NAME: string, name of experiment
:param n_classes: int, number of classes present in SHREC17 dataset
:param Nside: int, parameter of HEALpix
:param architecture: string, type of NN
:param verbose: bool, print info
:return: parameters needed to create a deepsphere model
"""
params = dict()
params['dir_name'] = EXP_NAME
params['num_feat_in'] = nfeat_in
# Types of layers.
params['conv'] = 'chebyshev5' # Graph convolution: chebyshev5 or monomials.
params['pool'] = 'max' # Pooling: max or average.
params['activation'] = 'relu' # Non-linearity: relu, elu, leaky_relu, softmax, tanh, etc.
params['statistics'] = 'mean' # Statistics (for invariance): None, mean, var, meanvar, hist.
# Architecture.
params['F'] = [16, 32, 64, 128, 256, 512, 1024, 2048, 2048, n_classes] # Graph convolutional layers: number of feature maps.
params['K'] = [4] * 10 # Polynomial orders.
# params['K'] = [np.ceil(np.sqrt(3)*Nside).astype(int),
# np.ceil(np.sqrt(3)*Nside//4).astype(int),
# np.ceil(np.sqrt(3)*Nside//8).astype(int)]
params['batch_norm'] = [True] * 10 # Batch normalization.
params['M'] = [] # Fully connected layers: output dimensionalities.
# Pooling.
nsides = [Nside, Nside//2, Nside//4, Nside//4, Nside//8, Nside//8,
Nside//16, Nside//16, Nside//32, Nside//32, Nside//32]
params['nsides'] = nsides
params['indexes'] = None
if architecture == "CNN":
# Replace the last graph convolution and global average pooling by a fully connected layer.
# That is, change the classifier while keeping the feature extractor.
params['F'] = params['F'][:-1]
params['K'] = params['K'][:-1]
params['nsides'] = params['nsides'][:-1]
params['batch_norm'] = params['batch_norm'][:-1]
params['statistics'] = 'mean'
params['M'] = [n_classes]
elif architecture != "FCN":
raise ValueError('Unknown architecture {}.'.format(architecture))
# Regularization (to prevent over-fitting).
params['regularization'] = 0 # Amount of L2 regularization over the weights (will be divided by the number of weights).
params['dropout'] = 1 # Percentage of neurons to keep.
params['dropFilt'] = 1 # percentage of filter to keep in each layer
# Training.
params['num_epochs'] = 50 #30 # Number of passes through the training data.
params['batch_size'] = 32 # Constant quantity of information (#pixels) per step (invariant to sample size).
# Optimization: learning rate schedule and optimizer.
params['scheduler'] = lambda step: tf.train.exponential_decay(2e-2, step, decay_steps=5, decay_rate=1)#decay_steps=7000, decay_rate=0.1, staircase=True)#0.999)
params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=0.1)
#params['optimizer'] = lambda lr: tf.train.GradientDescentOptimizer(lr)
# Number of model evaluations during training (influence training time).
n_evaluations = 200
params['eval_frequency'] = int(params['num_epochs'] * ntrain / params['batch_size'] / n_evaluations)
if verbose:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
print('#sides: {}'.format(nsides))
print('#pixels: {}'.format([12 * (nside)**2 for nside in nsides]))
# Number of pixels on the full sphere: 12 * nsides**2.
print('#samples per batch: {}'.format(params['batch_size']))
print('=> #pixels per batch (input): {:,}'.format(params['batch_size']*12*(Nside)**2))
print('=> #pixels for training (input): {:,}'.format(params['num_epochs']*ntrain*12*(Nside)**2))
n_steps = params['num_epochs'] * ntrain // params['batch_size']
lr = [params['scheduler'](step).eval(session=tf.Session(config=config)) for step in [0, n_steps]]
print('Learning rate will start at {:.1e} and finish at {:.1e}.'.format(*lr))
return params
def get_params_mn40(ntrain, EXP_NAME, Nside, n_classes, nfeat_in=6, architecture="FCN", verbose=True):
"""
:param ntrain: int, number of elements in the training set
:param EXP_NAME: string, name of experiment
:param n_classes: int, number of classes present in SHREC17 dataset
:param Nside: int, parameter of HEALpix
:param architecture: string, type of NN
:param verbose: bool, print info
:return: parameters needed to create a deepsphere model
"""
params = dict()
params['dir_name'] = EXP_NAME
params['num_feat_in'] = nfeat_in
# Types of layers.
params['conv'] = 'chebyshev5' # Graph convolution: chebyshev5 or monomials.
params['pool'] = 'max' # Pooling: max or average.
params['activation'] = 'relu' # Non-linearity: relu, elu, leaky_relu, softmax, tanh, etc.
params['statistics'] = 'mean' # Statistics (for invariance): None, mean, var, meanvar, hist.
# Architecture.
params['F'] = [16, 16, 32, 32, 64, 64, 128, 128, 256, 256, n_classes]
params['K'] = [4] * 11 # Polynomial orders.
# params['K'] = [np.ceil(np.sqrt(3)*Nside).astype(int),
# np.ceil(np.sqrt(3)*Nside//4).astype(int),
# np.ceil(np.sqrt(3)*Nside//8).astype(int)]
params['batch_norm'] = [True] * 11 # Batch normalization.
params['M'] = [] # Fully connected layers: output dimensionalities.
# Pooling.
nsides = [Nside, Nside, Nside//2, Nside//2, Nside//4, Nside//4, Nside//8, Nside//8, Nside//16, Nside//16, Nside//32, Nside//32]
params['nsides'] = nsides
params['indexes'] = None
if architecture == "CNN":
# Replace the last graph convolution and global average pooling by a fully connected layer.
# That is, change the classifier while keeping the feature extractor.
params['F'] = params['F'][:-1]
params['K'] = params['K'][:-1]
params['nsides'] = params['nsides'][:-1]
params['batch_norm'] = params['batch_norm'][:-1]
params['statistics'] = 'mean'
params['M'] = [n_classes]
elif architecture != "FCN":
raise ValueError('Unknown architecture {}.'.format(architecture))
# Regularization (to prevent over-fitting).
params['regularization'] = 0 # Amount of L2 regularization over the weights (will be divided by the number of weights).
params['dropout'] = 1 # Percentage of neurons to keep.
params['dropFilt'] = 1
# Training.
params['num_epochs'] = 30 # Number of passes through the training data.
params['batch_size'] = 32 # Constant quantity of information (#pixels) per step (invariant to sample size).
# Optimization: learning rate schedule and optimizer.
params['scheduler'] = lambda step: tf.train.exponential_decay(2e-2, step, decay_steps=5, decay_rate=1)#0.999)
#params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=1e-8)
params['optimizer'] = lambda lr: tf.train.AdamOptimizer(lr, beta1=0.9, beta2=0.999, epsilon=0.1)
# Number of model evaluations during training (influence training time).
n_evaluations = 60
params['eval_frequency'] = int(params['num_epochs'] * ntrain / params['batch_size'] / n_evaluations)
if verbose:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
print('#sides: {}'.format(nsides))
print('#pixels: {}'.format([12 * (nside)**2 for nside in nsides]))
# Number of pixels on the full sphere: 12 * nsides**2.
print('#samples per batch: {}'.format(params['batch_size']))
print('=> #pixels per batch (input): {:,}'.format(params['batch_size']*12*(Nside)**2))
print('=> #pixels for training (input): {:,}'.format(params['num_epochs']*ntrain*12*(Nside)**2))
n_steps = params['num_epochs'] * ntrain // params['batch_size']
lr = [params['scheduler'](step).eval(session=tf.Session(config=config)) for step in [0, n_steps]]
print('Learning rate will start at {:.1e} and finish at {:.1e}.'.format(*lr))
return params