mindspore.ops.tanhshrink

mindspore.ops.tanhshrink(input)[源代码]

Tanhshrink激活函数, \(Tanhshrink(x)=x-Tanh(x)\) ,其中 \(x\) 即输入 input

详情请查看 mindspore.nn.Tanhshrink

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore as ms
>>> from mindspore import ops
>>> from mindspore import Tensor
>>> import numpy as np
>>> input = Tensor(np.array([1, 2, 3, 2, 1]), ms.float16)
>>> output = ops.tanhshrink(input)
>>> print(output)
[0.2383 1.036  2.004  1.036  0.2383]