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

    xiaoxiao2021-03-26  48

    ReLU、LeakyReLU

    ReLU作为激活函数被广泛应用于各种深度神经网络中。在这篇博客中,我主要记录一下它和它的变种在caffe中的实现。 先看下来自wikipedia的一张示意图,图中蓝色的线表示的就是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

    转载请注明原文地址: https://ju.6miu.com/read-350135.html

    最新回复(0)