快捷方式

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 的全面开发者文档

查看文档

教程

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

查看教程

资源

查找开发资源并获得问题解答

查看资源