有關(guān)Tensorflow梯度下降常用的優(yōu)化方法分享
1.tf.train.exponential_decay() 指數(shù)衰減學(xué)習(xí)率:
#tf.train.exponential_decay(learning_rate, global_steps, decay_steps, decay_rate, staircase=True/False): #指數(shù)衰減學(xué)習(xí)率 #learning_rate-學(xué)習(xí)率 #global_steps-訓(xùn)練輪數(shù) #decay_steps-完整的使用一遍訓(xùn)練數(shù)據(jù)所需的迭代輪數(shù);=總訓(xùn)練樣本數(shù)/batch #decay_rate-衰減速度 #staircase-衰減方式;=True,那就表明每decay_steps次計(jì)算學(xué)習(xí)速率變化,更新原始學(xué)習(xí)速率;=alse,那就是每一步都更新學(xué)習(xí)速率。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) 滑動(dòng)平均更新參數(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--返回的是需要訓(xùn)練的變量列表 averages_op = ema.apply(tf.trainable_variables()) with tf.control_dependencies([optimizer]): train_op = tf.group(averages_op)
以上這篇有關(guān)Tensorflow梯度下降常用的優(yōu)化方法分享就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- tensorflow 實(shí)現(xiàn)自定義梯度反向傳播代碼
- TensorFlow梯度求解tf.gradients實(shí)例
- 基于TensorFlow中自定義梯度的2種方式
- tensorflow 查看梯度方式
- tensorflow求導(dǎo)和梯度計(jì)算實(shí)例
- Tensorflow的梯度異步更新示例
- 在Tensorflow中實(shí)現(xiàn)梯度下降法更新參數(shù)值
- Tensorflow實(shí)現(xiàn)部分參數(shù)梯度更新操作
- 運(yùn)用TensorFlow進(jìn)行簡(jiǎn)單實(shí)現(xiàn)線(xiàn)性回歸、梯度下降示例
- Tensorflow 卷積的梯度反向傳播過(guò)程
相關(guān)文章
ansible作為python模塊庫(kù)使用的方法實(shí)例
ansible是一個(gè)python package,是個(gè)完全的unpack and play軟件,對(duì)客戶(hù)端唯一的要求是有ssh有python,并且裝了python-simplejson包,部署上簡(jiǎn)單到發(fā)指。下面這篇文章就給大家主要介紹了ansible作為python模塊庫(kù)使用的方法實(shí)例,需要的朋友可以參考借鑒。2017-01-01pytorch中的weight-initilzation用法
這篇文章主要介紹了pytorch中的weight-initilzation用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-06-06Python實(shí)現(xiàn)的幾個(gè)常用排序算法實(shí)例
這篇文章主要介紹了Python實(shí)現(xiàn)的幾個(gè)常用排序算法實(shí)例例如直接插入排序、直接選擇排序、冒泡排序、快速排序等,需要的朋友可以參考下2014-06-06Python實(shí)例方法、類(lèi)方法、靜態(tài)方法區(qū)別詳解
這篇文章主要介紹了Python實(shí)例方法、類(lèi)方法、靜態(tài)方法區(qū)別詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09使用 Python 快速實(shí)現(xiàn) HTTP 和 FTP 服務(wù)器的方法
這篇文章主要介紹了使用 Python 快速實(shí)現(xiàn) HTTP 和 FTP 服務(wù)器 的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07Python中執(zhí)行存儲(chǔ)過(guò)程及獲取存儲(chǔ)過(guò)程返回值的方法
這篇文章主要介紹了Python中執(zhí)行存儲(chǔ)過(guò)程及獲取存儲(chǔ)過(guò)程返回值的方法,結(jié)合實(shí)例形式總結(jié)分析了Python調(diào)用存儲(chǔ)過(guò)程的常用方法與相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2017-10-10python中導(dǎo)入 train_test_split提示錯(cuò)誤的解決
這篇文章主要介紹了python中導(dǎo)入 train_test_split提示錯(cuò)誤的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-06-06