Functions and operators

tanh⁡(x)\tanh(x) Hyperbolic tangent

An S-shaped activation squashing any number into (−1, 1).

In ML papers

tanh⁡(x)=ex−e−xex+e−x\tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}} squashes inputs into (−1,1)(-1, 1), centred on 0. RNNs and LSTMs use it for their hidden-state updates. It is a rescaled sigmoid: tanh⁡(x)=2σ(2x)−1\tanh(x) = 2\sigma(2x) - 1.

How to type it

LaTeXShows
\tanhtanh⁡\tanh

A worked example

tanh⁡(0)=0,tanh⁡(1)≈0.76,tanh⁡(−3)≈−0.995\tanh(0) = 0, \quad \tanh(1) \approx 0.76, \quad \tanh(-3) \approx -0.995

Equations that use it

Related

σ(z)\sigma(z)Sigma (lowercase)ReLU⁡(x)=max⁡(0,x)\operatorname{ReLU}(x) = \max(0, x)ReLUex=exp⁡(x)e^{x} = \exp(x)Exponential

Decode this example →