软 plus 函数
- classtorch.nn.Softplus(beta=1.0, threshold=20.0)[源代码]
-
对每个元素应用Softplus函数。
SoftPlus 是 ReLU 函数的一种平滑近似,可用于确保机器的输出始终为正。
为了保证数值稳定性,当时,实现会退回到线性函数。
- 形状:
-
-
输入: ,其中表示任意维度的数量。
-
输出: ,形状与输入相同。
-
示例:
>>> m = nn.Softplus() >>> input = torch.randn(2) >>> output = m(input)