TensorFlow 中的 tf.train.exponential_decay() 指数衰减法
exponential_decay(learning_rate, global_step, decay_steps, decay_rate, staircase=False, name=None)
使用方式为
tf.train.exponential_decay( )
在 Tensorflow 中,exponential_decay()是应用于学习率的指数衰减函数(实现指数衰减学习率)。
在训练模型时,通常建议随着训练的进行逐步降低学习率。该函数需要`global_step`值来计算衰减的学习速率。
该函数返回衰减后的学习率。该函数的计算方程式如下

参数:
- learning_rate - 初始学习率
- global_step - 用于衰减计算的全局步骤。 一定不为负数。喂入一次 BACTH_SIZE 计为一次 global_step
- decay_steps - 衰减速度,一定不能为负数,每间隔decay_steps次更新一次learning_rate值
- decay_rate - 衰减系数,衰减速率,其具体意义参看函数计算方程(对应α^t中的α)。
- staircase - 若 ‘ True ’ ,则学习率衰减呈 ‘ 离散间隔 ’ (discrete intervals),具体地讲,`global_step / decay_steps`是整数除法,衰减学习率( the decayed learning rate )遵循阶梯函数;若为 ’ False ‘ ,则更新学习率的值是一个连续的过程,每步都会更新学习率。
返回值:
- 与初始学习率 ‘ learning_rate ’ 相同的标量 ’ Tensor ‘ 。
优点:
- 训练伊始可以使用较大学习率,以快速得到比较优的解。
- 后期通过逐步衰减后的学习率进行迭代训练,以使模型在训练后期更加稳定。
示例:
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.1
decay_rate = 0.96
global_steps = 1000
decay_steps = 100
global_step = tf.Variable(0, trainable = Fasle)
c = tf.train.exponential_decay(learning_rate, global_step, decay_steps, decay_rate, staircase=True)
d = tf.train.exponential_decay(learning_rate, global_step, decay_steps, decay_rate, staircase=False)
T_C = []
F_D = []
with tf.Session() as sess:
for i in range(global_steps):
T_c = sess.run(c, feed_dict={global_step: i})
T_C.append(T_c)
F_d = sess.run(d, feed_dict={global_step: i})
F_D.append(F_d)
plt.figure(1)
plt.plot(range(global_steps), F_D, 'r-')
plt.plot(range(global_steps), T_C, 'b-')
plt.show()
运行

备注:
(1)
台阶形状的蓝色线是 staircase = True
线条形状的红色线是 staircase = Fasle
(2)
初始学习率 learning_rate 为0.1,总训练次数 global_setps 为 1000 次;staircase=True时,每隔 decay_steps = 100 次更新一次 学习率 learning_rate,而staircase=True时,每一步均会更新一次学习率 learning_rate ,
(3)
训练过程中,decay_rate的数值保持步不变。
TensorFlow 中的 tf.train.exponential_decay() 指数衰减法的更多相关文章
- tensorflow之tf.train.exponential_decay()指数衰减法
exponential_decay(learning_rate, global_steps, decay_steps, decay_rate, staircase=False, name=None) ...
- Tensorflow中的tf.argmax()函数
转载请注明出处:http://www.cnblogs.com/willnote/p/6758953.html 官方API定义 tf.argmax(input, axis=None, name=None ...
- tensorflow中使用tf.variable_scope和tf.get_variable的ValueError
ValueError: Variable conv1/weights1 already exists, disallowed. Did you mean to set reuse=True in Va ...
- [转载]tensorflow中使用tf.ConfigProto()配置Session运行参数&&GPU设备指定
tf.ConfigProto()函数用在创建session的时候,用来对session进行参数配置: config = tf.ConfigProto(allow_soft_placement=True ...
- tensorflow中共享变量 tf.get_variable 和命名空间 tf.variable_scope
tensorflow中有很多需要变量共享的场合,比如在多个GPU上训练网络时网络参数和训练数据就需要共享. tf通过 tf.get_variable() 可以建立或者获取一个共享的变量. tf.get ...
- tensorflow中使用tf.ConfigProto()配置Session运行参数&&GPU设备指定
tf.ConfigProto()函数用在创建session的时候,用来对session进行参数配置: config = tf.ConfigProto(allow_soft_placement=True ...
- tf.Session()函数的参数应用(tensorflow中使用tf.ConfigProto()配置Session运行参数&&GPU设备指定)
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/dcrmg/article/details ...
- tensorflow中的tf.app.run()的使用
指明函数的入口,即从哪里执行函数. 如果你的代码中的入口函数不叫main(),而是一个其他名字的函数,如test(),则你应该这样写入口tf.app.run(test()) 如果你的代码中的入口函数叫 ...
- tensorflow中协调器 tf.train.Coordinator 和入队线程启动器 tf.train.start_queue_runners
TensorFlow的Session对象是支持多线程的,可以在同一个会话(Session)中创建多个线程,并行执行.在Session中的所有线程都必须能被同步终止,异常必须能被正确捕获并报告,会话终止 ...
随机推荐
- [Git] Squash all of my commits into a single one and merge into master
Often you have your feature branch you’ve been working on and once it’s ready, you just want it to m ...
- 【python】使用py3-bencode打开torrent文件
没想到这个原始版本访问量超过了后继版本,估计有些流量是搜索引擎带来的,有些人并不会点击左边“我的随笔”去找新的版本. 现把后继版本地址贴一下:http://www.cnblogs.com/xiande ...
- iOS 获取已安装 的APP
-(void)getAppPlist { Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace ...
- ReactJS.NET 之 Demo 初探
ReactJS.NET 是专对 .NET 平台开发者设计,让我们不只可以在前端去Render出页面,也可以在Server端去Render页面.开发 ReactJS 可以用一般JS 库,也可以通过类似X ...
- 设计模式 - 模板方法模式(template method pattern) 排序(sort) 具体解释
模板方法模式(template method pattern) 排序(sort) 具体解释 本文地址: http://blog.csdn.net/caroline_wendy 參考模板方法模式(tem ...
- 12 个非常实用的 jQuery 代码片段
jQuery是一个非常流行而且实用的JavaScript前端框架,本文并不是介绍jQuery的特效动画,而是分享一些平时积累的12个jQuery实用代码片段,希望对你有所帮助. 导航菜单背景切换效果 ...
- zip 文件下载函数封装
代码: export default { /** * 下载文件 */ exportFile: (fileUrl) => { if (fileUrl) { let exportFrame = do ...
- golang之tcp自动重连
操作系统: CentOS 6.9_x64 go语言版本: 1.8.3 问题描述 现有一个tcp客户端程序,需定期从服务器取数据,但由于种种原因(网络不稳定等)需要自动重连. 测试服务器示例代码: /* ...
- spring & java 面试
https://blog.csdn.net/u014079773/article/details/52453002 1.Spring中AOP的应用场景.Aop原理.好处? 答:AOP--Aspect ...
- qtp descriptive programming multiple language(多语言支持)
so easy, 1,use the descriptive programming; 2,use the | chracter to seperate the different language ...