mindspore/docs/api/api_python/nn/mindspore.nn.HSigmoid.rst

40 lines
921 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.nn.HSigmoid
=============================
.. py:class:: mindspore.nn.HSigmoid
Hard Sigmoid激活函数。
按元素计算Hard Sigmoid激活函数。
Hard Sigmoid定义为
.. math::
\text{hsigmoid}(x_{i}) = max(0, min(1, \frac{x_{i} + 3}{6})),
其中,:math:`x_i` 是输入Tensor的一个元素。
**输入:**
- **input_x** (Tensor) - Hard Sigmoid的输入。shape为 :math:`(N,*)` ,其中 :math:`*` 表示任意的附加维度。
**输出:**
Tensor数据类型和shape与 `input_x` 的相同。
**异常:**
**TypeError** - `input_x` 不是tensor。
**支持平台:**
``Ascend`` ``GPU`` ``CPU``
**样例:**
>>> x = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float16)
>>> hsigmoid = nn.HSigmoid()
>>> result = hsigmoid(x)
>>> print(result)
[0.3333 0.1666 0.5 0.8335 0.6665]