Commit 4d543417 authored by Toby Boyd's avatar Toby Boyd Committed by GitHub
Browse files

Merge pull request #2090 from mari-linhares/patch-8

Adding parameter to change learning_rate
parents c3b69841 99cb3f70
......@@ -64,7 +64,7 @@ class Cifar10DataSet(object):
tf.float32)
label = tf.cast(features['label'], tf.int32)
# Custom preprocessing .
# Custom preprocessing.
image = self.preprocess(image)
return image, label
......
......@@ -73,23 +73,32 @@ tf.flags.DEFINE_float('momentum', 0.9, 'Momentum for MomentumOptimizer.')
tf.flags.DEFINE_float('weight_decay', 2e-4, 'Weight decay for convolutions.')
tf.flags.DEFINE_float('learning_rate', 0.1,
"""This is the inital learning rate value.
The learning rate will decrease during training.
For more details check the model_fn implementation
in this file.
""".)
tf.flags.DEFINE_boolean('use_distortion_for_training', True,
'If doing image distortion for training.')
tf.flags.DEFINE_boolean('run_experiment', False,
'If True will run an experiment,'
'otherwise will run training and evaluation'
'using the estimator interface.'
'Experiments perform training on several workers in'
'parallel, in other words experiments know how to'
' invoke train and eval in a sensible fashion for'
' distributed training.')
"""If True will run an experiment,
otherwise will run training and evaluation
using the estimator interface.
Experiments perform training on several workers in
parallel, in other words experiments know how to
invoke train and eval in a sensible fashion for
distributed training.
""")
tf.flags.DEFINE_boolean('sync', False,
'If true when running in a distributed environment'
'will run on sync mode')
"""If true when running in a distributed environment
will run on sync mode.
""")
tf.flags.DEFINE_integer('num_workers', 1, 'Number of workers')
tf.flags.DEFINE_integer('num_workers', 1, 'Number of workers.')
# Perf flags
tf.flags.DEFINE_integer('num_intra_threads', 1,
......@@ -233,7 +242,7 @@ def _resnet_model_fn(features, labels, mode):
Support single host, one or more GPU training. Parameter distribution can be
either one of the following scheme.
1. CPU is the parameter server and manages gradient updates.
2. Paramters are distributed evenly across all GPUs, and the first GPU
2. Parameters are distributed evenly across all GPUs, and the first GPU
manages gradient updates.
Args:
......@@ -308,7 +317,9 @@ def _resnet_model_fn(features, labels, mode):
num_batches_per_epoch * x
for x in np.array([82, 123, 300], dtype=np.int64)
]
staged_lr = [0.1, 0.01, 0.001, 0.0002]
staged_lr = [FLAGS.learning_rate * x
for x in [1, 0.1, 0.01, 0.002]]
learning_rate = tf.train.piecewise_constant(tf.train.get_global_step(),
boundaries, staged_lr)
# Create a nicely-named tensor for logging
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment