激活函数-Tanh ############# * 双曲正切函数 * 特点:将输入的实数映射到 (-1, 1) 范围内,可以提供比 Sigmoid 更强的非线性性质,常用于隐藏层。 * 公式: .. math:: \text{tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}} \\ => \\ \text{tanh}(x) = \frac{1-exp(-2x)}{1+exp(-2x)} .. figure:: https://img.zhaoweiguo.com/uPic/2024/12/0bm8eP.png tanh 函数的导数为: .. math:: \frac{d}{dx} tanh(x) = 1 - tanh^2(x) .. figure:: https://img.zhaoweiguo.com/uPic/2024/12/kSLAc1.png 当输入接近 0 时,tanh 函数的导数接近最大值 1。同 sigmoid 函数一样,当输入在任一方向上远离 0 时,tanh 函数的导数接近 0。