You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.HSigmoid.rst 921 B

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