tanh, or the hyperbolic tangent, is a smooth S-shaped activation function that squishes any real-valued input into the interval from −1 to 1. In a neural network, it helps transform layer outputs so the model can build more complex decision boundaries. section 10.2 section 10.6
tanh is useful, but it has important trade-offs:
- It is less flat than sigmoid, so it often works better in practice. section 10.2
- It still has flat regions and can contribute to the vanishing-gradient problem during training. section 10.2 section 10.6
- It contrasts with ReLU, which turns negative inputs into zero and is used more widely to reduce vanishing gradients. section 10.2
Compare activation-function shapes
Visualize sigmoid, tanh, and ReLU side by side: tanh occupies the middle position, showing its S-shaped curve and output range between −1 and 1.



