主要是用在梯度下降中的學(xué)習(xí)率問題上,用來解決lr過大容易越過最優(yōu)值造成振蕩,lr過小造成收斂太慢并且可能達(dá)到局部最優(yōu)。
具體公式:
decayed_learning_rate = learning_rate * decay_rate ^ (global_step / decay_steps)
上述公式中
- decay_rate = 衰減系數(shù)
- decay_steps = 完整使用一遍訓(xùn)練數(shù)據(jù)所需迭代論數(shù)
- global_step = 當(dāng)前迭代的輪數(shù))
用于公式中的learning_rate、decay_rate以及decay_steps都是固定值,
可見decayed_learning_rate只與global_rate的變化有關(guān)
老規(guī)矩:
global_step = tf.Variable(0)
# 通過exponential_decay函數(shù)生成學(xué)習(xí)率
learning_rate = tf.train.exponential_decay(0.1, global_step, 100, 0.96, staircase = True)
# 使用指數(shù)衰減的學(xué)習(xí)率。在minimize函數(shù)中傳入global_step將自動更新
# global_ste參數(shù),從而使得學(xué)習(xí)率也得到相應(yīng)更新
learning_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(..my loss.., global_step = global_step)