Softshrink module
Applies the soft shrinkage function elementwise:
nn_softshrink(lambd = 0.5)
Arguments
lambd
: the λ (must be no less than zero) value for the Softshrink formulation. Default: 0.5
Details
\mboxSoftShrinkage(x)=⎩⎨⎧x−λ,x+λ,0,\mboxifx>λ\mboxifx<−λ\mboxotherwise
Shape
- Input: (N,∗) where
*
means, any number of additional dimensions
- Output: (N,∗), same shape as the input
Examples
if (torch_is_installed()) {
m <- nn_softshrink()
input <- torch_randn(2)
output <- m(input)
}