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 848 B

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