pymc.math.tanh#
- pymc.math.tanh = Elemwise(scalar_op=tanh,inplace_pattern=<frozendict {}>)[source]#
hyperbolic tangent of a
Computes element-wise hyperbolic tangent of a tensor.
- Parameters:
- a
TensorLike
Input tensor
- a
- Returns:
TensorVariable
Output tensor with the hyperbolic tangent of each element, with values in the range [-1, 1]
Notes
This function corresponds to NumPy’s np.tanh function. The hyperbolic tangent is defined as: tanh(x) = sinh(x)/cosh(x)
Examples
>>> import pytensor >>> import pytensor.tensor as pt >>> x = pt.vector("x") >>> f = pytensor.function([x], pt.tanh(x)) >>> f([-1, 0, 1]) array([-0.76159416, 0. , 0.76159416])