Skip to content
fn

softsign

→Tensor
softsign(input: Tensor)

Softsign activation.

A bounded (−1,1)(-1, 1) activation that saturates polynomially rather than exponentially — its tails are much heavier than tanh's, so gradients vanish more slowly in deep networks.

Parameters

inputTensor
Input tensor of any shape; activation is element-wise.

Returns

Tensor

Activated tensor with the same shape as input, values in (−1,1)(-1, 1).

Notes

softsign(x)=x1+∣x∣,softsign′(x)=1(1+∣x∣)2\text{softsign}(x) = \frac{x}{1 + |x|}, \qquad \text{softsign}'(x) = \frac{1}{(1 + |x|)^2}

Derivative decays like 1/x21/x^2 rather than tanh⁡\tanh's 1/cosh⁡21/\cosh^2, so saturation is gentler. Lacks the bi-Lipschitz smoothness of tanh near zero (kink at x=0x = 0 from the absolute value) but is monotone and zero-centred.

Examples

>>> import lucid
>>> from lucid.nn.functional import softsign
>>> x = lucid.tensor([-2.0, -1.0, 0.0, 1.0, 2.0])
>>> softsign(x)
tensor([-0.6667, -0.5, 0., 0.5, 0.6667])

Used by 1