我在阅读关于学习率衰减的内容时,觉得文档中可能存在错误,因此想确认一下。文档中提到衰减方程是:
decayed_learning_rate = learning_rate * decay_rate ^ (global_step / decay_steps)
然而,如果global_step = 0
,我猜测不会有衰减,对吗?但是,看看这个示例:
...global_step = tf.Variable(0, trainable=False)starter_learning_rate = 0.1learning_rate = tf.train.exponential_decay(starter_learning_rate, global_step, 100000, 0.96, staircase=True)# Passing global_step to minimize() will increment it at each step.learning_step = ( tf.GradientDescentOptimizer(learning_rate) .minimize(...my loss..., global_step=global_step))
示例中有一个global_step = tf.Variable(0, trainable=False)
被设置为零。因此,没有衰减。我的推断正确吗?
我原本以为在设置staircase函数为true时,可能会因为整数除法而有所不同,但即使是整数除法,似乎仍然没有衰减。还是我误解了staircase的作用?
回答:
变量global_step
被传递到minimize
函数中,并且每次运行训练操作learning_step
时都会增加。
甚至在你的代码注释中也写着:
# Passing global_step to minimize() will increment it at each step.