Skip to content

Commit 38385b0

Browse files
tfboydTaylor Robie
authored and
Taylor Robie
committed
Update lr and default number epochs for CIFAR 10 (tensorflow#5243)
1 parent f505cec commit 38385b0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

official/resnet/cifar10_main.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
_NUM_CLASSES = 10
3939
_NUM_DATA_FILES = 5
4040

41+
# TODO(tobyboyd): Change to best practice 45K(train)/5K(val)/10K(test) splits.
4142
_NUM_IMAGES = {
4243
'train': 50000,
4344
'validation': 10000,
@@ -193,14 +194,14 @@ def __init__(self, resnet_size, data_format=None, num_classes=_NUM_CLASSES,
193194
def cifar10_model_fn(features, labels, mode, params):
194195
"""Model function for CIFAR-10."""
195196
features = tf.reshape(features, [-1, _HEIGHT, _WIDTH, _NUM_CHANNELS])
196-
197+
# Learning rate schedule follows arXiv:1512.03385 for ResNet-56 and under.
197198
learning_rate_fn = resnet_run_loop.learning_rate_with_decay(
198199
batch_size=params['batch_size'], batch_denom=128,
199-
num_images=_NUM_IMAGES['train'], boundary_epochs=[100, 150, 200],
200+
num_images=_NUM_IMAGES['train'], boundary_epochs=[91, 136, 182],
200201
decay_rates=[1, 0.1, 0.01, 0.001])
201202

202-
# We use a weight decay of 0.0002, which performs better
203-
# than the 0.0001 that was originally suggested.
203+
# Weight decay of 2e-4 diverges from 1e-4 decay used in the ResNet paper
204+
# and seems more stable in testing. The difference was nominal for ResNet-56.
204205
weight_decay = 2e-4
205206

206207
# Empirical testing showed that including batch_normalization variables
@@ -234,8 +235,8 @@ def define_cifar_flags():
234235
flags.adopt_module_key_flags(resnet_run_loop)
235236
flags_core.set_defaults(data_dir='/tmp/cifar10_data',
236237
model_dir='/tmp/cifar10_model',
237-
resnet_size='32',
238-
train_epochs=250,
238+
resnet_size='56',
239+
train_epochs=182,
239240
epochs_between_evals=10,
240241
batch_size=128)
241242

0 commit comments

Comments
 (0)