keisoku

Tanh Activation Function Calculator

Compute the hyperbolic tangent tanh(x) with its first and second derivatives, the related sigmoid value, and a curve plot.

Input

Enter x to compute tanh(x) along with its first and second derivatives.

Enter any real number.

Result

tanh(1)

0.761594156

1st derivative 1-tanh^2

0.4199743416

2nd derivative

-0.6397000084

Related sigmoid value

0.880797078

Input x

1

Graph of tanh(x)

How it works

  • tanh(x) is the hyperbolic tangent, defined as tanh(x) = (e^x - e^(-x)) / (e^x + e^(-x)). It is an odd function with a range from -1 to 1 passing through the origin.
  • The first derivative is d/dx tanh(x) = 1 - tanh(x)^2. It reaches a maximum of 1 at x=0 and approaches 0 as |x| grows, which contributes to the vanishing gradient problem.
  • The second derivative is d2/dx2 tanh(x) = -2 tanh(x) (1 - tanh(x)^2). It is 0 at x=0, where the curve has an inflection point.
  • tanh relates to the sigmoid by tanh(x) = 2 sigmoid(2x) - 1. This tool also shows (tanh(x)+1)/2 as the related sigmoid value.
  • As a neural network activation, tanh centers outputs around 0, which often makes training more stable than the sigmoid.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Tanh Activation Function Calculator