Tanh#
- class brainpy.dnn.Tanh(name=None, mode=None)[source]#
Applies the Hyperbolic Tangent (Tanh) function element-wise.
Tanh is defined as:
\[\text{Tanh}(x) = \tanh(x) = \frac{\exp(x) - \exp(-x)} {\exp(x) + \exp(-x)}\]- Shape:
Input: \((*)\), where \(*\) means any number of dimensions.
Output: \((*)\), same shape as the input.
Examples:
>>> import brainpy as bp >>> import brainpy.math as bm >>> m = bp.dnn.Tanh() >>> input = bm.random.randn(2) >>> output = m(input)