[Caffe]:关于ReLU、LeakyReLU 、PReLU layer

ReLU、LeakyReLU

ReLU作为激活函数被广泛应用于各种深度神经网络中。在这篇博客中,我主要记录一下它和它的变种在caffe中的实现。
先看下来自wikipedia的一张示意图,图中蓝色的线表示的就是ReLU函数。
ReLU
ReLU激活函数极为 f(x)=max(0,x) 。而LeakyReLU则是其变体 f(x)=max(0,x)+negative_slope×min(0,x) ,其中, negative_slope 是一个小的非零数。

综上,在caffe中,ReLU和LeakyReLU都包含在relu_layer中。
在后向传播过程中,ReLU做如下运算:

Ex=0Eyifx0ifx>0

而变体的LeakyReLU则做:
Ex=νEyEyifx0ifx>0

接下来,我们来看看ReLU层的参数。

// Message that stores parameters used by ReLULayer
message ReLUParameter {
  // Allow non-zero slope for negative inputs to speed up optimization
  // Described in:
  // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
  // improve neural network acoustic models. In ICML Workshop on Deep Learning
  // for Audio, Speech, and Language Processing.
  optional float negative_slope = 1 [default = 0]; //如之前分析的,默认值0即为ReLU,非零则为LeakyReLU
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 2 [default = DEFAULT]; //运算引擎选择,一般选择默认
}

PReLU

PReLU,即Parametric ReLU,是何凯明组提出的一种改进ReLU。它的数学表示为 yi=max(0,xi)+ai×min(0,xi) ,其中 a 是可学习参数。当a为固定的非零较小数时,它等价于LeakyReLU;当它为0时,PReLU等价于ReLU。它的后向传播进行如下计算:

Exi=aiEyiEyiifxi0ifxi>0

参数 a 的更新公式如下:
Eai=xixiEyi0ifxi0ifxi>0

PReLU的实现不包含在ReLU中,主要是有可学习参数 a <script type="math/tex" id="MathJax-Element-12">a</script>,它的实现包含在prelu_layer中。

message PReLUParameter {
  // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
  // Surpassing Human-Level Performance on ImageNet Classification, 2015.

  // Initial value of a_i. Default is a_i=0.25 for all i.
  optional FillerParameter filler = 1;  //默认填充,a_i的初始值为0.25
  // Whether or not slope parameters are shared across channels.
  optional bool channel_shared = 2 [default = false]; //是否通道共享参数,默认为不共享
}

Delving Deep into Rectifiers:Surpassing Human-Level Performance on ImageNet Classification

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值