Tensorflow——tf.train.exponential_decay函数(指数衰减法)

简介

在Tensorflow中,为解决设定学习率(learning rate)问题,提供了指数衰减法来解决。
通过tf.train.exponential_decay函数实现指数衰减学习率。

学习率较大容易搜索震荡(在最优值附近徘徊),学习率较小则收敛速度较慢,
那么可以通过初始定义一个较大的学习率,通过设置decay_rate来缩小学习率,减少迭代次数。
tf.train.exponential_decay就是用来实现这个功能。

步骤:
1.首先使用较大学习率(目的:为快速得到一个比较优的解);
2.然后通过迭代逐步减小学习率(目的:为使模型在训练后期更加稳定);

定义

tf.train.exponential_decay(
learning_rate, 
global_, 
decay_steps, 
decay_rate, 
staircase=True/False
)

参数设置:

  1. learning_rate = 学习速率
  2. decay_rate = 0.96 # 衰减速率,即每一次学习都衰减为原来的0.96
  3. 如果staircase=True,那么每decay_steps更新一次decay_rate,如果是False那么每一步都更新一次decay_rate。
    • 如果staircase为True,那么每decay_steps改变一次learning_rate,
    • 改变为learning_rate*(decay_rate^decay_steps)
    • 如果为False则,每一步都改变,为learning_rate*decay_rate
  4. global_ = tf.placeholder(dtype=tf.int32)

你可能感兴趣的:(Tensorflow——tf.train.exponential_decay函数(指数衰减法))