torch.tanh

torch.tanh(input, *, out=None) → Tensor

Returns a new tensor with the hyperbolic tangent of the elements of input.

outi=tanh(inputi)\text{out}_{i} = \tanh(\text{input}_{i})
Parameters

input (Tensor) – the input tensor.

Keyword Arguments

out (Tensor, optional) – the output tensor.

Example:

>>> a = torch.randn(4)
>>> a
tensor([ 0.8986, -0.7279,  1.1745,  0.2611])
>>> torch.tanh(a)
tensor([ 0.7156, -0.6218,  0.8257,  0.2553])

© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.tanh.html