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} SoftShrinkage(x)=⎩⎨⎧x−λ,x+λ,0, if x>λ if x<−λ otherwise 參數 lambd (float) – λ\lambdaλ(必須不小於零)Softshrink 公式中的 λ\lambdaλ 值。預設值:0.5 形狀 輸入:(∗)(*)(∗),其中 ∗*∗ 代表任意數量的維度。 輸出:(∗)(*)(∗),與輸入形狀相同。 範例 >>> m = nn.Softshrink() >>> input = torch.randn(2) >>> output = m(input)