Shortcuts

SiLU

class torch.nn.SiLU(inplace=False)[源代码]

逐元素应用Sigmoid线性单元(SiLU)函数。

SiLU 函数也被称为 swish 函数。

silu(x)=xσ(x),where σ(x) is the logistic sigmoid.\text{silu}(x) = x * \sigma(x), \text{where } \sigma(x) \text{ is the logistic sigmoid.}

注意

参见 高斯误差线性单元 (GELUs) 其中首次提出了 SiLU(Sigmoid 线性单元),并参见 用于强化学习中神经网络函数逼近的 Sigmoid 加权线性单元Swish: 一种自门控激活函数 其中后来对 SiLU 进行了实验。

Shape:
  • 输入:()(*),其中 * 表示任意数量的维度。

  • 输出: ()(*), 与输入形状相同。

../_images/SiLU.png

示例:

>>> m = nn.SiLU()
>>> input = torch.randn(2)
>>> output = m(input)
优云智算