softshrink¶
- paddle.nn.functional. softshrink ( x: Tensor, threshold: float = 0.5, name: str | None = None ) Tensor [source]
-
softshrink activation
softshrink(x)={x−threshold,if x>thresholdx+threshold,if x<−threshold0,otherwise- Parameters
-
x (Tensor) – The input Tensor with data type float32, float64.
threshold (float, optional) – The value of threshold(must be no less than zero) for softplus. Default is 0.5
name (str|None, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.
- Returns
-
A Tensor with the same data type and shape as
x
.
Examples
>>> 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(cpu), stop_gradient=True, [-0.39999998, 0. , 0. , 0.30000001])