Activation Functions › Swish / SiLU

Michael BrenndoerferApril 21, 20252 min read
Language AI HandbookAll chapters
Part 10 of 67Neural Network Foundations
Chapter 62Activation Functions › Swish / SiLU
Reading section 7 of 16 · Swish / SiLU · 2 minSection 7 of 16 · 2 min

Book contents

Section 7 of 16 · 2 min read

Activation Functions › Swish / SiLUOne section · Sections in this chapter7 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Swish (also called SiLU, for Sigmoid Linear Unit) was discovered by automated neural architecture search at Google in 2017. It resembles GELU but is simpler in formulation and has become the activation function of choice in several important vision architectures.

Definition

Swish is defined as:

Swish(z)=z⋅σ(z)=z1+e−z\text{Swish}(z) = z \cdot \sigma(z) = \frac{z}{1 + e^{-z}}

where:

  • zz: the pre-activation value
  • σ(z)=1/(1+e−z)\sigma(z) = 1/(1 + e^{-z}): the sigmoid function used as a soft gate

Like GELU, Swish scales the input by a smooth gate function. The difference is that Swish uses sigmoid as the gate rather than the normal CDF. For large positive zz, σ(z)→1\sigma(z) \to 1 so Swish approaches the identity. For large negative zz, σ(z)→0\sigma(z) \to 0 so Swish approaches zero. The function is non-monotone with a minimum around z≈−1.28z \approx -1.28 where the output is approximately −0.28-0.28.

The derivative of Swish is:

d Swish(z)dz=σ(z)+z⋅σ(z)(1−σ(z))=σ(z)(1+z(1−σ(z)))\frac{d\,\text{Swish}(z)}{dz} = \sigma(z) + z \cdot \sigma(z)(1 - \sigma(z)) = \sigma(z)(1 + z(1 - \sigma(z)))

where:

  • σ(z)\sigma(z): the sigmoid gate value at zz
  • z(1−σ(z))z(1 - \sigma(z)): the product contribution from the input-dependent component

This derivative is smooth everywhere and never hard-zeros the gradient, which aids gradient flow in deep networks.

Swish vs GELU

Swish and GELU are closely related and perform similarly in practice. The main differences are:

  • Swish uses sigmoid as the gate function; GELU uses the normal CDF. Both give similar values in the range that matters for neural activations, because sigmoid and the normal CDF have similar shapes.
  • Swish has a learnable variant where the sigmoid is scaled by a learnable parameter β\beta: z⋅σ(βz)z \cdot \sigma(\beta z). When β=1\beta = 1, this is standard Swish. When β→0\beta \to 0, it approaches a linear function. When β→∞\beta \to \infty, the sigmoid sharpens into a step function and Swish approaches ReLU. This parameterization allows the network to learn the appropriate gate sharpness for each layer.
  • GELU is used more in NLP (following BERT's success); Swish/SiLU is more common in vision models and EfficientNet architectures.
  • For practical purposes, you can treat GELU and SiLU as interchangeable unless you have specific reasons to prefer one.

PyTorch provides both: torch.nn.GELU() and torch.nn.SiLU().