1. 程式人生 > >TensorFlow筆記:指數衰減學習率

TensorFlow筆記:指數衰減學習率

學習率決定了引數更新的幅度。通常我們希望在學習開始階段提供一個較大的學習率,使得引數快速更新,達到最優解附近。然後隨著訓練的進行,我們希望在學習率隨著訓練次數的增加而減少,即在接近最優解的時候能夠以較小的學習率逼近最優解
TensorFlow為我們提供了tf.train.exponential_decay()函式實現這個功能

tf.train.exponential_decay()函式

定義

tf.train.exponential_decay(
    learning_rate,
    global_step,
    decay_steps,
    decay_rate,
    staircase=
False, name=None )

解釋

指數衰減學習率的計算方法如下
new_learning_rate=learning_ratedecay_rateglobal_stepdecay_step new\_learning\_rate = learning\_rate * decay\_rate^{\frac{global\_step}{decay\_step}}
learning_rate 引數為初始的學習率, global_step 引數為當前的訓練步數, decay_steps

引數設定了學習率衰減的速度,經過 decay_steps 後會進行一次衰減, decay_rate 引數則是衰減的比例, staircse 引數為真時會對 global_stepdecay_step\frac{global\_step}{decay\_step} 進行取整,從而學習率會呈階梯式下降