# 激活函数

[函数图像](https://www.desmos.com/calculator/iriqusvnem)

![](https://3528240873-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhkWhCiW-a4eAtmKiFj%2F-LhkWlG5DoSqZhA-P_5x%2F-LhkWqwQYgfowjt_1xd6%2Fb7ox4yzozj.png?generation=1560961053875720\&alt=media)

* 红色：ReLU
* 蓝色：Tanh
* 绿色：Sigmoid
* 紫色：Linear

### ReLU（Rectified Linear Unit）

此激活函数广泛应用于各种深度学习网络中。

$$\displaystyle{f(x) = \begin{cases} x & x > 0 \ 0 & x \leqslant 0 \end{cases}}$$

$$\displaystyle{f'(x) = \begin{cases} 1 & x > 0 \ 0 & x \leqslant 0 \end{cases}}$$

### S形函数（Sigmoid）

此激活函数早期广泛应用于神经网络中，但是由于梯度饱和问题，超过三层时误差就无法传到最初的层了，因此在深度学习中效果不如ReLU。

$$\displaystyle{f(x) = \frac{1}{1+e^{-x}}}$$

$$\displaystyle{f'(x) = f(x)(1-f(x))}$$

### 双曲正切函数（Hyperbolic tangent）

双曲正切函数简称Tanh函数，类似于Sigmoid函数，不过函数值范围是－1\~1。

$$\displaystyle{f(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}}$$

$$\displaystyle{f'(x) = 1-f^2(x)}$$

## 线性（Linear）

线性相当于没有激活函数，每层之间直接进行矩阵乘法，无法学习非线性数据。

$$\displaystyle{f(x)=x}$$

$$\displaystyle{f'(x)=1}$$
