快捷方式

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 的完整開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得解答

檢視資源