Tanh Function Calculator

Evaluate Tanh activations, gradients, saturation, vectors, batches, and ranges while comparing Sigmoid and ReLU through detailed steps, charts, and exportable results instantly for learning.

Calculator Inputs

Choose a scalar, matrix, or generated range. Optional scaling adjusts every value before activation.

Applied before Tanh calculation.
Added after scaling.
Marks outputs near -1 or 1.
Flags possible vanishing gradients.
Use commas or spaces. Start new rows with semicolons or line breaks.

Formula Used

Tanh activation: tanh(x) = (ex - e-x) ÷ (ex + e-x)

Stable equivalent: tanh(x) = 2 ÷ (1 + e-2x) - 1

Derivative: tanh′(x) = 1 - tanh²(x)

Tanh maps every finite input between negative one and one. Its derivative peaks at zero and shrinks near saturation.

How to Use

  1. Select a single, matrix, or generated range mode.
  2. Enter values and optional scale or offset settings.
  3. Choose precision, thresholds, and graph limits.
  4. Press Calculate Tanh to view outputs and gradients.
  5. Copy, print, or export the completed results.

Example Data

These values demonstrate negative, central, and positive activation behaviour. Large magnitudes show how Tanh approaches saturation.

x Approximate tanh(x) Approximate derivative Interpretation
-5-0.9999090.000182Negative saturation
-2-0.9640280.070651Strong negative activation
-1-0.7615940.419974Negative active region
00.0000001.000000Maximum gradient
10.7615940.419974Positive active region
20.9640280.070651Strong positive activation
50.9999090.000182Positive saturation

Machine Learning Interpretation

Tanh is zero-centred, unlike the standard Sigmoid activation. This often gives balanced positive and negative hidden outputs.

Large inputs create saturation and very small derivatives. Deep networks may then experience slower gradient-based learning.

ReLU avoids positive-side saturation but discards negative outputs. Tanh remains useful for recurrent states and bounded signals.

Frequently Asked Questions

What does the Tanh function return?

It returns a smooth value between negative one and one. Zero input produces exactly zero output.

Why is Tanh called zero-centred?

Its outputs can be negative, zero, or positive. This differs from standard Sigmoid outputs.

What is the Tanh derivative?

The derivative equals one minus the squared Tanh output. It reaches one when x equals zero.

When does Tanh saturate?

Saturation occurs when outputs approach negative one or positive one. The threshold is adjustable here.

Can this calculator process matrices?

Yes, it calculates every matrix value element by element. Rows may use line breaks or semicolons.

How does Tanh compare with Sigmoid?

Both functions saturate and remain smooth. Tanh produces zero-centred outputs from negative one to one.

How does Tanh compare with ReLU?

ReLU is unbounded for positive inputs. Tanh is bounded and preserves negative activation values.

Why do gradients become small?

The Tanh curve flattens at large input magnitudes. Flat regions have derivatives approaching zero.

Can extreme values cause overflow?

The calculator uses stable built-in Tanh computation. Exponential details display safe infinity notation when needed.

Related Calculators

Neural Network Parameter CalculatorActivation Function CalculatorReLU Function CalculatorNeural Network Weighted Sum CalculatorForward Propagation CalculatorBackpropagation Gradient CalculatorLearning Rate CalculatorEpoch and Iteration CalculatorDropout CalculatorWeight Initialization Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.