mindspore.ops.tanhshrink

mindspore.ops.tanhshrink(input)[source]

Compute the Tanhshrink activation function of the input tensor element-wise.

\[Tanhshrink(x) = x - anh(x)\]
Parameters:

input (Tensor) – The input tensor.

Returns:

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> output = mindspore.ops.tanhshrink(mindspore.tensor([1., 2., 3., 2., 1.]))
>>> print(output)
[0.23840582 1.0359724  2.0049443  1.0359724  0.23840582]