Tensorflow学习率的learning rate decay

  • Post author:
  • Post category:其他


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



版权声明:本文为taoyanqi8932原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。