softshrink¶
softshrink 激活层
softshrink(x)={x−threshold,if x>thresholdx+threshold,if x<−threshold0,otherwise
其中,x 为输入的 Tensor
返回¶
Tensor
,数据类型和形状同x
一致。
代码示例¶
import paddle
import paddle.nn.functional as F
x = paddle.to_tensor([-0.9, -0.2, 0.1, 0.8])
out = F.softshrink(x)
print(out)
# Tensor(shape=[4], dtype=float32, place=Place(gpu:0), stop_gradient=True,
# [-0.39999998, 0. , 0. , 0.30000001])