mindspore.ops.HShrink
- class mindspore.ops.HShrink(lambd=0.5)[source]
Hard Shrink activation function.
Refer to
mindspore.ops.hardshrink()
for more details.- Parameters
lambd (float, optional) – The threshold \(\lambda\) defined by the Hard Shrink formula. Default: 0.5.
- Inputs:
input_x (Tensor) - The input of HardShrink.
- Outputs:
Tensor, the same shape and data type as the input.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore as ms >>> import mindspore.ops as ops >>> from mindspore import Tensor, nn >>> import numpy as np >>> input_x = Tensor(np.array([[0.5, 1, 2.0], [0.0533, 0.0776, -2.1233]]), ms.float32) >>> hshrink = ops.HShrink() >>> output = hshrink(input_x) >>> print(output) [[ 0. 1. 2. ] [ 0. 0. -2.1233]]