fn
tanhshrink
→Tensortanhshrink(x: Tensor)Tanh shrinkage activation.
Behaves like a smooth high-pass filter: subtracts the tanh-saturated component of the input, leaving small linear residuals near zero and near-linear behaviour for large magnitudes.
Parameters
xTensorInput tensor of any shape; activation is element-wise.
Returns
TensorActivated tensor with the same shape as x.
Notes
For , , so — small signals are cubically suppressed. For , saturates to so the output behaves like . -smooth and monotonic.
Examples
>>> import lucid
>>> from lucid.nn.functional import tanhshrink
>>> x = lucid.tensor([-2.0, -0.5, 0.0, 0.5, 2.0])
>>> tanhshrink(x)
Tensor([-1.0360, -0.0379, 0.0000, 0.0379, 1.0360])