Machine Learning & AI
Basic

Tanh Activation

Squashes input to the range (-1, 1); zero-centred activation.

Formula

tanh(x)=exexex+ex\tanh(x) = \dfrac{e^{x}-e^{-x}}{e^{x}+e^{-x}}

Variables

xInput value

Example

tanh(0)=0, tanh(2)=0.964

Did You Know?

Because tanh is zero-centred it often trained early networks better than the sigmoid.

Share this formula