batch_norm在强化学习中建议使用的形式
def batch_norm(layer, **kwargs):
"""
Apply batch normalization to an existing layer. This is a convenience
function modifying an existing layer to include batch normalization: It
will steal the layer's nonlinearity if there is one (effectively
introducing the normalization right before the nonlinearity), remove
the layer's bias if there is one (because it would be redundant), and add
a :class:`BatchNormLayer` and :class:`NonlinearityLayer` on top. Parameters
----------
layer : A :class:`Layer` instance
The layer to apply the normalization to; note that it will be
irreversibly modified as specified above
**kwargs
Any additional keyword arguments are passed on to the
:class:`BatchNormLayer` constructor. Returns
-------
BatchNormLayer or NonlinearityLayer instance
A batch normalization layer stacked on the given modified `layer`, or
a nonlinearity layer stacked on top of both if `layer` was nonlinear. Examples
--------
Just wrap any layer into a :func:`batch_norm` call on creating it: >>> from lasagne.layers import InputLayer, DenseLayer, batch_norm
>>> from lasagne.nonlinearities import tanh
>>> l1 = InputLayer((64, 768))
>>> l2 = batch_norm(DenseLayer(l1, num_units=500, nonlinearity=tanh)) This introduces batch normalization right before its nonlinearity: >>> from lasagne.layers import get_all_layers
>>> [l.__class__.__name__ for l in get_all_layers(l2)]
['InputLayer', 'DenseLayer', 'BatchNormLayer', 'NonlinearityLayer']
"""
nonlinearity = getattr(layer, 'nonlinearity', None)
if nonlinearity is not None:
layer.nonlinearity = lasagne.nonlinearities.identity
if hasattr(layer, 'b') and layer.b is not None:
del layer.params[layer.b]
layer.b = None
layer = BatchNormLayer(layer, **kwargs)
if nonlinearity is not None:
layer = L.NonlinearityLayer(layer, nonlinearity)
return layer
源代码地址:
https://gitee.com/devilmaycry812839668/rllab/blob/master/rllab/core/lasagne_layers.py
=================================================
这是经典reinforcement learning框架rllab中的batch_norm的使用。可以看到,在对一个线性层进行batch_norm的时候是不先对线性层的输出进行非线性变换的,而是先对其进行batch_norm,然后再进行非线性变换。而且要注意这里使用的线性层是不使用偏置参数b的,形象的来说,这里建议使用的对 tanh(w*x+b) 的 batch_norm 是这样运行的:
tanh( batch_norm( w*x ) )
而不是:
batch_norm( tanh( w*x + b ) )
This introduces batch normalization right before its nonlinearity:
It
will steal the layer's nonlinearity if there is one (effectively
introducing the normalization right before the nonlinearity), remove
the layer's bias if there is one (because it would be redundant)
=================================================
batch_norm在强化学习中建议使用的形式的更多相关文章
- 强化学习中的无模型 基于值函数的 Q-Learning 和 Sarsa 学习
强化学习基础: 注: 在强化学习中 奖励函数和状态转移函数都是未知的,之所以有已知模型的强化学习解法是指使用采样估计的方式估计出奖励函数和状态转移函数,然后将强化学习问题转换为可以使用动态规划求解的 ...
- 深度强化学习中稀疏奖励问题Sparse Reward
Sparse Reward 推荐资料 <深度强化学习中稀疏奖励问题研究综述>1 李宏毅深度强化学习Sparse Reward4 强化学习算法在被引入深度神经网络后,对大量样本的需求更加 ...
- 强化学习中REIINFORCE算法和AC算法在算法理论和实际代码设计中的区别
背景就不介绍了,REINFORCE算法和AC算法是强化学习中基于策略这类的基础算法,这两个算法的算法描述(伪代码)参见Sutton的reinforcement introduction(2nd). A ...
- SpiningUP 强化学习 中文文档
2020 OpenAI 全面拥抱PyTorch, 全新版强化学习教程已发布. 全网第一个中文译本新鲜出炉:http://studyai.com/course/detail/ba8e572a 个人认为 ...
- 强化学习中的经验回放(The Experience Replay in Reinforcement Learning)
一.Play it again: reactivation of waking experience and memory(Trends in Neurosciences 2010) SWR发放模式不 ...
- (转) 深度强化学习综述:从AlphaGo背后的力量到学习资源分享(附论文)
本文转自:http://mp.weixin.qq.com/s/aAHbybdbs_GtY8OyU6h5WA 专题 | 深度强化学习综述:从AlphaGo背后的力量到学习资源分享(附论文) 原创 201 ...
- 深度强化学习资料(视频+PPT+PDF下载)
https://blog.csdn.net/Mbx8X9u/article/details/80780459 课程主页:http://rll.berkeley.edu/deeprlcourse/ 所有 ...
- 【整理】强化学习与MDP
[入门,来自wiki] 强化学习是机器学习中的一个领域,强调如何基于环境而行动,以取得最大化的预期利益.其灵感来源于心理学中的行为主义理论,即有机体如何在环境给予的奖励或惩罚的刺激下,逐步形成对刺激的 ...
- 强化学习读书笔记 - 05 - 蒙特卡洛方法(Monte Carlo Methods)
强化学习读书笔记 - 05 - 蒙特卡洛方法(Monte Carlo Methods) 学习笔记: Reinforcement Learning: An Introduction, Richard S ...
- 强化学习(五)—— 策略梯度及reinforce算法
1 概述 在该系列上一篇中介绍的基于价值的深度强化学习方法有它自身的缺点,主要有以下三点: 1)基于价值的强化学习无法很好的处理连续空间的动作问题,或者时高维度的离散动作空间,因为通过价值更新策略时是 ...
随机推荐
- springmvc组件说明
DispatcherServlet:前端控制器,也称为中央控制器,它是整个请求响应的控制中心,组件的调用由它统一调度. HandlerMapping:处理器映射器,它根据用户访问的 URL 映射到对应 ...
- http请求方式-RestTemplate
http请求方式-RestTemplate import com.alibaba.fastjson.JSON; import com.example.core.mydemo.http.OrderReq ...
- 开发工具-eclipse/idea 在运行前执行一些动作
毫无疑问,我们有的时候想在运行/编译程序前后执行一些动作.eclipse和idea都能支持. 日前正好遇到一个问题:有个依赖于pom的某个jar,内容虽然变了,但是版本不变,所以希望每次执行前先清除特 ...
- 十大java应用服务器(web server)总结
java应用服务器(web server),是指运行java程序的web应用服务器软件,不包括nginx.Apache等通用web服务器软件. 一.Tomcat Tomcat是Apache 软件基金会 ...
- 算法金 | A - Z,115 个数据科学 机器学习 江湖黑话(全面)
大侠幸会,在下全网同名「算法金」 0 基础转 AI 上岸,多个算法赛 Top 「日更万日,让更多人享受智能乐趣」 机器学习本质上和数据科学一样都是依赖概率统计,今天整整那些听起来让人头大的机器学习江湖 ...
- SpringBoot打包maven仓库里面没有的包
SpringBoot打包maven仓库里面没有的包 在遇到一些自定义的jar包,maven仓库里面没有这些包,但是发布线上时我们还是只想发布一个jar包,也就是我们想要把第三方包打在最后生成的大jar ...
- TI AM64x工业开发板硬件说明书(双核ARM Cortex-A53 + 单/四核Cortex-R5F + 单核Cortex-M4F,主频1GHz)
前 言 本文主要介绍TL64x-EVM评估板硬件接口资源以及设计注意事项等内容. 创龙科技TL64x-EVM是一款基于TI Sitara系列AM64x双核ARM Cortex-A53 + 单/四核C ...
- c语言生成随机数
记录示例,留作自用 #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) ...
- 汇编语言--cpu的工作原理(寄存器)--手稿
03
- ARP协议介绍与投毒攻击
目录 ARP是什么? ARP协议工作原理 ARP攻击原理 攻击软件 防范 Reference ARP是什么? ARP是通过网络地址(IP)来定位机器MAC地址的协议,它通过解析网络层地址(IP)来找寻 ...