torch.tanh

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

返回一个新张量,其中包含输入张量中每个元素的双曲正切值。

$\text{out}_{i} = \tanh(\text{input}_{i})$
参数

input (Tensor) – 需要输入的张量。

关键字参数

out (Tensor, 可选) – 指定输出张量。

示例:

>>> 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])
本页目录