快捷方式

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}
參數

lambd (float) – λ\lambda(必須不小於零)Softshrink 公式中的 λ\lambda 值。預設值:0.5

形狀
  • 輸入:()(*),其中 * 代表任意數量的維度。

  • 輸出:()(*),與輸入形狀相同。

../_images/Softshrink.png

範例

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

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得初學者和進階開發人員的深入教學

檢視教學

資源

尋找開發資源並取得您的問題解答

檢視資源