mindspore.nn.HSigmoid
- class mindspore.nn.HSigmoid[source]
Applies the Hard Sigmoid activation function element-wise.
Hard Sigmoid is defined as:
\[\begin{split}\text{HSigmoid}(input) = \begin{cases} 0, & \text{ if } input \leq -3, \\ 1, & \text{ if } input \geq +3, \\ input/6 + 1/2, & \text{ otherwise } \end{cases}\end{split}\]HSigmoid Activation Function Graph:
- Inputs:
input (Tensor) - The input tensor to be processed by Hard Sigmoid.
- Outputs:
Tensor, with the same type and shape as the input.
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore >>> import numpy as np >>> input = mindspore.tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float16) >>> hsigmoid = mindspore.nn.HSigmoid() >>> result = hsigmoid(input) >>> print(result) [0.3333 0.1666 0.5 0.8335 0.6665]