莫烦大大TensorFlow学习笔记(8)----优化器
一、TensorFlow中的优化器
- tf.train.GradientDescentOptimizer:梯度下降算法
- tf.train.AdadeltaOptimizer
- tf.train.AdagradOptimizer
- tf.train.MomentumOptimizer:动量梯度下降算法
- tf.train.AdamOptimizer:自适应矩估计优化算法
- tf.train.RMSPropOptimizer
- tf.train.AdagradDAOptimizer
- tf.train.FtrlOptimizer
- tf.train.ProximalGradientDescentOptimizer
- tf.train.ProximalAdagradOptimizertf.train.RMSProOptimizer
(1)如果数据是稀疏的,使用自适应学习方法。
(2)RMSprop,Adadelta,Adam是非常相似的优化算法,Adam的bias-correction帮助其在最后优化期间梯度变稀疏的情况下略微战胜了RMSprop。整体来讲,Adam是最好的选择。
(3)很多论文中使用vanilla SGD without momentum。SGD通常能找到最小值,但是依赖健壮的初始化,并且容易陷入鞍点。因此,如果要获得更快的收敛速度和训练更深更复杂的神经网络,需要选择自适应学习方法。
https://blog.csdn.net/winycg/article/details/79363169
二、常用的种类:
1、tf.train.Optimizer:
2、tf.train.GradientDescentOptimizer:梯度下降
原理:
batch GD【全部样本,速度慢】
随机GD【随机一个样本,速度快,但局部最优】
mini-batch GD 【batch个样本,常在数据量较大时使用】
训练集样本数少【≤2000】:采用batchGD
训练集样本数多:采用mini-batch GD,batch大小一般为64-512. 训练时多尝试一下2的次方来找到最合适的batch大小。
应用:
这个类是实现梯度下降算法的优化器。这个构造函数需要的一个学习率就行了。
构造函数:tf.train.GradientDescentOptimizer(0.001).minimize(loss,global_step=None,var_list=None,gate_gradients=GATE_OP,aggregation_method=None,colocate_gradients_with_ops=False,name=None,grad_loss=None)
__init__( learning_rate, use_locking=False, name='GradientDescent' )
learning_rate
: (学习率)张量或者浮点数
use_locking
: 为True时锁定更新
name
: 梯度下降名称,默认为"GradientDescent".
3、tf.train.AdadeltaOptimizer:
实现了 Adadelta算法的优化器,可以算是下面的Adagrad算法改进版本。
构造函数: tf.train.AdadeltaOptimizer.init(learning_rate=0.001, rho=0.95, epsilon=1e-08, use_locking=False, name=’Adadelta’)
4、tf.train.AdagradOptimizer:
构造函数:tf.train.AdagradOptimizer.__init__
(learning_rate, initial_accumulator_value=0.1, use_locking=False, name=’Adagrad’)
5、tf.train.MomentumOptimizer:
原理:
momentum表示要在多大程度上保留原来的更新方向,这个值在0-1之间,在训练开始时,由于梯度可能会很大,所以初始值一般选为0.5;当梯度不那么大时,改为0.9。 α是学习率,即当前batch的梯度多大程度上影响最终更新方向,跟普通的SGD含义相同。
应用:
构造函数:tf.train.MomentumOptimizer.__init__
(learning_rate, momentum, use_locking=False, name=’Momentum’, use_nesterov=False)
__init__( learning_rate, momentum, use_locking=False, name='Momentum', use_nesterov=False )
learning_rate: (学习率)张量或者浮点数
momentum: (动量)张量或者浮点数
use_locking: 为True时锁定更新
name: 梯度下降名称,默认为 "Momentum".
use_nesterov: 为True时,使用 Nesterov Momentum.
6、tf.train.RMSPropOptimizer
目的和动量梯度一样,减小垂直方向,增大水平方向。W为水平方向,b为垂直方向。
7、tf.train.AdamOptimizer:动量和RMSProp结合
应用:
__init__( learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, use_locking=False, name='Adam' )
构造函数:tf.train.AdamOptimizer.__init__
(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, use_locking=False, name=’Adam’)
learning_rate: (学习率)张量或者浮点数,需要调试
beta1: 浮点数或者常量张量 ,表示 The exponential decay rate for the 1st moment estimates.【推荐使用0.9】
beta2: 浮点数或者常量张量 ,表示 The exponential decay rate for the 2nd moment estimates.【推荐使用0.999】
epsilon: A small constant for numerical stability. This epsilon is "epsilon hat" in the Kingma and Ba paper (in the formula just before Section 2.1), not the epsilon in Algorithm 1 of the paper.
use_locking: 为True时锁定更新
name: 梯度下降名称,默认为 "Adam".
莫烦大大TensorFlow学习笔记(8)----优化器的更多相关文章
- 莫烦大大TensorFlow学习笔记(9)----可视化
一.Matplotlib[结果可视化] #import os #os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import tensorflow as tf i ...
- 莫烦python教程学习笔记——总结篇
一.机器学习算法分类: 监督学习:提供数据和数据分类标签.--分类.回归 非监督学习:只提供数据,不提供标签. 半监督学习 强化学习:尝试各种手段,自己去适应环境和规则.总结经验利用反馈,不断提高算法 ...
- 莫烦python教程学习笔记——保存模型、加载模型的两种方法
# View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://ww ...
- 莫烦python教程学习笔记——validation_curve用于调参
# View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...
- 莫烦python教程学习笔记——learn_curve曲线用于过拟合问题
# View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...
- 莫烦python教程学习笔记——利用交叉验证计算模型得分、选择模型参数
# View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...
- 莫烦python教程学习笔记——数据预处理之normalization
# View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...
- 莫烦python教程学习笔记——线性回归模型的属性
#调用查看线性回归的几个属性 # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # ...
- 莫烦python教程学习笔记——使用波士顿数据集、生成用于回归的数据集
# View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...
随机推荐
- oracle 工具:tkprof
https://docs.oracle.com/cd/B10501_01/server.920/a96533/ex_plan.htm http://blog.csdn.net/dba_waterbin ...
- HDU 1238
好吧,这题直接搜索就可以了,不过要按照长度最短的来搜,很容易想得到. 记得ACM比赛上有这道题,呃..不过,直接搜..呵呵了,真不敢想. #include <iostream> #incl ...
- struts1——静态ActionForm与动态ActionForm
在struts1中,我们能够使用ActionForm来获取从client端提交上来的数据.并通过action配置中的name属性.将某个ActionForm配置到某次请求应答的Action中.作为本次 ...
- android 构建GPS Provide步骤及信息
构建GPS Provide步骤及信息 1. 用GPS2GoogleEarth录制KML文件 2. KML文件 2.1 经纬度解析 <LineString> <coordina ...
- Spring JDBC数据库开发
针对数据库操作,Spring框架提供了JdbcTemplate类. 1.Spring JDBC的配置 创建配置文件applicationContext.xml,添加如下代码: <!--配置数据源 ...
- Java编程:切面条
/* 一根高筋拉面,中间切一刀,能够得到2根面条. 假设先对折1次.中间切一刀.能够得到3根面条. 假设连续对折2次,中间切一刀.能够得到5根面条. 那么.连续对折10次.中间切一刀.会得到多少面条呢 ...
- fragment.setMenuVisibility setUserVisibleHint
[Android]Fragment真正意义上的onResume和onPause 前言 Fragment虽然有onResume和onPause的,但是这两个方法是Activity的方法,调用时机也是与A ...
- consul 集群安装
上图是官网提供的一个事例系统图,图中的Server是consul服务端高可用集群,Client是consul客户端.consul客户端不保存数据,客户端将接收到的请求转发给响应的Server端.Ser ...
- 什么是递归?用十进制转二进制的Python函数示例说明
先上用Python写的十进制转二进制的函数代码: def Dec2Bin(dec): result = '' if dec: result = Dec2Bin(dec//2) return resul ...
- JS form 表单收集 数据 formSerialize
做后台系统的时候通常会用到form表单来做数据采集:每次一个字段一个字段的去收集就会很麻烦,网站也有form.js插件可以进行表单收集,并封装成一个对象,通过ajax方法传到后台:现在介绍一种直觉采集 ...