背景
在深度学习领域,激活函数的探索已成为独立研究课题。诸如 GELU、SELU 和 SiLU 等新型激活函数,因具备平滑梯度与出色的收敛特性,正备受关注。经典 ReLU 凭借简洁性、固有稀疏性及其独特优势拓扑特性,依旧受青睐。然而,ReLU 网络存在重大缺陷 ——“死亡 ReLU 问题”。一旦神经元在训练中输出恒为 0,其梯度也为 0,致使神经元无法恢复,制约网络效能。为应对这一问题,LeakyReLU、PReLU、GELU、SELU、SiLU/Swish 和 ELU 等改进函数涌现。它们通过引入负预激活值的非零激活,提供不同权衡。
近期,德国吕贝克大学等机构研究者提出新型方法 SUGAR(Surrogate Gradient for ReLU),在保留 ReLU 优势的同时解决其局限性。SUGAR 于前向传播使用标准 ReLU,反向传播时以非零、连续的替代梯度函数替换 ReLU 导数,使 ReLU 能保持原始前向行为,避免梯度消失,激活死神经元。基于此,研究者设计出两种新型替代梯度函数:B-SiLU(Bounded SiLU)和 NeLU(Negative slope Linear Unit),可无缝融入多种模型。
公式推导
-
论文标题: The Resurrection of the ReLU
-
论文链接:https://arxiv.org/pdf/2505.22074
FGI是一种分离前向和反向梯度的操作,一般可以设计成如下方程,前向是显而易见的,主要考虑反向梯度
y = g ( x ) − s g ( g ( x ) ) + s g ( f ( x ) ) ∂ y ∂ x = ∂ ∂ x ( g ( x ) − s g ( g ( x ) ) + s g ( f ( x ) ) ) = ∂ g ( x ) ∂ x − s g ( g ( x ) ) ∂ g ( x ) ∂ g ( x ) ∂ x + ∂ s g ( f ( x ) ) ∂ f ( x ) ∂ f ( x ) ∂ x = ∂ g ( x ) ∂ x y = g(x) − sg(g(x)) + sg(f(x)) \\ \frac{∂y}{∂x} = \frac{∂}{∂x}(g(x)-sg(g(x)) + sg(f(x))) \\ =\frac{∂g(x)}{∂x} - \frac{sg(g(x))}{∂g(x)}\frac{∂g(x)}{∂x} + \frac{∂sg(f(x))}{∂f(x)}\frac{∂f(x)}{∂x} \\ =\frac{∂g(x)}{∂x} y=g(x)−sg(g(x))+sg(f(x))∂x∂y=∂x∂(g(x)−sg(g(x))+sg(f(x)))=∂x∂g(x)−∂g(x)sg(g(x))∂x∂g(x)+∂f(x)∂sg(f(x))∂x∂f(x)=∂x∂g(x)
这样的方式有个缺陷,就是反向传播时依然需要对g(x)进行autodiff求导,效率低下,所以一般会直接提供g(x)的导数函数,以乘法的形式融入公式,根据这个思路可以设计如下方程
h = x ⋅ s g ( g ′ ( x ) ) y = h − s g ( h ) + s g ( f ( x ) ) ∂ y ∂ x = ∂ ∂ x ( h − s g ( h ) + s g ( f ( x ) ) ) = ∂ ∂ x ( x ∗ s g ( g ′ ( x ) ) ) − ∂ s g ( h ) ∂ h ∂ h ∂ x + s g ( f ( x ) ) ∂ f ( x ) f ( x ) x = ∂ g ( x ) ∂ x h = x · sg(g^{'}(x)) \\ y = h - sg(h) + sg(f(x)) \\ \frac{∂y}{∂x} = \frac{∂}{∂x}(h - sg(h) + sg(f(x))) \\ = \frac{∂}{∂x}(x * sg(g^{'}(x))) - \frac{∂sg(h)}{∂h}\frac{∂h}{∂x} + \frac{sg(f(x))}{∂f(x)} \frac{f(x)}{x} \\ = \frac{∂g(x)}{∂x} h=x⋅sg(g′(x))y=h−sg(h)+sg(f(x))∂x∂y=∂x∂(h−sg(h)+sg(f(x)))=∂x∂(x∗sg(g′(x)))−∂h∂sg(h)∂x∂h+∂f(x)sg(f(x))xf(x)=∂x∂g(x)
tensorflow2实现
class BSiLU_SUGAR(tf.keras.layers.Layer):
def __init__(self, alpha=1.67, **kwargs):
super(BSiLU_SUGAR, self).__init__(**kwargs)
self.alpha = alpha
def call(self, x, training=None, **kwargs):
fx = tf.nn.relu(x)
sigmoid_forward = tf.nn.sigmoid(x)
gx = sigmoid_forward + (x + self.alpha) * sigmoid_forward * (1 - sigmoid_forward)
m = x * tf.stop_gradient(gx)
y = m - tf.stop_gradient(m) + tf.stop_gradient(fx)
return y
def get_config(self):
config = {
'alpha': self.alpha
}
base_config = super(BSiLU_SUGAR, self).get_config()
return dict(list(base_config.items()) + list(config.items()))
真实数据实验效果
数据 | 模型 | loss | auc | uauc |
---|---|---|---|---|
自有数据 | mlp+relu | 0.0918 | 0.8242 | 0.735 |
自有数据 | mlp+新激活函数 | 0.0916 | 0.8260 | 0.737 |
结论
- 可能有一些效果,需要再其他数据集上进行更多测试得出综合结论
Reference
-
https://mp.weixin.qq.com/s/b29WfOloGFIyh-j8EfV96A
-
https://arxiv.org/pdf/2505.22074
-
https://arxiv.org/pdf/2406.00177v1