Hardshwink module
Applies the hard shrinkage function element-wise:
nn_hardshrink(lambd = 0.5)
Arguments
lambd
: the λ value for the Hardshrink formulation. Default: 0.5
Details
\mboxHardShrink(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_hardshrink()
input <- torch_randn(2)
output <- m(input)
}