Skip to content
fn

selu

→Tensor
selu(input: Tensor, inplace: bool = False)

Implementing kernel

C++ engine symbols that back this Python API.

Scaled exponential linear unit activation.

Self-normalising activation from Klambauer et al. (2017): when used in a fully-connected network with LeCun-normal initialised weights, the fixed scale λ\lambda and slope α\alpha drive the activations toward zero-mean, unit-variance fixed points without the need for explicit batch / layer normalisation.

Parameters

inputTensor
Input tensor of any shape; activation is element-wise.
inplacebool= False
If True, write the result into input and return input.

Returns

Tensor

Activated tensor with the same shape as input.

Notes

SELU(x)=λ ELU(x,α)=λ{xx>0α(ex−1)x≤0\text{SELU}(x) = \lambda \, \text{ELU}(x, \alpha) = \lambda \begin{cases} x & x > 0 \\ \alpha (e^x - 1) & x \le 0 \end{cases}

with the (non-tunable) constants

λ≈1.0507,α≈1.6733,\lambda \approx 1.0507, \qquad \alpha \approx 1.6733,

chosen so that the activation has a zero-mean unit-variance attractor fixed point. Pair with alpha_dropout and LeCun-normal weight init to retain the self-normalising property.

Examples

>>> import lucid
>>> from lucid.nn.functional import selu
>>> x = lucid.tensor([-1.0, 0.0, 1.0])
>>> selu(x)
tensor([-1.111, 0., 1.051])

Used by 2