mindspore/docs/api/api_python/mint/mindspore.mint.nn.functiona...

33 lines
1.1 KiB
ReStructuredText
Raw Permalink 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.mint.nn.functional.softshrink
=======================================
.. py:function:: mindspore.mint.nn.functional.softshrink(input, lambd=0.5)
Soft Shrink激活函数。按输入元素计算输出。公式定义如下
.. math::
\text{SoftShrink}(x) =
\begin{cases}
x - \lambda, & \text{ if } x > \lambda \\
x + \lambda, & \text{ if } x < -\lambda \\
0, & \text{ otherwise }
\end{cases}
SoftShrink激活函数图
.. image:: ../images/Softshrink.png
:align: center
参数:
- **input** (Tensor) - Soft Shrink的输入。支持数据类型
- Ascendfloat16、float32、bfloat16。
- **lambd** (number可选) - Soft Shrink公式定义的阈值 :math:`\lambda``lambd` 应该大于等于0。默认值 ``0.5``
返回:
Tensorshape和数据类型与输入 `input` 相同。
异常:
- **TypeError** - `lambd` 不是float、bool或int。
- **TypeError** - `input` 不是Tensor。
- **TypeError** - `input` 的dtype不是float16float32或bfloat16。