mindspore.mint.nn.Softshrink
- class mindspore.mint.nn.Softshrink(lambd=0.5)
Applies the Softshrink function element-wise.
Softshrink Activation Function Graph:
- Parameters
lambd (number, optional) – The threshold
defined by the Soft Shrink formula. It should be greater than or equal to 0, default:0.5
.
- Inputs:
input (Tensor) - The input of Soft Shrink. Supported dtypes:
Ascend: float16, float32, bfloat16.
- Outputs:
Tensor, the same shape and data type as the input.
- Raises
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> from mindspore import Tensor, mint >>> import numpy as np >>> input = Tensor(np.array([[ 0.5297, 0.7871, 1.1754], [ 0.7836, 0.6218, -1.1542]]), mindspore.float16) >>> softshrink = mint.nn.Softshrink() >>> output = softshrink(input) >>> print(output) [[ 0.02979 0.287 0.676 ] [ 0.2837 0.1216 -0.6543 ]]