Md. Asif Uddin
    I.3.X01

    Sigmoid and tanh, and the identity between them

    numeric▲△△

    Compute σ(z)\sigma(z), tanh⁡(z)\tanh(z), σ′(z)\sigma'(z) and tanh⁡′(z)\tanh'(z) at z∈{−1,0,1.5}z \in \{-1, 0, 1.5\}. Verify tanh⁡(z)=2σ(2z)−1\tanh(z) = 2\sigma(2z)-1 at each point, and state the ratio tanh⁡′/σ′\tanh'/\sigma' at z=0z=0.

    Hint

    Compute σ\sigma first and get everything else from it.

    Solution
    zzσ\sigmatanh⁡\tanh2σ(2z)−12\sigma(2z)-1σ′\sigma'tanh⁡′\tanh'
    −1.0-1.00.26890.2689−0.7616-0.7616−0.7616-0.76160.19660.19660.42000.4200
    0.00.00.50000.50000.00000.00000.00000.00000.25000.25001.00001.0000
    1.51.50.81760.81760.90510.90510.90510.90510.14910.14910.18070.1807

    Working at z=−1z = -1. σ(−1)=1/(1+e)=1/3.7183=0.2689\sigma(-1) = 1/(1+e) = 1/3.7183 = 0.2689. Then σ′=(0.2689)(0.7311)=0.1966\sigma' = (0.2689)(0.7311) = 0.1966. For tanh use the identity: 2σ(−2)−1=2(0.1192)−1=−0.76162\sigma(-2) - 1 = 2(0.1192) - 1 = -0.7616, and tanh⁡′=1−(−0.7616)2=1−0.5800=0.4200\tanh' = 1 - (-0.7616)^2 = 1 - 0.5800 = 0.4200.

    The identity holds to every printed digit at all three points, which is what an exact identity should do.

    The ratio at z=0z = 0. tanh⁡′(0)/σ′(0)=1.0000/0.2500=4\tanh'(0)/\sigma'(0) = 1.0000/0.2500 = \mathbf{4}.

    Why that four matters. Over LL layers the gradient is multiplied by one derivative per layer, so at their best points a tanh stack passes 4L4^{L} times more gradient than a sigmoid stack. At L=10L = 10 that is a factor of about a million. It is the entire quantitative content of the historical preference for tanh over sigmoid in hidden layers, and I.3.B02 showed it follows from the identity by the chain rule: tanh⁡′(z)=4σ′(2z)\tanh'(z) = 4\sigma'(2z).

    But notice the third row. At z=1.5z = 1.5 the two derivatives are 0.14910.1491 and 0.18070.1807 — a ratio of 1.211.21, not 44. The advantage is largest at the origin and shrinks as either function saturates. Tanh delays the problem; it does not solve it, which is why Chapter I.8 exists.

    Draws on