快捷方式

SiLU

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

逐元素地应用 Sigmoid Linear Unit (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)

文档

查阅 PyTorch 的完整开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得解答

查看资源