mindspore/docs/api/api_python/ops/mindspore.ops.func_softshri...

28 lines
901 B
ReStructuredText
Raw Permalink Normal View History

2023-03-01 15:13:38 +08:00
mindspore.ops.softshrink
2022-06-17 17:29:28 +08:00
=========================
2023-03-01 15:13:38 +08:00
.. py:function:: mindspore.ops.softshrink(x, lambd=0.5)
2022-06-17 17:29:28 +08:00
2022-08-19 16:24:01 +08:00
Soft Shrink激活函数按输入元素计算输出。公式定义如下
2022-06-17 17:29:28 +08:00
.. math::
\text{SoftShrink}(x) =
\begin{cases}
x - \lambda, & \text{ if } x > \lambda \\
x + \lambda, & \text{ if } x < -\lambda \\
0, & \text{ otherwise }
\end{cases}
2022-07-26 10:27:56 +08:00
参数:
- **x** (Tensor) - Soft Shrink的输入数据类型为float16或float32。
- **lambd** (float) - :math:`\lambda` 应大于等于0。默认值0.5。
返回:
Tensorshape和数据类型与输入相同。
异常:
- **TypeError** - `lambd` 不是float。
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的dtype既不是float16也不是float32。
- **ValueError** - `lambd` 小于0。