評價此頁

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]#

執行前向傳播。

返回型別

張量