快捷鍵

Softplus

class torch.nn.Softplus(beta=1.0, threshold=20.0)[來源][來源]

逐元素套用 Softplus 函數。

Softplus(x)=1βlog(1+exp(βx))\text{Softplus}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x))

SoftPlus 是一個對 ReLU 函數的平滑近似,可用於約束機器輸出始終為正數。

為了數值穩定性,當 input×β>thresholdinput \times \beta > threshold 時,實現會回復到線性函數。

參數
  • beta (float) – Softplus 公式中的 β\beta 值。預設值:1

  • threshold (float) – 高於此值會回復到線性函數。預設值:20

形狀
  • 輸入:()(*),其中 * 表示任何數量的維度。

  • 輸出:()(*),與輸入形狀相同。

../_images/Softplus.png

範例

>>> m = nn.Softplus()
>>> input = torch.randn(2)
>>> output = m(input)

文件

存取 PyTorch 的完整開發人員文件

檢視文件

教學

取得針對初學者和進階開發人員的深入教學

檢視教學

資源

尋找開發資源並取得問題解答

檢視資源