Hyperbolic Tangent

The hyperbolic tangent (tanh) is a sigmoid function centered at the origin. It has a bounded output range of between -1 and 1.

tanh function

We can define tanh using the following equation:

tanh ( x ) = e x - e - x e x + e - x

The derivative of the tanh function is:

tanh ' ( x ) = 1 - tanh 2 ( x )

Computing the hyperbolic tangent in numpy

import numpy as np

print(f"tanh(0) = {np.tanh(0)}")
tanh(0) = 0.0

This page references the following sources:

Here are all the notes in this garden, along with their links, visualized as a graph.