What is the SELU activation function?
The SELU activation function (Scaled Exponential Linear Unit) is an ELU multiplied by a fixed scale. For an input \( x \), it is:
\[ \mathrm{SELU}(x) = \lambda \begin{cases} x & \text{if } x > 0 \\ \alpha\,(e^{x} – 1) & \text{if } x \le 0 \end{cases} \]
The two constants are not hyperparameters. They were derived by Klambauer et al. in the 2017 paper Self-Normalizing Neural Networks (arXiv) and every library uses the same values:
- \( \lambda \approx 1.0507009873554805 \) (the scale)
- \( \alpha \approx 1.6732632423543772 \) (the negative-side multiplier)
So positive inputs are multiplied by about 1.0507, and negative inputs follow a smooth exponential curve that flattens out at \( -\lambda\alpha \approx -1.7581 \). With those exact constants, a deep stack of fully connected layers pushes its activations towards mean 0 and variance 1 on its own. The paper calls networks built this way self-normalising.
SELU calculator
Enter an input and this SELU activation function calculator returns SELU(x), its derivative, and the ELU and ReLU outputs for comparison. List mode applies SELU to a vector and reports the mean and variance of the outputs.
Worked example: SELU of −1 and 2
Take one neuron in a dense layer whose weighted sum is \( x = -1 \), and another whose weighted sum is \( x = 2 \).
Negative input, \( x = -1 \). Use the lower branch:
- \( e^{-1} = 0.367879 \)
- \( e^{-1} - 1 = -0.632121 \)
- Multiply by \( \alpha \): \( 1.673263 \times (-0.632121) = -1.057704 \)
- Multiply by \( \lambda \): \( 1.050701 \times (-1.057704) = -1.111331 \)
So \( \mathrm{SELU}(-1) \approx -1.1113 \). For comparison, ReLU would output 0 and ELU (with \( \alpha = 1 \)) would output \( -0.6321 \). SELU keeps a larger negative value, which is what lets it pull the mean of a layer back down towards zero.
Positive input, \( x = 2 \). Use the upper branch: \( 1.050701 \times 2 = 2.101402 \), so \( \mathrm{SELU}(2) \approx 2.1014 \).
Derivative. Differentiating each branch gives
\[ \mathrm{SELU}'(x) = \begin{cases} \lambda & x > 0 \\ \lambda\alpha\,e^{x} & x \le 0 \end{cases} \]
At \( x = -1 \) that is \( 1.758099 \times 0.367879 = 0.6468 \), and for any positive input it is \( 1.0507 \). Backpropagation multiplies these through the network. At exactly \( x = 0 \) the two sides disagree (1.7581 from the left, 1.0507 from the right); the calculator uses the left-hand value there.
Why the SELU activation function is self-normalising
Deep networks train badly when activations drift: if each layer's outputs get a little larger or smaller, the effect compounds and gradients explode or vanish (see the vanishing gradient problem). Batch normalisation fixes this by explicitly re-centring every layer. SELU tries to get the same effect from the activation alone.
The authors chose \( \lambda \) and \( \alpha \) so that, if a layer's inputs have mean 0 and variance 1 and its weights are initialised with mean 0 and variance \( 1/n \) (where \( n \) is the number of inputs), the outputs also have mean 0 and variance 1. They then proved that this point is an attractor: nearby means and variances are pulled back towards it, layer after layer. Two features of the curve make that work. The negative saturation at \( -1.7581 \) reduces variance when it is too large, and the slope \( \lambda > 1 \) on the positive side increases it when it is too small.
Unlike ReLU, which zeroes every negative value, SELU keeps them, so the layer mean can stay near zero.
When to use SELU and when not to
Good fits:
- Deep, fully connected feed-forward networks on tabular data. This is where the SELU activation function has its theory, and the paper's experiments (including 121 UCI datasets) used this kind of model.
- Models where you want to avoid batch normalisation, for example because batches are small.
Poor fits:
- Architectures where the self-normalising proof does not apply: convolutional networks with residual connections, recurrent networks and transformers. SELU can still be used there, but you lose the guarantee and should compare it against alternatives.
- Networks that already rely on batch or layer normalisation. The explicit normalisation does the job SELU was designed for, so SELU adds little.
- Pipelines where you cannot control initialisation or input scaling. Without them the fixed point argument does not hold.
SELU vs ELU (and ReLU)
ELU is the nearest alternative: SELU is literally \( \lambda \times \mathrm{ELU}_\alpha(x) \) with specific constants. The table sets them side by side, with ReLU as the familiar baseline.
| SELU | ELU | ReLU | |
|---|---|---|---|
| Formula for \( x > 0 \) | \( 1.0507\,x \) | \( x \) | \( x \) |
| Formula for \( x \le 0 \) | \( 1.7581\,(e^x - 1) \) | \( \alpha\,(e^x - 1) \) | 0 |
| Lowest output | \( -1.7581 \) | \( -\alpha \) (\( -1 \) by default) | 0 |
| Output at \( x = -1 \) | \( -1.1113 \) | \( -0.6321 \) (\( \alpha = 1 \)) | 0 |
| Tunable constant | None (fixed) | \( \alpha \) | None |
| Needs special setup | Yes: LeCun normal init, standardised inputs, alpha dropout | No | No |
| Self-normalising | Yes, in fully connected nets | No | No |
Choose ELU when you want smooth negative outputs without any special setup, or ReLU and Leaky ReLU when you want the cheapest option. Pick SELU when you are building a plain deep MLP and are happy to follow its recipe. Newer smooth functions such as GELU and Swish are more common in modern architectures; the activation functions guide compares them all.
Common mistakes with SELU
- Using He or Glorot initialisation. Self-normalisation assumes LeCun normal weights (variance \( 1/n \)). In PyTorch, the
torch.nn.initdocumentation advisesnonlinearity='linear'rather than'selu'when you want this behaviour, which gives the same variance. - Using ordinary dropout. Standard dropout sets values to 0, which shifts the mean and variance. Use alpha dropout instead: it sets dropped units to the negative saturation value and rescales so mean and variance are kept.
- Skipping input standardisation. The inputs to the first layer should have mean 0 and variance 1; see feature scaling.
- Treating \( \alpha \) and \( \lambda \) as tunable. Changing them breaks the fixed point. If you want an adjustable curve, use ELU.
- Expecting guarantees in every architecture. The proof is for fully connected feed-forward layers.
SELU in PyTorch and Keras
import torch.nn as nn
model = nn.Sequential(
nn.Linear(64, 128), nn.SELU(), nn.AlphaDropout(0.05),
nn.Linear(128, 128), nn.SELU(),
nn.Linear(128, 1),
)
for m in model.modules():
if isinstance(m, nn.Linear):
nn.init.kaiming_normal_(m.weight, nonlinearity="linear") # LeCun normal
nn.init.zeros_(m.bias)
In Keras, write Dense(128, activation="selu", kernel_initializer="lecun_normal"). The constants are listed in the PyTorch SELU documentation.
Frequently asked questions
What are the alpha and lambda values in SELU?
\( \alpha \approx 1.6733 \) and \( \lambda \approx 1.0507 \). Their product, about 1.7581, is the size of the most negative output SELU can produce.
Is SELU better than ReLU?
Not in general. In deep fully connected networks set up as the paper describes, it can train without batch normalisation. In CNNs and transformers, ReLU, GELU or similar functions with normalisation layers are the usual choice.
Can I use batch normalisation with SELU?
You can, but there is little reason to. SELU exists to make the network normalise itself; adding batch normalisation duplicates that job.
What is the derivative of SELU?
It is \( \lambda \approx 1.0507 \) for positive inputs and \( \lambda\alpha e^x \) for negative inputs, for example 0.6468 at \( x = -1 \). You can check it with the derivative calculator.
Why does the SELU activation function need LeCun normal initialisation?
The constants were derived assuming weights with mean 0 and variance \( 1/n \). Other initialisations start the network away from the fixed point, so the self-normalising property is not guaranteed.