有關(guān)Tensorflow梯度下降常用的優(yōu)化方法分享
1.tf.train.exponential_decay() 指數(shù)衰減學習率:
#tf.train.exponential_decay(learning_rate, global_steps, decay_steps, decay_rate, staircase=True/False): #指數(shù)衰減學習率 #learning_rate-學習率 #global_steps-訓練輪數(shù) #decay_steps-完整的使用一遍訓練數(shù)據(jù)所需的迭代輪數(shù);=總訓練樣本數(shù)/batch #decay_rate-衰減速度 #staircase-衰減方式;=True,那就表明每decay_steps次計算學習速率變化,更新原始學習速率;=alse,那就是每一步都更新學習速率。learning_rate = tf.train.exponential_decay( initial_learning_rate = 0.001 global_step = tf.Variable(0, trainable=False) decay_steps = 100 decay_rate = 0.95 total_loss = slim.losses.get_total_loss() learning_rate = tf.train.exponential_decay(initial_learning_rate, global_step, decay_steps, decay_rate, True, name='learning_rate') optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(total_loss, global_step)
2.tf.train.ExponentialMovingAverage(decay, steps) 滑動平均更新參數(shù):
initial_learning_rate = 0.001 global_step = tf.Variable(0, trainable=False) decay_steps = 100 decay_rate = 0.95 total_loss = slim.losses.get_total_loss() learning_rate = tf.train.exponential_decay(initial_learning_rate, global_step, decay_steps, decay_rate, True, name='learning_rate') optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(total_loss, global_step) ema = tf.train.ExponentialMovingAverage(decay=0.9999) #tf.trainable_variables--返回的是需要訓練的變量列表 averages_op = ema.apply(tf.trainable_variables()) with tf.control_dependencies([optimizer]): train_op = tf.group(averages_op)
以上這篇有關(guān)Tensorflow梯度下降常用的優(yōu)化方法分享就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
在ipython notebook中使用argparse方式
這篇文章主要介紹了在ipython notebook中使用argparse方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
windows python3安裝Jupyter Notebooks教程
這篇文章主要介紹了windows python3安裝Jupyter Notebooks教程,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
np.concatenate()函數(shù)數(shù)組序列參數(shù)的實現(xiàn)
本文主要介紹了np.concatenate()函數(shù)數(shù)組序列參數(shù)的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-03-03
python基礎(chǔ)教程之簡單入門說明(變量和控制語言使用方法)
這篇文章主要介紹了開始學習python的第一步需要知道的知識(變量和控制語言使用方法),需要的朋友可以參考下2014-03-03
django中url映射規(guī)則和服務(wù)端響應(yīng)順序的實現(xiàn)
這篇文章主要介紹了django中url映射規(guī)則和服務(wù)端響應(yīng)順序的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-04-04

