liveBook · Manning

Tanh

The hyperbolic tangent, or tanh, is a smooth nonlinear function that maps real-valued inputs to values between −1 and 1.

How 4 Manning books explain it

Grokking Machine Learning

A smooth S-shaped activation function that maps real-valued inputs to values between negative one and one.

How it is used
Uses tanh as a neural-network activation function that squishes values and helps construct nonlinear decision boundaries.
How deep it goes
Explains tanh’s output range, shape, sigmoid comparison, and vanishing-gradient limitation without deriving its formula.
Examples
Compares tanh visually with sigmoid and ReLU in a three-function activation plot.
What you can do after
Evaluate tanh against sigmoid and ReLU when selecting activation functions for neural-network training.

Read how Grokking Machine Learning explains tanh →

Optimization Algorithms: AI techniques for design, planning, and control problems

The hyperbolic tangent is an activation function that maps real-valued inputs to the interval from -1 to 1.

How it is used
Uses tanh as the hidden-layer activation in a neural network trained for classification with particle swarm optimization.
How deep it goes
Defines tanh and demonstrates its NumPy placement in forward propagation, but does not derive its mathematical formula or training gradients.
Examples
Demonstrates tanh on the hidden layer of a NumPy classifier using the Penguins dataset.
What you can do after
Apply it via NumPy when implementing a neural-network hidden layer and inspect its effect within forward propagation.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains tanh →

Inside Deep Learning: Math, Algorithms, Models

A nonlinear activation function that maps real-valued inputs into the interval [-1,1].

How it is used
Uses tanh between linear operations to add nonlinear modeling capacity and in LSTMs to support bounded gating computations.
How deep it goes
Defines the output range, explains nonlinear placement and saturation, and demonstrates PyTorch usage without deriving tanh internals.
Examples
Demonstrates activation curves, a two-layer PyTorch network, LSTM gates, and an additive-attention replacement exercise.
What you can do after
Apply it via PyTorch's nn.Tanh in hidden layers and recognize saturation-related gradient risks.

Read how Inside Deep Learning: Math, Algorithms, Models explains tanh →

Math and Architectures of Deep Learning

A hyperbolic tangent activation function used to introduce nonlinearity in neural networks.

How it is used
Introduces nonlinearity in neural networks and supports gradient-based training when inputs are centered around zero.
How deep it goes
Defines the output range and explains gradient behavior near zero, but stops short of implementation details or a derivative formula.
Examples
Uses derivative comparison graphs and LeNet's tanh layers after convolutional feature maps.
What you can do after
Evaluate/understand how centered outputs and stronger near-zero gradients make tanh useful as a neural-network activation.

Read how Math and Architectures of Deep Learning explains tanh →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.