Tensorflow学习率的learning rate decay
Posted yqtaowhu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tensorflow学习率的learning rate decay相关的知识,希望对你有一定的参考价值。
x = tf.Variable(1.0)
y = x.assign_add(1)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print sess.run(x)
print sess.run(y)
print sess.run(x)
输出 1,2,2注意其x会变的
import tensorflow as tf
global_step = tf.Variable(0, trainable=False)
initial_learning_rate = 0.1 #初始学习率
learning_rate = tf.train.exponential_decay(initial_learning_rate,
global_step=global_step,
decay_steps=10,decay_rate=0.9)
opt = tf.train.GradientDescentOptimizer(learning_rate)
add_global = global_step.assign_add(1)
with tf.Session() as sess:
tf.global_variables_initializer().run()
print(sess.run(learning_rate))
for i in range(1):
_, rate = sess.run([add_global, learning_rate])
print(rate)
参考:
http://blog.csdn.net/u012436149/article/details/62058318
以上是关于Tensorflow学习率的learning rate decay的主要内容,如果未能解决你的问题,请参考以下文章
tensorflow机器学习指数衰减学习率的使用tf.train.exponential_decay
Tensorflow学习笔记(对MNIST经典例程的)的代码注释与理解
TensorFlow 中的 tf.train.exponential_decay() 指数衰减法