Open main menu

GM-RKB β

Softshrink Activation Function

References

2018a

f(x) = x-lambda, if x > lambda 
f(x) = x+lambda, if x < -lambda
f(x) = 0, otherwise
Parameters: lambd – the lambda value for the Softshrink formulation. Default: 0.5

Shape:

  • Input: [math](N,∗)[/math] where * means, any number of additional dimensions
  • Output: [math](N,∗)[/math], same shape as the input
Examples:
>>> m = nn.Softshrink()
>>> input = autograd.Variable(torch.randn(2))
>>> print(input)
>>> print(m(input))
forward(input) source

Defines the computation performed at every call.

Should be overriden by all subclasses.

Note:

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.