ML0029 Tanh

What are the advantages and disadvantages of using the tanh activation function?

Answer

In machine learning, the hyperbolic tangent (tanh) activation function is defined as
\mbox{tanh}(x) = \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
This function transforms input values into a range between -1 and 1, helping with faster convergence in neural networks.

Advantages:
(1) Zero-centered outputs: Unlike sigmoid, which outputs values between 0 and 1, tanh produces values between -1 and 1, making optimization easier and reducing bias in gradient updates.
(2) Smooth and Differentiable: The function is infinitely differentiable, supporting stable gradient‑based methods.

Disadvantages:
(1) Vanishing gradient problem: For very large or very small input values, the derivative of tanh approaches zero, leading to slow weight updates and potentially hindering deep network training.
(2) Computationally expensive: Compared to ReLU, tanh requires exponentially complex calculations, which may slow down model inference.


Login to view more content


Did you solve the problem?

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *