2021年6月28日 / 151次阅读 / Last Modified 2021年6月28日
神经网络
开始转移云上小悟上关于神经网络的笔记到这里,这一篇关于ReLU神经元激活函数。
貌似ReLU神经元激活函数是在2011左右出现的,著名的AlexNet就使用了它。ReLU神经元激活函数的出现,同样也是来自生物神经科学领域的启发。它给神经网络技术带来的好处是:
ReLU的数学公式看这里:神经元激活函数。
不过,ReLU函数也有“弱点”,就是它可能会在训练的过程中死掉(Dead ReLU)。
Referring to the Stanford course notes on Convolutional Neural Networks for Visual Recognition, a paragraph says:
"Unfortunately, ReLU units can be fragile during training and can "die". For example, a large gradient flowing through a ReLU neuron could cause the weights to update in such a way that the neuron will never activate on any data point again. If this happens, then the gradient flowing through the unit will forever be zero from that point on. That is, the ReLU units can irreversibly die during training since they can get knocked off the data manifold. For example, you may find that as much as 40% of your network can be "dead" (i.e. neurons that never activate across the entire training dataset) if the learning rate is set too high. With a proper setting of the learning rate this is less frequently an issue."
有可能出现,在某一次weight和bias更新之后,这个ReLU神经元对于所有的data point input,输出都是0,这是我们就说这个ReLU死掉了。
死掉的ReLU是不可逆的,即它无法再“正常”地活过来,因为对于所有的input,它的输出都是0,这时按照BP算法规则,它的weight和bias无法得到更新。
上面这段英文也说明了另外一个事实:Learning Rate不要设置太大,一部分ReLU在训练过程中死掉,也不是个什么问题,这正好也符合科学家在生物精神领域发现的神经元的稀疏性保持一致。
Learning Rate设置过大,确实是个问题。可以让ReLU彻底死掉,也可能出现overshooting现象,即cost不断变大。
注意一个算法细节:我们在训练神经网络的时候,一般采用SGD算法,即小批量地更新weights和bias,每一次更新weights和bias前,都会将一组input数据的梯度进行算术平均,可能有些ReLU对某个input输出0,但是对其它的input输出就不是0,这样计算平均,梯度为非0,其对应的weights和bias依然可以得到更新。
那些死掉的ReLU,是对所有input的输出都是0的顽固份子。有人说,这其实又是另外一种“梯度消失”。
-- EOF --
本文链接:https://www.pynote.net/archives/3737
©Copyright 麦新杰 Since 2019 Python笔记