Bugfix in lr policy
@@ -86,7 +86,20 @@ class ModelBase:
def exp_decay(learning_rate, var_global_step):
- new_lr = tf.train.exponential_decay(learning_rate=learning_rate,
+ new_lr = tf.cond(
+ var_global_step < self.model_params['begin_decay_at'],
+ lambda: learning_rate,
+ lambda: tf.train.exponential_decay(
+ learning_rate,
+ var_global_step - self.model_params['begin_decay_at'],
+ self.model_params['decay_steps'],
+ self.model_params['decay_rate'],
+ staircase=self.model_params['use_staircase_decay']),
+ name="learning_rate")
+ final_lr = tf.maximum(self.model_params['min_learning_rate'], new_lr)
+ self._lr = final_lr
+ return final_lr
+ """new_lr = tf.train.exponential_decay(learning_rate=learning_rate,
global_step=var_global_step,
decay_steps=self.model_params['decay_steps'],
decay_rate=self.model_params['decay_rate'],
@@ -99,7 +112,7 @@ class ModelBase:
boundaries=boundaries,
values=values), min_rate)
self._lr = final_lr
- return final_lr
+ return final_lr"""
lr_decay_fn = exp_decay if 'use_decay' in self.model_params and self.model_params['use_decay'] == True else None
