Summary
An activation inserts a nonlinear map between affine layers. Without it, repeated affine layers collapse into one affine map.
Take , then compare with . What changes at and ? The graphs show activation output , not the complete network output .
Optimization intuition
Flat activation regions weaken the gradient travelling backward
Derivation
Sigmoid: two saturating tails
The slope approaches zero at both output limits.
ReLU vs exact GELU
A half-line of zero slope differs from one smooth shoulder.
Where does the same small input move produce almost no output change?
Trace the two inputs
Without activation, substitution gives everywhere. ReLU instead clips negative to zero.
| Input | Affine output | ReLU output | ReLU path derivative | |
|---|---|---|---|---|
The activated network is constant at when , and equals when . Its breakpoint is . Both branches meet there, but the derivative is not unique. Frameworks choose a derivative convention at the kink.
For positive , ReLU’s local slope is one. For negative , it is zero, removing this path’s gradient on that input. Sigmoid has derivative , which approaches zero in both tails. Full gradient flow also depends on weights and other paths.
Change the requirement
1. Keep a negative-region gradient
New task: this path repeatedly receives and needs a negative-region update.
Picture and change: replace ReLU by leaky ReLU with negative slope . This changes both values and gradients.
Check: activation output becomes with local slope , instead of zero output and slope. The complete output is , and .
Use when: persistent inactivity is observed, with the changed function acceptable for the task.
2. Change label exclusivity
New task: logits are . Choose outputs for one exclusive class versus two labels that can coexist.
Picture and change: softmax normalizes jointly; separate sigmoids produce individual Bernoulli probabilities.
Check: softmax gives ; sigmoids give . The latter need not sum to one.
Use when: target structure changes, rather than merely changing a hidden activation.
Check the loss input contract
Do not apply softmax before a cross-entropy API that expects logits. It would transform already transformed values. Check whether the API accepts logits, probabilities or log probabilities.
Try diagnosing a negative ReLU input
Does one negative input mean the unit is permanently dead?
Check your answer
No. Other inputs or upstream parameter changes can reactivate it. Persistent inactivity across relevant inputs is the concern.
The standard family
Here for ELU and for leaky ReLU.
| Activation | Formula | Range | Constraint or role |
|---|---|---|---|
| Sigmoid | Bernoulli outputs and gates; saturating tails | ||
| Tanh | Odd and centered at the origin, not necessarily zero-mean over data | ||
| ReLU | Unit positive slope, zero negative slope | ||
| Leaky ReLU | Nonzero negative slope | ||
| ELU | if ; otherwise | Negative outputs; smooth at zero only when | |
| Exact GELU | , normal CDF | Bounded below, unbounded above | Small negative shoulder; not every real output is attainable |
| SiLU / swish with unit scale | Bounded below, unbounded above | Smooth, nonmonotone negative shoulder | |
| Softmax | Probability simplex interior for finite logits | Couples coordinates; not an elementwise activation |
Smoothness does not guarantee gradient flow
Exact GELU has derivative , where is the normal density. It can vanish at isolated points. Exact and approximate GELU differ; match framework settings for reproducibility. Activation choice and initialization must be considered together. No activation guarantees better task accuracy from its curve alone.
References: ReLU, GELU, swish, and feedforward networks.
SwiGLU and gated activations
For row-vector batches , use and :
This has projection parameters, excluding biases, versus for a two-projection block at equal hidden width. Equal parameter budgets require adjusting width; performance comparisons must state that budget.
When to use which output activation
| Task | Output activation |
|---|---|
| Binary classification | Sigmoid |
| Multi-class classification | Softmax |
| Multi-label classification | Separate sigmoid heads; labels need not be mutually exclusive |
| Regression (unbounded) | Identity (no activation) |
| Regression (bounded ) | Sigmoid |
| Probability over a discrete distribution | Softmax |
| Embedding output | Identity; normalize if the similarity objective requires it |
Common pitfalls
Output constraints must match the target: softplus is positive, while ReLU can produce exact zeros and inactive gradients. Bounded sigmoid outputs do not by themselves establish calibrated probabilities.
Related
- Weight initialization. Initialization is activation-dependent.
- Exploding and vanishing gradients. What motivates ReLU and gated activations.