赞
踩
若
f
(
x
)
=
1
x
f(x)=\frac{1}{x}
f(x)=x1,则
f
′
(
x
)
=
−
1
x
2
f'(x)=- \frac{1}{x^2}
f′(x)=−x21
若
g
(
x
)
=
e
x
g(x)=e^x
g(x)=ex,则
g
′
(
x
)
=
e
x
g'(x)=e^x
g′(x)=ex
Sigmoid函数:
f
(
x
)
=
1
1
+
e
−
x
f(x)= \frac{1}{1+e^{-x}}
f(x)=1+e−x1
Sigmoid函数的导数:
f
′
(
x
)
=
f
(
x
)
(
1
−
f
(
x
)
)
f'(x)=f(x)(1-f(x))
f′(x)=f(x)(1−f(x))
首先,对
f
(
x
)
f(x)
f(x)进行变形:
f
(
x
)
=
1
1
+
e
−
x
=
1
1
+
1
e
x
=
(
1
+
1
e
x
)
−
1
=
(
e
x
e
x
+
1
e
x
)
−
1
=
(
e
x
+
1
e
x
)
−
1
=
e
x
e
x
+
1
=
(
e
x
+
1
)
−
1
e
x
+
1
=
e
x
+
1
e
x
+
1
−
1
e
x
+
1
=
1
−
1
e
x
+
1
=
1
−
(
e
x
+
1
)
−
1
求导:
注意使用链式法则求导
f
′
(
x
)
=
(
1
−
(
e
x
+
1
)
−
1
)
′
=
(
−
1
)
(
−
1
)
(
e
x
+
1
)
−
2
e
x
=
(
e
x
+
1
)
−
2
e
x
=
(
e
x
+
1
)
−
1
(
e
x
+
1
)
−
1
e
x
由前面提到的
f
(
x
)
f(x)
f(x)的变形可知:
f
(
x
)
=
1
1
+
e
−
x
=
(
1
+
e
−
x
)
−
1
=
e
x
e
x
+
1
=
e
x
(
e
x
+
1
)
−
1
所以:
f
′
(
x
)
=
(
e
x
+
1
)
−
1
⋅
(
e
x
+
1
)
−
1
e
x
=
(
e
x
+
1
)
−
1
⋅
e
x
(
e
x
+
1
)
−
1
=
(
e
x
+
1
)
−
1
⋅
(
1
+
e
−
x
)
−
1
=
1
e
x
+
1
⋅
1
1
+
e
−
x
=
(
e
x
+
1
)
−
e
x
e
x
+
1
⋅
1
1
+
e
−
x
=
(
e
x
+
1
e
x
+
1
−
e
x
e
x
+
1
)
⋅
1
1
+
e
−
x
=
(
1
−
e
x
e
x
+
1
)
⋅
1
1
+
e
−
x
=
(
1
−
1
1
+
e
−
x
)
⋅
1
1
+
e
−
x
=
(
1
−
f
(
x
)
)
⋅
f
(
x
)
=
f
(
x
)
(
1
−
f
(
x
)
)
Sigmoid 函数的数学表达式为:
σ ( x ) = 1 1 + e − x \sigma(x) = \frac{1}{1 + e^{-x}} σ(x)=1+e−x1
我们要对其进行导数,通常会用到链式法则,也就是内导数乘以外导数。计算过程如下:
首先,令内部函数为:
u
=
1
+
e
−
x
u = 1 + e^{-x}
u=1+e−x
则 Sigmoid 函数可以表示为外部函数:
σ
(
x
)
=
u
−
1
\sigma(x) = u^{-1}
σ(x)=u−1
接着我们计算这两个函数的导数:
若 g ( x ) = e − x g(x)=e^{-x} g(x)=e−x,则有链式法则可得 g ′ ( x ) = − e − x g'(x)=-e^{-x} g′(x)=−e−x
现在,根据链式法则,找到 Sigmoid 函数关于
x
x
x 的导数:
d
σ
d
x
=
d
σ
d
u
⋅
d
u
d
x
\frac{d\sigma}{dx} = \frac{d\sigma}{du} \cdot \frac{du}{dx}
dxdσ=dudσ⋅dxdu
d
σ
d
x
=
−
1
u
2
⋅
(
−
e
−
x
)
\frac{d\sigma}{dx} = -\frac{1}{u^2} \cdot (-e^{-x})
dxdσ=−u21⋅(−e−x)
d
σ
d
x
=
e
−
x
(
1
+
e
−
x
)
2
\frac{d\sigma}{dx} = \frac{e^{-x}}{(1 + e^{-x})^2}
dxdσ=(1+e−x)2e−x
使用 Sigmoid 函数的原始定义和上面的导数结果,我们可以将导数简化为 Sigmoid 函数的形式:
d
σ
d
x
=
1
1
+
e
−
x
(
1
−
1
1
+
e
−
x
)
\frac{d\sigma}{dx} = \frac{1}{1 + e^{-x}} \left(1 - \frac{1}{1 + e^{-x}}\right)
dxdσ=1+e−x1(1−1+e−x1)
d
σ
d
x
=
σ
(
x
)
(
1
−
σ
(
x
)
)
\frac{d\sigma}{dx} = \sigma(x)(1 - \sigma(x))
dxdσ=σ(x)(1−σ(x))
所以最终得到的 Sigmoid 函数关于 x x x 的导数是:
d σ d x = σ ( x ) ( 1 − σ ( x ) ) \frac{d\sigma}{dx} = \sigma(x)(1 - \sigma(x)) dxdσ=σ(x)(1−σ(x))
这就是 Sigmoid 函数的导数,可以直接用于梯度计算和其他数学运算中。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。