I use Tensorflow Object Detection API tutorial https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/index.html to train my custom model. Follow this instructions, I have used config file from oficial GitHub repo and script train.py for training. I have seen in config file, that learning rate should be adaptive. It can be seen in this lines:
train_config: {
batch_size: 24
optimizer {
rms_prop_optimizer: {
learning_rate: {
exponential_decay_learning_rate {
initial_learning_rate: 0.004
decay_steps: 800720
decay_factor: 0.95
}
}
momentum_optimizer_value: 0.9
decay: 0.9
epsilon: 1.0
}
}
Then, I used TensorBoard during the training and it showed me, that learning rate is constant for every training step. Why does it going? May it be, that TensorBoard see only initial value of learning rate and optimizer calculate real value of it on the fly?
In the API, the optimizer was built in this file. And this is the line for the rms_prop_optimizer
. To build the optimizer learning rate, the function called a function _create_learning_rate
that eventually called the learning_schedules
under object_detection/utils
. And here is how the learning rate is scheduled in your example.
def exponential_decay_with_burnin(global_step,
learning_rate_base,
learning_rate_decay_steps,
learning_rate_decay_factor,
burnin_learning_rate=0.0,
burnin_steps=0,
min_learning_rate=0.0,
staircase=True):
"""Exponential decay schedule with burn-in period.
In this schedule, learning rate is fixed at burnin_learning_rate
for a fixed period, before transitioning to a regular exponential
decay schedule.
Args:
global_step: int tensor representing global step.
learning_rate_base: base learning rate.
learning_rate_decay_steps: steps to take between decaying the learning rate.
Note that this includes the number of burn-in steps.
learning_rate_decay_factor: multiplicative factor by which to decay
learning rate.
burnin_learning_rate: initial learning rate during burn-in period. If
0.0 (which is the default), then the burn-in learning rate is simply
set to learning_rate_base.
burnin_steps: number of steps to use burnin learning rate.
min_learning_rate: the minimum learning rate.
staircase: whether use staircase decay.
Returns:
a (scalar) float tensor representing learning rate
"""
if burnin_learning_rate == 0:
burnin_learning_rate = learning_rate_base
post_burnin_learning_rate = tf.train.exponential_decay(
learning_rate_base,
global_step - burnin_steps,
learning_rate_decay_steps,
learning_rate_decay_factor,
staircase=staircase)
return tf.maximum(tf.where(
tf.less(tf.cast(global_step, tf.int32), tf.constant(burnin_steps)),
tf.constant(burnin_learning_rate),
post_burnin_learning_rate), min_learning_rate, name='learning_rate')
And here is the learning rate decay plot. Even after 100 000 steps, the decay is actually very small.