快捷方式

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 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得您的问题解答

查看资源