评价此页

SiLU#

class torch.nn.modules.activation.SiLU(inplace=False)[source]#

逐元素应用 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.}

注意

请参阅 Gaussian Error Linear Units (GELUs),其中最初创造了 SiLU (Sigmoid Linear Unit) 一词;以及参阅 Sigmoid-Weighted Linear Units for Neural Network Function Approximation in Reinforcement LearningSwish: a Self-Gated Activation Function,其中后来对 SiLU 进行了实验。

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

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

../_images/SiLU.png

示例

>>> m = nn.SiLU()
>>> input = torch.randn(2)
>>> output = m(input)
extra_repr()[source]#

返回模块的额外表示。

返回类型

str

forward(input)[source]#

执行前向传播。

返回类型

张量