Softshrink¶
Softshrink激活层
Softshrink(x)={x−threshold,if x>thresholdx+threshold,if x<−threshold0,otherwise
其中,x 为输入的 Tensor
参数¶
threshold (float, 可选) - Softshrink激活计算公式中的threshold值,必须大于等于零。默认值为0.5。
name (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 Name。
形状:¶
input: 任意形状的Tensor。
output: 和input具有相同形状的Tensor。
代码示例¶
import paddle
import numpy as np
x = paddle.to_tensor(np.array([-0.9, -0.2, 0.1, 0.8]))
m = paddle.nn.Softshrink()
out = m(x) # [-0.4, 0, 0, 0.3]