def noam_scheme(global_step, num_warmup_steps, num_train_steps, init_lr, warmup=True):
"""
decay learning rate
if warmup > global step, the learning rate will be global_step/num_warmup_steps * init_lr
if warmup < global step, the learning rate will be polynomial decay
:param global_step: global steps
:param num_warmup_steps: number of warm up steps
:param num_train_steps: number of train steps
:param init_lr: initial learning rate
:param warmup: if True, it will warm up learning rate
:return: learning rate
"""
learning_rate = tf.constant(value=init_lr, shape=[], dtype=tf.float32)
learning_rate = tf.train.polynomial_decay(learning_rate,
global_step,
num_train_steps,
end_learning_rate=0.0,
power=1.0,
cycle=False) if warmup:
global_steps_int = tf.cast(global_step, tf.int32)
warmup_steps_int = tf.constant(num_warmup_steps, dtype=tf.int32) global_steps_float = tf.cast(global_steps_int, tf.float32)
warmup_steps_float = tf.cast(warmup_steps_int, tf.float32) warmup_percent_done = global_steps_float / warmup_steps_float
warmup_learning_rate = init_lr * warmup_percent_done is_warmup = tf.cast(global_steps_int < warmup_steps_int, tf.float32)
learning_rate = ((1.0 - is_warmup) * learning_rate + is_warmup * warmup_learning_rate) return learning_rate

learning rate warmup实现的更多相关文章

  1. Dynamic learning rate in training - 培训中的动态学习率

    I'm using keras 2.1.* and want to change the learning rate during training. I know about the schedul ...

  2. mxnet设置动态学习率(learning rate)

    https://blog.csdn.net/xiaotao_1/article/details/78874336 如果learning rate很大,算法会在局部最优点附近来回跳动,不会收敛: 如果l ...

  3. 学习率(Learning rate)的理解以及如何调整学习率

    1. 什么是学习率(Learning rate)?   学习率(Learning rate)作为监督学习以及深度学习中重要的超参,其决定着目标函数能否收敛到局部最小值以及何时收敛到最小值.合适的学习率 ...

  4. 跟我学算法-吴恩达老师(mini-batchsize,指数加权平均,Momentum 梯度下降法,RMS prop, Adam 优化算法, Learning rate decay)

    1.mini-batch size 表示每次都只筛选一部分作为训练的样本,进行训练,遍历一次样本的次数为(样本数/单次样本数目) 当mini-batch size 的数量通常介于1,m 之间    当 ...

  5. Keras 自适应Learning Rate (LearningRateScheduler)

    When training deep neural networks, it is often useful to reduce learning rate as the training progr ...

  6. Deep Learning 32: 自己写的keras的一个callbacks函数,解决keras中不能在每个epoch实时显示学习速率learning rate的问题

    一.问题: keras中不能在每个epoch实时显示学习速率learning rate,从而方便调试,实际上也是为了调试解决这个问题:Deep Learning 31: 不同版本的keras,对同样的 ...

  7. pytorch learning rate decay

    关于learning rate decay的问题,pytorch 0.2以上的版本已经提供了torch.optim.lr_scheduler的一些函数来解决这个问题. 我在迭代的时候使用的是下面的方法 ...

  8. machine learning (5)---learning rate

    degugging:make sure gradient descent is working correctly cost function(J(θ)) of Number of iteration ...

  9. 深度学习: 学习率 (learning rate)

    Introduction 学习率 (learning rate),控制 模型的 学习进度 : lr 即 stride (步长) ,即反向传播算法中的 ηη : ωn←ωn−η∂L∂ωnωn←ωn−η∂ ...

随机推荐

  1. Maven的assembly插件在linux启动卡住Starting the localhost.localdomain

    1.今天在测试assembly的时候,在Linux虚拟机,内存配置为512mb,然后开始在Linux上运行assembly的时候就会一直卡住  2.停止运行后,查看了下日志 [root@localho ...

  2. C#WinForm解决跨线程访问控件属性报错

    方式一(在程序初始化构造函数中加一行代码): public Form1() { InitializeComponent(); Control.CheckForIllegalCrossThreadCal ...

  3. 在执行方法和Web资源中获取传递过来参数的值

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复228或者20161026可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...

  4. 安装Ubuntu系统后的配置工作

    目录 卸载webapps和LibreOffice 修改软件更新和安装的apt源 修改安装python库的pip源 安装并设置搜狗输入法 安装vim.git.pip和tweak软件 修改用户主目录下的文 ...

  5. 如何使用 CODING 进行瀑布流式研发

    你好,欢迎使用CODING!这份最佳实践将帮助你通过 CODING 更好地实践瀑布流式开发流程. 什么是瀑布流式研发 1970 年温斯顿·罗伊斯(Winston Royce)提出了著名的"瀑 ...

  6. Python—实现ssh客户端(连接远程服务器)

    paramiko是一个基于SSH用于连接远程服务器并执行相关操作(SSHClient和SFTPClinet,即一个是远程连接,一个是上传下载服务),使用该模块可以对远程服务器进行命令或文件操作,值得一 ...

  7. 实时SSH网络吞吐量测试

    centos 需要epel 源安装pv 软件,debian 需要安装pv 软件 #测试本机到192.168.1.158 的实时速率 yes | pv | ssh 192.168.1.158 " ...

  8. C学习笔记(7)--- typedef,输入输出

    1.typedef: C 语言提供了 typedef 关键字,您可以使用它来为类型(type)取一个新的名字. 比如: typedef unsigned char BYTE; 然后你就可以把BYTE当 ...

  9. 简单web服务工作流程梳理

       一.用户访问web基本流转过程梳理 二.web框架粗略概括

  10. 如何使用DOM4j+xpath 解析

    1.首先去dom4j官网下载一个对应版本的JAR包 XML的配置文件 导入一个config.xml文件 下面是dom4j+xpath解析XML文件