mindspore.ops.SoftShrink

class mindspore.ops.SoftShrink(lambd=0.5)[source]

Applies the SoftShrink function element-wise.

Refer to mindspore.ops.soft_shrink() for more detail.

Supported Platforms:

Ascend CPU GPU

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 ]]