mindspore2022/docs/api/api_python/nn/mindspore.nn.HShrink.rst

32 lines
821 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.HShrink
=============================
.. py:class:: mindspore.nn.HShrink(lambd=0.5)
Hard Shrink激活函数按输入元素计算输出公式定义如下
.. math::
\text{HardShrink}(x) =
\begin{cases}
x, & \text{ if } x > \lambda \\
x, & \text{ if } x < -\lambda \\
0, & \text{ otherwise }
\end{cases}
**参数:**
**lambd** (float) - Hard Shrink公式定义的阈值 :math:`\lambda` 。默认值0.5。
**输入:**
- **input_x** (Tensor) - Hard Shrink的输入数据类型为float16或float32。
**输出:**
Tensorshape和数据类型与输入相同。
**异常:**
- **TypeError** - `lambd` 数据类型不是float。
- **TypeError** - `input_x` 数据类型不是float。