快捷方式

Softplus

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

逐元素地應用 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 的全面開發者文件

檢視文件

教程

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

檢視教程

資源

查詢開發資源並獲得解答

檢視資源