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

31 lines
825 B
ReStructuredText
Raw Normal View History

2021-12-08 15:50:20 +08:00
mindspore.nn.HShrink
=============================
.. py:class:: mindspore.nn.HShrink(lambd=0.5)
2022-01-08 17:47:30 +08:00
Hard Shrink激活函数按输入元素计算输出公式定义如下
2021-12-08 15:50:20 +08:00
.. math::
\text{HardShrink}(x) =
\begin{cases}
x, & \text{ if } x > \lambda \\
x, & \text{ if } x < -\lambda \\
0, & \text{ otherwise }
\end{cases}
**参数:**
2022-01-08 17:47:30 +08:00
**lambd** (float) - Hard Shrink公式定义的阈值 :math:`\lambda` 。默认值0.5。
2021-12-08 15:50:20 +08:00
**输入:**
- **input_x** (Tensor) - Hard Shrink的输入数据类型为float16或float32。
**输出:**
Tensorshape和数据类型与输入相同。
**异常:**
- **TypeError** - `lambd` 不是float。
- **TypeError** - `input_x` 的dtype既不是float16也不是float32。