快捷方式

Softshrink

class torch.nn.Softshrink(lambd=0.5)[source][source]

逐元素应用软收缩函数。

SoftShrinkage(x)={xλ, if x>λx+λ, if x<λ0, otherwise \text{SoftShrinkage}(x) = \begin{cases} x - \lambda, & \text{ if } x > \lambda \\ x + \lambda, & \text{ if } x < -\lambda \\ 0, & \text{ otherwise } \end{cases}
参数

lambd (float) – Softshrink 公式的 λ\lambda 值(必须不小于零)。默认值:0.5

形状
  • 输入: ()(*),其中 * 表示任意数量的维度。

  • 输出: ()(*),与输入形状相同。

../_images/Softshrink.png

示例

>>> m = nn.Softshrink()
>>> input = torch.randn(2)
>>> output = m(input)

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源