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(x)=β1∗log(1+exp(β∗x))SoftPlus 是 ReLU 函式的平滑近似,可用於限制模型(或機器)的輸出始終為正。 為了數值穩定性,當 input×β>thresholdinput \times \beta > thresholdinput×β>threshold 時,實現(或函式)會退化為線性函式。 引數 beta (float) – Softplus 公式中的 β\betaβ 值。預設值:1 threshold (float) – 高於此值的輸入會退化為線性函式。預設值:20 形狀 輸入:(∗)(*)(∗),其中 ∗*∗ 表示任意維度數量。 輸出:(∗)(*)(∗),形狀與輸入相同。 示例 >>> m = nn.Softplus() >>> input = torch.randn(2) >>> output = m(input)