一个节点的激活函数(Activation Function)定义了该节点在给定的输入或输入的集合下的输出。神经网络中的激活函数用来提升网络的非线性(只有非线性的激活函数才允许网络计算非平凡问题),以增强网络的表征能力。对激活函数的一般要求是:必须非常数、有界、单调递增并且连续,并且可导。
在实际选择激活函数时并不会严格要求可导,只需要激活函数几乎在所有点可导即可,即在个别点不可导是可以接受的。另外,其导数尽可能的大可以帮助加速训练神经网络,否则导数过小会导致网络无法继续训练下去。
下面是不同的激活函数的函数公式,图像和导数公式,图像。
f ( x ) = x f ′ ( x ) = 1 f(x)=x \qquad\qquad\qquad f^{'}(x)=1 f(x)=xf′(x)=1
f ( x ) = { 0 , x < 0 1 , x ≥ 0 f ′ ( x ) = { 0 , x ≠ 0 ? , x = 0 f(x)=\left\{\begin{array} {ll} 0,x < 0\\1,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array} {ll} 0,x \ne 0\\?,x= 0 \end{array}\right. f(x)={0,x<01,x≥0f′(x)={0,x=0?,x=0
f ( x ) = σ ( x ) = 1 1 + e − x f ′ ( x ) = f ( x ) ( 1 − f ( x ) ) f(x)=\sigma(x)=\frac{1}{1+e^{-x}}\qquad\qquad f^{'}(x)=f(x)(1-f(x)) f(x)=σ(x)=1+e−x1f′(x)=f(x)(1−f(x))
f ( x ) = t a n h ( x ) = ( e x − e − x ) e x + e − x f ′ ( x ) = 1 − f ( x ) 2 f(x)=tanh(x)=\frac{(e^x-e^{-x})}{e^x+e^{-x}}\qquad \qquad f^{'}(x)=1-f(x)^2 f(x)=tanh(x)=ex+e−x(ex−e−x)f′(x)=1−f(x)2
f ( x ) = t a n − 1 ( x ) f ′ ( x ) = 1 x 2 + 1 f(x)=tan^{-1}(x)\qquad\qquad f^{'}(x)=\frac{1}{x^2+1} f(x)=tan−1(x)f′(x)=x2+11
f ( x ) = x 1 + ∣ x ∣ f ′ ( x ) = 1 ( 1 + ∣ x ∣ ) 2 f(x)=\frac{x}{1+|x|}\qquad\qquad f^{'}(x)=\frac{1}{(1+|x|)^2} f(x)=1+∣x∣xf′(x)=(1+∣x∣)21
f ( x ) = x 1 + α x 2 f ′ ( x ) = ( 1 1 + α x 2 ) 3 f(x)=\frac{x}{\sqrt{1+\alpha x^2}}\qquad \qquad f^{'}(x)=(\frac{1}{\sqrt{1+\alpha x^2}})^3 f(x)=1+αx2xf′(x)=(1+αx21)3
f ( x ) = { 0 , x < 0 x , x ≥ 0 f ′ ( x ) = { 0 , x < 0 1 , x ≥ 0 f(x)= \left\{\begin{array}{ll}0,x<0\\x,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array}{ll}0,x<0\\1,x\ge 0 \end{array}\right. f(x)={0,x<0x,x≥0f′(x)={0,x<01,x≥0
f ( x ) = { 0.01 x , x < 0 x , x ≥ 0 f ′ ( x ) = { 0.01 , x < 0 1 , x ≥ 0 f(x)= \left\{\begin{array}{ll}0.01x,x<0\\x,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array}{ll}0.01,x<0\\1,x\ge 0 \end{array}\right. f(x)={0.01x,x<0x,x≥0f′(x)={0.01,x<01,x≥0
f ( x ) = { α x , x < 0 x , x ≥ 0 f ′ ( x ) = { α , x < 0 1 , x ≥ 0 f(x)= \left\{\begin{array}{ll}\alpha x,x<0\\x,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array}{ll}\alpha,x<0\\1,x\ge 0 \end{array}\right. f(x)={αx,x<0x,x≥0f′(x)={α,x<01,x≥0
f ( x ) = { α x , x < 0 x , x ≥ 0 f ′ ( x ) = { α , x < 0 1 , x ≥ 0 f(x)= \left\{\begin{array}{ll}\alpha x,x<0\\x,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array}{ll}\alpha,x<0\\1,x\ge 0 \end{array}\right. f(x)={αx,x<0x,x≥0f′(x)={α,x<01,x≥0
f ( x ) = { α ( e x − 1 ) , x < 0 x , x ≥ 0 f ′ ( x ) = { f ( α , x ) + α , x < 0 1 , x ≥ 0 f(x)= \left\{\begin{array}{ll}\alpha(e^x-1),x<0\\x,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array}{ll}f(\alpha,x)+\alpha,x<0\\1,x\ge 0 \end{array}\right. f(x)={α(ex−1),x<0x,x≥0f′(x)={f(α,x)+α,x<01,x≥0
f ( x ) = λ { α ( e x − 1 ) , x < 0 x , x ≥ 0 λ = 1.0507 , α = 1.67326 f ′ ( x ) = λ { α ( e x ) , x < 0 1 , x ≥ 0 \begin{aligned} f(x)=\lambda \left\{\begin{array}{ll}\alpha(e^x-1),x<0\\x,x\ge 0 \end{array}\right. \\ \lambda=1.0507,\alpha=1.67326 \end{aligned} \qquad\qquad f^{'}(x)=\lambda \left\{\begin{array}{ll}\alpha(e^x),x<0\\1,x\ge 0 \end{array}\right. f(x)=λ{α(ex−1),x<0x,x≥0λ=1.0507,α=1.67326f′(x)=λ{α(ex),x<01,x≥0
f t l , a l , t r , a r ( x ) = { t l + a l ( x − t l ) , x ≤ t l x , t l < x < t r t r + a r ( x − t r ) , x ≥ t r t l , a l , t r , a r 为 参 数 f t l , a l , t r , a r ′ ( x ) = { a l , x ≤ t l 1 , t l < x < t r a r , x ≥ t r \begin{aligned} f_{t_l,a_l,t_r,a_r}(x)=\left\{\begin{array} {ll} t_l+a_l(x-t_l),x\le t_l\\ x,t_l
f ( x ) = { x 1 + α x 2 , x < 0 x , x ≥ 0 f ′ ( x ) = { ( 1 1 + α x 2 ) 3 , x < 0 1 , x ≥ 0 f(x)= \left\{\begin{array}{ll}\frac{x}{\sqrt{1+\alpha x^2}},x<0\\x,x\ge 0 \end{array}\right.\qquad\qquad f^{'}(x)=\left\{\begin{array}{ll}(\frac{1}{\sqrt{1+\alpha x^2}})^3,x<0\\1,x\ge 0 \end{array}\right. f(x)={1+αx2x,x<0x,x≥0f′(x)={(1+αx21)3,x<01,x≥0
f ( x ) = m a x ( 0 , x ) + ∑ s = 1 S a i s m a x ( 0 , − x + b i s ) f ′ ( x ) = H ( x ) − ∑ s = 1 S a i s H ( − x + b i s ) f(x)=max(0,x)+\sum_{s=1}^{S}a^s_{i}max(0,-x+b^s_i)\qquad\qquad f^{'}(x)=H(x)-\sum^{S}_{s=1}a^s_iH(-x+b^s_i) f(x)=max(0,x)+s=1∑Saismax(0,−x+bis)f′(x)=H(x)−s=1∑SaisH(−x+bis)
f ( x ) = ln ( 1 + e x ) f ′ ( x ) = e x 1 + e x f(x)=\ln(1+e^x) \qquad\qquad f^{'}(x)=\frac{e^x}{1+e^x} f(x)=ln(1+ex)f′(x)=1+exex
f ( x ) = x 2 + 1 − 1 2 + x f ′ ( x ) = x 2 x 2 + 1 + 1 f(x)=\frac{\sqrt{x^2+1}-1}{2}+x\qquad\qquad f^{'}(x)=\frac{x}{2\sqrt{x^2+1}}+1 f(x)=2x2+1−1+xf′(x)=2x2+1x+1
f ( x ) = x ⋅ σ ( x ) f ′ ( x ) = f ( x ) + σ ( x ) ( 1 − f ( x ) ) f(x)=x\cdot \sigma(x) \qquad\qquad f^{'}(x)=f(x)+\sigma(x)(1-f(x)) f(x)=x⋅σ(x)f′(x)=f(x)+σ(x)(1−f(x))
f ( x ) = { − l n ( 1 − α ( x + α ) ) α , α < 0 x , α = 0 e α x − 1 α , α > 0 f ′ ( x ) = { 1 1 − α ( α + x ) , α < 0 e α x , α ≥ 0 f(x)= \left\{\begin{array} {ll} -\frac{ln(1-\alpha(x+\alpha))}{\alpha}, \alpha < 0\\ x,\alpha=0\\ \frac{e^{\alpha x}-1}{\alpha},\alpha >0 \end{array}\right. \qquad\qquad f^{'}(x)=\left\{\begin{array} {ll} \frac{1}{1-\alpha(\alpha+x)},\alpha < 0\\ e^{\alpha x},\alpha \ge 0 \end{array}\right. f(x)=⎩⎨⎧−αln(1−α(x+α)),α<0x,α=0αeαx−1,α>0f′(x)={1−α(α+x)1,α<0eαx,α≥0
f ( x ) = s i n ( x ) f ′ ( x ) = c o s ( x ) f(x)= sin(x)\qquad\qquad f^{'}(x)=cos(x) f(x)=sin(x)f′(x)=cos(x)
f ( x ) = { 1 , x = 0 s i n ( x ) x , x ≠ 0 f ( x ) = { 0 , x = 0 c o s ( x ) x − s i n ( x ) x , x ≠ 0 f(x)=\left\{\begin{array} {ll} 1,x=0 \\ \frac{sin(x)}{x},x\ne 0 \end{array}\right.\qquad \qquad f(x)=\left\{\begin{array} {ll} 0,x=0 \\ \frac{cos(x)}{x}-\frac{sin(x)}{x},x\ne 0 \end{array}\right. f(x)={1,x=0xsin(x),x=0f(x)={0,x=0xcos(x)−xsin(x),x=0
f ( x ) = e − x 2 f ′ ( x ) = − 2 x e − x 2 f(x)=e^{-x^2} \qquad\qquad f^{'}(x)=-2xe^{-x^2} f(x)=e−x2f′(x)=−2xe−x2