2022-05-05 16:57:29 +08:00
|
|
|
|
mindspore.nn.SiLU
|
|
|
|
|
|
=============================
|
|
|
|
|
|
|
|
|
|
|
|
.. py:class:: mindspore.nn.SiLU
|
|
|
|
|
|
|
|
|
|
|
|
SiLU激活函数。
|
|
|
|
|
|
|
2022-06-30 16:48:21 +08:00
|
|
|
|
逐元素计算SiLU激活函数。
|
2022-05-05 16:57:29 +08:00
|
|
|
|
|
|
|
|
|
|
SiLU函数定义为:
|
|
|
|
|
|
|
|
|
|
|
|
.. math::
|
|
|
|
|
|
|
|
|
|
|
|
\text{SiLU}(x) = x * \sigma(x),
|
|
|
|
|
|
|
2022-06-09 14:59:05 +08:00
|
|
|
|
其中 :math:`x_i` 是输入的元素, :math:`\sigma(x)` 是Sigmoid函数。
|
2022-05-05 16:57:29 +08:00
|
|
|
|
|
|
|
|
|
|
.. math::
|
|
|
|
|
|
|
|
|
|
|
|
\text{sigmoid}(x_i) = \frac{1}{1 + \exp(-x_i)},
|
|
|
|
|
|
|
2022-06-02 10:27:11 +08:00
|
|
|
|
关于SiLU的图例见 `SiLU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Swish.svg>`_ 。
|
2022-05-05 16:57:29 +08:00
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
输入:
|
|
|
|
|
|
- **x** (Tensor) - 数据类型为float16或float32的输入。任意维度的Tensor。
|
2022-05-05 16:57:29 +08:00
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
输出:
|
|
|
|
|
|
Tensor,数据类型和shape与 `x` 的相同。
|
2022-05-05 16:57:29 +08:00
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
异常:
|
|
|
|
|
|
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
|