mindspore/docs/api/api_python/ops/mindspore.ops.func_hardshri...

26 lines
852 B
ReStructuredText
Raw Normal View History

mindspore.ops.hardshrink
========================
.. py:function:: mindspore.ops.hardshrink(x, lambd=0.5)
2022-10-13 16:22:54 +08:00
Hard Shrink激活函数。按输入元素计算输出。公式定义如下
.. math::
\text{HardShrink}(x) =
\begin{cases}
x, & \text{ if } x > \lambda \\
x, & \text{ if } x < -\lambda \\
0, & \text{ otherwise }
\end{cases}
2022-07-25 17:18:38 +08:00
参数:
- **x** (Tensor) - Hard Shrink的输入数据类型为float16或float32。
- **lambd** (float) - Hard Shrink公式定义的阈值 :math:`\lambda` 。默认值0.5。
2022-07-25 17:18:38 +08:00
返回:
Tensorshape和数据类型与输入 `x` 相同。
2022-07-25 17:18:38 +08:00
异常:
- **TypeError** - `lambd` 不是float。
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的dtype既不是float16也不是float32。