机器学习人工智能/模式识别/机器学习精华专题Machine Learning & Recommendation & NLP & DL

ReLU激活函数

2019-06-16  本文已影响11人  9933fdf22087

概述:ReLU函数的计算是在卷积之后进行的,因此它与tanh函数和sigmoid函数一样,同属于非线性激活函数。ReLU函数的倒数在正数部分是恒等于1的,因此在深度网络中使用relu激活函数就不会导致梯度小时和爆炸的问题。并且,ReLU函数计算速度快,加快了网络的训练。不过,如果梯度过大,导致很多负数,由于负数部分值为0,这些神经元将无法激活(可通过设置较小学习率来解决)。

1.ReLu:
\operatorname{Re} \mathrm{LU}(\mathrm{x})=\max (\mathrm{x}, 0)=\left\{\begin{array}{l}{0, x<0} \\ {x, x>0}\end{array}\right\}
后向推导过程:设l层输出为z^l,经过激活函数后的输出为z^{l+1};记损失函数L关于第l层的输出z^l的偏导为\delta^{l}=\frac{\partial L}{\partial z^{l}},则损失函数L关于第l层的偏导为:
\delta^{l}=\frac{\partial L}{\partial z^{l+1}} \frac{\partial z^{l+1}}{\partial z^{l}}
=\delta^{l+1} \frac{\partial \operatorname{Re} L U\left(z^{l}\right)}{\partial z^{l}}
=\delta^{l+1}\left\{\begin{array}{ll}{1} & {z^{l}>0} \\ {0} & {z^{l}<=0}\end{array}\right.

2.LeakReLU:
LeakReLU (LeakReLU(z))=\left\{\begin{array}{ll}{z} & {z>0} \\ {\alpha z} & {z<=0, \alpha=0.1}\end{array}\right.
在负数部分给予一个小的梯度。由Relu可知损失函数L关于第l层的偏导为:
\delta^{l}=\left\{\begin{array}{ll}{\delta^{l+1}} & {z^{l}>0} \\ {\alpha \delta^{l+1}} & {z^{l}<=0, \alpha=0.1}\end{array}\right.

3.PReLU:
表达式与LeakReLu相同,只不过\alpha可以学习。损失函数L关于参数\alpha的偏导为:
\frac{\partial L}{\partial \alpha}=\frac{\partial L}{\partial z^{l+1}} \frac{\partial z^{l+1}}{\partial \alpha}
\delta^{l}=\delta^{l+1} \frac{\partial P R e L U\left(z^{l}\right)}{\partial \alpha}
\delta^{l}=\delta^{l+1}\left\{\begin{array}{ll}{0} & {z^{l}>0} \\ {z^{l}} & {z^{l}<=0}\end{array}\right.
\delta^{l}=\left\{\begin{array}{ll}{0} & {z^{l}>0} \\ {\delta^{l+1} z^{l}} & {z^{l}<=0}\end{array}\right.

4.ELU:
f(z)=\left\{\begin{array}{ll}{z} & {z>0} \\ {\alpha(\exp (z)-1)} & {z \leq 0}\end{array}\right.
由LeakRelu可知损失函数L关于第l层的偏导为:
\delta^{l}=\left\{\begin{array}{ll}{\delta^{l+1}} & {z^{l}>0} \\ {\alpha \delta^{l+1} \exp \left(z^{l}\right)} & {z^{l}<=0}\end{array}\right.

5.SELU:
\operatorname{SELU}(z)=\lambda\left\{\begin{array}{ll}{z} & {z>0} \\ {\alpha(\exp (z)-1)} & {z<=0}\end{array}\right.
由ELU可知损失函数L关于第l层的偏导为:

\delta^{l}=\lambda\left\{\begin{array}{ll}{\delta^{l+1}} & {z^{l}>0} \\ {\alpha \delta^{l+1} \exp \left(z^{l}\right)} & {z^{l}<=0}\end{array}\right.

总结:当激活值的均值非0时,就会对下一层造成一个bias,如果激活值之间不会相互抵消(即均值非0),会导致下一层的激活单元有bias shift。如此叠加,单元越多时,bias shift就会越大。除了ReLU,其它激活函数都将输出的平均值接近0,从而加快模型收敛,类似于Batch Normalization的效果,但是计算复杂度更低。虽然LeakReLU和PReLU都也有负值,但是它们不保证在不激活状态下(就是在输入为负的状态下)对噪声鲁棒。反观ELU在输入取较小值时具有软饱和的特性,提升了对噪声的鲁棒性。

上一篇下一篇

猜你喜欢

热点阅读