快捷方式

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

查看文档

教程

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

查看教程

资源

查找开发资源并获得解答

查看资源