快捷方式

Softshrink

class torch.nn.Softshrink(lambd=0.5)[source][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)

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得解答

檢視資源