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