Shortcuts

Softshrink

class torch.nn.Softshrink(lambd=0.5)[源代码]

逐元素应用软收缩函数。

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}
Parameters

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

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

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

../_images/Softshrink.png

示例:

>>> m = nn.Softshrink()
>>> input = torch.randn(2)
>>> output = m(input)
优云智算