fn
softshrink
→Tensorsoftshrink(x: Tensor, lambd: float = 0.5)Soft shrinkage operator — proximal operator of .
Translates the input toward zero by and zeros out everything in the dead zone . Used in iterative-shrinkage solvers (ISTA / FISTA) and in sparse autoencoder decoders.
Parameters
xTensorInput tensor.
lambdfloat= 0.5Shrinkage threshold . Default
0.5.Returns
TensorShrunk tensor with the same shape as x.
Notes
Continuous everywhere (unlike hardshrink), with derivative
outside the dead zone and inside it. Coincides
with the closed-form solution of
.
Examples
>>> import lucid
>>> from lucid.nn.functional import softshrink
>>> x = lucid.tensor([-1.0, -0.3, 0.0, 0.3, 1.0])
>>> softshrink(x, lambd=0.5)
Tensor([-0.5000, 0.0000, 0.0000, 0.0000, 0.5000])