TensorFlow 學習率的設定

2021-08-08 14:22:44 字數 931 閱讀 9443

為了解決學習率不能過大不能過小的問題,tensorflow提供了靈活的學習率設定方法:指數衰減法

tensorflow.train.exponential_decay(learing_rate,global_step,decay_steps,decay_rate,staircase=false,name=none)
args:

return:

衰減的學習率

這個函式將指數衰減函式應用於初始化學習率,它使用乙個名稱為global_step變數去計算衰減學習率,可以將乙個在迭代中自增的tensorflow變數傳給它。

這個函式返回乙個衰減學習率,計算方式如下:

decayed_learning_rate =learing_rate * decay_rate^(global_step / decay_steps)
如果引數staircase為true,global / decay_steps 轉化為乙個整數。

example:每10000輪乙個0.96的速度衰減一次

global_step = tf.variable(0, trainable=false)

starter_learning_rate = 0.1

learning_rate = tf.exponential_decay(starter_learning_rate, global_step,100000, 0.96, staircase=true)

optimizer = tf.gradientdescent(learning_rate)

optimizer.minimize(...my loss..., global_step=global_step)

Tensorflow框架 學習率的設定

深度學習的訓練中,學習率的初始值對訓練的最終結果有著較大的影響,過大或過小的學習率可能使得網路無法收斂,或者收斂很慢,因此需要選擇合適的初值,並且要合理的降低學習率 參考部落格 下面主要介紹如下幾種常見的學習率衰減方式 指數衰減 分段常數衰減 1 指數衰減 tf.train.exponential ...

tensorflow複雜度學習率

import tensorflow as tfw tf.variable tf.constant 5,dtype tf.float32 epoch 40lr base 0.2 最初學習率 lr decay 0.99 學習率衰減率 lr step 1 餵入多少輪batch size後,更新一次學習率f...

tensorflow中學習率的調參策略

learning rate decay type 調參策略 1 exponential decay learning rate,global step,decay steps,decay rate,staircase false,name none learning rate 初始值 global ...