mindspore.ops.SoftShrink

View Source On Gitee
class mindspore.ops.SoftShrink(lambd=0.5)[source]

Applies the SoftShrink function element-wise.

Refer to mindspore.ops.softshrink() for more details.

Parameters

lambd (float, optional) – The \(\lambda\) must be no less than zero. Default: 0.5 .

Inputs:
  • input_x (Tensor) - The input of soft shrink with data type of float16 or float32.

Outputs:

Tensor, has the same shape and data type as input_x.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input_x = Tensor(np.array([[ 0.5297,  0.7871,  1.1754], [ 0.7836,  0.6218, -1.1542]]), mindspore.float16)
>>> softshrink = ops.SoftShrink()
>>> output = softshrink(input_x)
>>> print(output)
[[ 0.02979  0.287    0.676  ]
 [ 0.2837   0.1216  -0.6543 ]]