Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.An input that gates itself
SiLU (also called Swish) multiplies each input by its own sigmoid, z·σ(z). The sigmoid acts as a soft gate that is nearly open for large positive inputs and nearly closed for large negative ones, so the curve looks like a smooth ReLU with a small dip below zero, very much like GELU. Swish adds a knob β: z·σ(βz) is nearly linear when β is small and becomes ReLU as β grows.
SiLU is the activation of EfficientNet and YOLOv5-v8-family detectors, and its gated form SwiGLU (E1-11) is in the feed-forward blocks of most current language models. Its cheap cousin hard-swish (E1-13) runs on mobile and embedded NPUs. Understanding β explains why these variants behave as they do.
- 1. SiLU(z) =
- 2. Swish with very large β approaches…
- 3. Swish with β = 0 is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Values by hand
- Definition: SiLU(z) = z·σ(z) = z/(1 + e⁻ᶻ). SiLU(1) ≈ 0.731, SiLU(−1) ≈ −0.269, SiLU(0) = 0.
- Gradient: SiLU′(z) = σ(z)(1 + z(1 − σ(z))). SiLU′(0) = 0.5 and SiLU′(1) ≈ 0.928.
- Minimum: at z ≈ −1.2785 with value ≈ −0.2785. At the minimum 1 + z(1 − σ) = 0, so 1 − σ = −1/z, which gives SiLU = zσ = z + 1 exactly.
- Swish: f(z) = z·σ(βz). β = 0 gives z/2; β → ∞ gives ReLU; β = 1.702 gives the sigmoid approximation of GELU (E1-8). SiLU and GELU differ by up to 0.175 on [−6, 6].
- Gradient with respect to β: ∂f/∂β = z²σ(βz)(1 − σ(βz)), which is always ≥ 0.
- dSiLU: SiLU′ itself has been used as an activation in reinforcement learning (Elfwing et al., 2018). It peaks at about 1.10 near z = 2.40.
- 1. SiLU's minimum value is about…
- 2. SiLU′(0) =
- 3. Swish with β = 1.702 approximates…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.SiLU’s shape and limits
Exercise 1. The SiLU gradient matches finite differences. Swish equals z/2 exactly at β = 0, and is within 2 × 10⁻³ of ReLU at β = 200. Newton’s method, using SiLU″(z) = σ(1 − σ)(2 + z(1 − 2σ)), finds the minimum −0.2785 at z = −1.2785.
Compared with GELU.
- SiLU’s dip is deeper (−0.278 against −0.170) and further out (−1.28 against −0.75).
- Its gate is softer, since σ(z) changes more slowly than Φ(z).
- In practice the two perform similarly, and SiLU is slightly cheaper (one exponential).
Practical notes.
- Implement SiLU as z·sigmoid(z) with a stable sigmoid.
- For Swish with a learned β, initialise β = 1.
- In frameworks, SiLU is a built-in:
nn.SiLU(),tf.nn.silu.
nn.SiLU() # z * sigmoid(z)
beta = nn.Parameter(torch.ones(1)); y = x * torch.sigmoid(beta * x) # Swish with learned beta- 1. Compared with GELU, SiLU's dip is…
- 2. ∂f/∂β for Swish is…
- 3. At SiLU's minimum, SiLU(z) equals…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Discovery by search. Ramachandran, Zoph and Le (2017) ran a reinforcement-learning-guided search over compositions of unary and binary functions. The best simple candidate was x·σ(βx), which they named Swish. Replacing ReLU with it improved ImageNet top-1 accuracy by 0.6–0.9 points in Mobile NASNet-A and Inception-ResNet-v2. The same function had appeared earlier as the SiLU (Hendrycks and Gimpel, 2016; Elfwing et al., 2018).
Properties.
- Self-gating: the input gates itself, so the function needs only one input. This is unlike LSTM gates or GLU, which use a separate projection.
- Unbounded above, bounded below: outputs are ≥ −0.2785. Being bounded below acts as a mild regulariser, as large negative inputs are forgotten.
- Smooth, non-monotonic.
- Interpolation: β moves the function between linear and ReLU, so a learned β lets each layer choose its own amount of nonlinearity.
Why the β gradient is never negative. ∂f/∂β = z²σ(βz)(1 − σ(βz)) ≥ 0 for every z. The direction β moves therefore depends only on the sign of the upstream gradient, weighted by z². β grows when the loss favours sharper gating on the inputs the layer sees.
- 1. Swish was found by…
- 2. SiLU's output is bounded…
- 3. A learned β lets each layer choose…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Where does a learned β go?
History.
- D. Hendrycks and K. Gimpel (2016) described the SiLU alongside GELU.
- S. Elfwing, E. Uchibe and K. Doya (2018) used SiLU and dSiLU for reinforcement learning function approximation.
- P. Ramachandran, B. Zoph and Q. Le (2017) found Swish by automated search.
- M. Tan and Q. Le (2019) used it in EfficientNet, and A. Howard et al. (2019) introduced hard-swish for MobileNetV3.
Exercise 2. A 4-hidden-layer MLP (width 64) on spirals, He initialisation, minibatch SGD at learning rate 0.1. Swish z·σ(βz) has a fixed β of 0.5, 1 or 4, or a learned β per layer starting at 1 and trained with its full gradient. Each cell lists three seeds.
| setting | after 100 steps | after 300 steps | final β per layer (first → last) |
|---|---|---|---|
| fixed β = 0.5 | 0.635, 0.668, 0.682 | 0.950, 0.965, 0.970 | 0.5 |
| fixed β = 1 (SiLU) | 0.863, 0.903, 0.900 | 0.993, 0.995, 0.992 | 1 |
| fixed β = 4 | 0.993, 0.993, 0.997 | 1.000, 1.000, 1.000 | 4 |
| learned β from 1 | 0.900, 0.923, 0.928 | 1.000, 0.995, 0.997 | 1.54 → 1.19; 1.50 → 1.23; 1.56 → 1.30 |
- β grew in every layer, from 1 to between 1.18 and 1.56. It grew most in the first layer, in all three seeds and in three further seeds.
- Learning β helped. It sped up early training compared with fixed SiLU, in every seed.
- But a fixed β = 4 was far faster. The learned β moved in the right direction (sharper) but much too slowly to get there in 300 steps.
- The same lesson as softplus (E1-7). On these inputs, sharper gating means more nonlinearity at the initialisation scale and faster learning. In transformers with normalised inputs, β = 1 works well, which illustrates that the best β depends on the scale of the pre-activations.
SiLU in AI, robotics and aerospace
- Detection on drones and robots: YOLOv5 to YOLOv8 use SiLU throughout.
- Efficient perception backbones: EfficientNet (SiLU) and MobileNetV3 (hard-swish) for satellite and UAV imagery on constrained hardware.
- Reinforcement learning: SiLU and dSiLU were introduced for value-function approximation in RL agents.
References
- P. Ramachandran, B. Zoph, Q. V. Le (2017). “Searching for activation functions.” arXiv:1710.05941.
- S. Elfwing, E. Uchibe, K. Doya (2018). “Sigmoid-weighted linear units for neural network function approximation in reinforcement learning.” Neural Networks 107.
- M. Tan, Q. V. Le (2019). “EfficientNet: rethinking model scaling for convolutional neural networks.” Proc. ICML.
- A. Howard et al. (2019). “Searching for MobileNetV3.” Proc. ICCV.