tanhshrink¶
tanhshrink 激活层
\[tanhshrink(x) = x - tanh(x)\]
其中,\(x\) 为输入的 Tensor。
返回¶
Tensor
,数据类型和形状同x
一致。
代码示例¶
>>> import paddle
>>> import paddle.nn.functional as F
>>> x = paddle.to_tensor([-0.4, -0.2, 0.1, 0.3])
>>> out = F.tanhshrink(x)
>>> print(out)
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.02005100, -0.00262472, 0.00033201, 0.00868741])