Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


torch (version 0.14.2)

nn_softshrink: Softshrink module

Description

Applies the soft shrinkage function elementwise:

Usage

nn_softshrink(lambd = 0.5)

Arguments

lambd

the λ (must be no less than zero) value for the Softshrink formulation. Default: 0.5

Shape

  • Input: (N,) where * means, any number of additional dimensions

  • Output: (N,), same shape as the input

Details

SoftShrinkage(x)={xλ, if x>λx+λ, if x<λ0, otherwise 

Examples

Run this code
if (torch_is_installed()) {
m <- nn_softshrink()
input <- torch_randn(2)
output <- m(input)
}

Run the code above in your browser using DataLab