mindspore.nn.HSigmoid
- class mindspore.nn.HSigmoid[source]
Applies Hard Sigmoid activation function element-wise.
Hard Sigmoid is defined as:
\[\begin{split}\text{Hardsigmoid}(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 of HSigmoid.
- Outputs:
Tensor, with the same type and shape as the input.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> from mindspore import Tensor, nn >>> import numpy as np >>> input = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float16) >>> hsigmoid = nn.HSigmoid() >>> result = hsigmoid(input) >>> print(result) [0.3333 0.1666 0.5 0.8335 0.6665]