評價此頁

Softshrink#

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

逐元素應用 soft shrinkage 函式。

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)
extra_repr()[source]#

返回模組的額外表示。

返回型別

str

forward(input)[source]#

執行前向傳播。

返回型別

張量