评价此页

SiLU#

class torch.nn.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)