Open Agent School · Public worked example
Tanh: meaning and example
Welcome! Take one idea with you today.
Tanh is a smooth function that maps finite real inputs into values strictly between -1 and 1. Negative inputs remain negative, zero remains zero, and positive inputs remain positive.
Picture it: In a synthetic feedback model, negative scores oppose a proposed action and positive scores support it. Tanh maps a zero score to 0 and a score of 1 to about 0.762, keeping the sign while limiting the size.
What is easy to mix up?
Tanh ranges from -1 to 1; logistic sigmoid ranges from 0 to 1. Neither reaches its limiting endpoints for finite real inputs in exact arithmetic.
Teaching example by Open Agent School. Source: Dive into Deep Learning: Multilayer Perceptrons.