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.HShrink.rst 825 B

4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031
  1. mindspore.nn.HShrink
  2. =============================
  3. .. py:class:: mindspore.nn.HShrink(lambd=0.5)
  4. Hard Shrink激活函数,按输入元素计算输出,公式定义如下:
  5. .. math::
  6. \text{HardShrink}(x) =
  7. \begin{cases}
  8. x, & \text{ if } x > \lambda \\
  9. x, & \text{ if } x < -\lambda \\
  10. 0, & \text{ otherwise }
  11. \end{cases}
  12. **参数:**
  13. **lambd** (float) - Hard Shrink公式定义的阈值 :math:`\lambda` 。默认值:0.5。
  14. **输入:**
  15. - **input_x** (Tensor) - Hard Shrink的输入,数据类型为float16或float32。
  16. **输出:**
  17. Tensor,shape和数据类型与输入相同。
  18. **异常:**
  19. - **TypeError** - `lambd` 不是float。
  20. - **TypeError** - `input_x` 的dtype既不是float16也不是float32。