tanh

Contents

tanh#

class brainstate.nn.tanh(x)[source]#

Hyperbolic tangent activation function.

Computes the element-wise function:

\[\mathrm{tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}\]
Parameters:

x (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Input array.

Returns:

An array with the same shape as the input.

Return type:

Array | Quantity