Swish · activation function

Also known as: SiLU · sigmoid linear unit

On this page 7

Swish is a smooth, non-monotonic activation function defined as f(x) = x · σ(βx), where σ is the logistic sigmoid and β is a constant or learnable parameter. With β equal to 1, it is identical to the SiLU, the sigmoid linear unit, and the two names are used interchangeably in neural networks literature and software libraries.

Swish became widely known in 2017, when researchers at Google Brain identified it through an automated search over candidate activation functions and reported consistent gains over ReLU on deep image classification and translation models. The same function had been described a year earlier as SiLU, which is why frameworks often label it that way. Today it underpins EfficientNet, MobileNetV3, many YOLO detectors and, through the SwiGLU variant, most large transformer language models.

How the Swish activation function behaves

Swish multiplies the input by a sigmoid gate computed from the same input, so each neuron decides softly how much of its own value to pass through. For large positive inputs the gate approaches 1 and Swish behaves like the identity. For large negative inputs the gate approaches 0 and the output decays smoothly toward zero instead of being cut off.

Between those regions the function dips below zero, reaching a global minimum of about −0.278 near x = −1.28 when β equals 1. This small negative region makes Swish non-monotonic, a property it shares with GELU and Mish but not with ReLU. The function is unbounded above, bounded below and continuously differentiable everywhere.

The following values show the shape for β equal to 1 and how it differs from ReLU around zero.

Input xSigmoid gate σ(x)Swish outputReLU output
−4.00.018−0.0720
−1.280.218−0.2780
0.00.5000.0000
1.00.7310.7311.0
4.00.9823.9284.0
Selected Swish values compared with ReLU

The role of the beta parameter

The parameter β controls how sharply the gate switches between closed and open. It can be fixed, which is the usual choice in practice, or learned per channel during training. Varying β makes Swish interpolate between a scaled linear function and ReLU.

Beta valueResulting functionPractical meaning
β = 0x / 2Linear, no nonlinearity at all
β = 1x · σ(x), the SiLUDefault in most frameworks
β ≈ 1.702Close to the sigmoid form of GELUNearly matches GELU behavior
β → ∞Approaches ReLUHard gate with a kink at zero
Effect of beta on the Swish curve

Learnable β adds only one parameter per channel, yet reported gains are small and inconsistent. Most production models therefore fix β at 1 and rely on the network depth, rather than on a tuned activation shape, for expressive power.

Why Swish trains well

Three properties explain the typical modest but repeatable accuracy gains of Swish over ReLU in deep networks. First, smoothness yields a continuous gradient, which gives the optimizer a better-behaved loss surface. Second, negative inputs still produce a nonzero gradient, so neurons do not become permanently inactive, which avoids the dying ReLU problem. Third, the bounded negative region acts as a mild self-regularizer by limiting how large negative activations can grow.

The derivative has a compact form for β equal to 1: f'(x) = f(x) + σ(x) · (1 − f(x)). Because it reuses the forward value, frameworks compute it efficiently during backpropagation. The derivative exceeds 1 slightly for moderate positive inputs, peaking at about 1.1 near x = 2.4, which helps the gradient flow without causing instability in normalized networks.

Swish compared with other activation functions

Swish belongs to a family of smooth ReLU alternatives that dominate modern architectures. The choice among them usually matters less than depth, normalization and data, but each has a typical home.

FunctionFormulaSmoothTypical use
ReLUmax(0, x)NoFast default for CNNs and MLPs
Swish or SiLUx · σ(βx)YesEfficientNet, YOLO, diffusion U-Nets
GELUx · Φ(x)YesBERT and many encoder transformers
Hard-swishx · ReLU6(x + 3) / 6PiecewiseMobile and quantized models
SwiGLUSwish(xW) ⊙ xVYesFeedforward blocks of large language models
Swish and related activation functions

SwiGLU deserves special attention. It is a gated linear unit in which Swish gates a second linear projection, and it has become the standard feedforward activation in many open-weight language model families. In that role, Swish is responsible for a large share of the compute in transformer layers.

Practical considerations and limitations

The main cost of Swish is computing an exponential for every activation, which makes it noticeably slower than ReLU on hardware without fused kernels. On mobile accelerators and in integer quantization, the sigmoid is awkward, which is why MobileNetV3 introduced the piecewise-linear hard-swish approximation.

  • Gains are architecture-dependent: shallow networks often show no benefit over ReLU.
  • Memory use rises slightly because the backward pass needs the input or the gate value.
  • Quantization needs care: the negative dip and the smooth knee lose precision at low bit widths.
  • Initialization schemes designed for ReLU, such as He initialization, still work but are not exactly matched.

When replacing ReLU with Swish in an existing model, practitioners usually keep the learning rate schedule and compare validation results over several seeds, since single runs rarely show differences larger than the natural run-to-run variance.

The decision table below summarizes when Swish is a sensible default and when another activation function is the better choice.

SituationRecommended choiceReason
Deep CNN trained on GPUsSwish or SiLUSmall accuracy gain at acceptable cost
Transformer feedforward blockSwiGLUGating improves quality per parameter
Mobile or 8-bit deploymentHard-swishCheap piecewise approximation
Shallow or latency-critical modelReLUFastest and rarely worse at small depth
Existing BERT-style encoderGELUMatches pretrained weights and tooling
Choosing between Swish and alternatives

Swapping the activation function of a pretrained model without retraining is not safe, because the learned weights assume the original nonlinearity. Fine-tuning after the swap, or keeping the original function, avoids a sudden drop in accuracy.

The idea in brief

Each neuron in a network decides how much signal to pass on. ReLU works like a light switch. Below zero it is off, above zero it is on.

Swish works like a dimmer instead. Strong signals pass almost fully. Weak or negative signals pass a little, or fade gently to nothing. This smoother behavior often helps deep networks learn slightly better, at the cost of a bit more computation.

A practical scenario

A machine learning engineer trains an image classifier for agricultural drones that must recognize crop diseases from leaf photos. The first version uses a ResNet-style network with ReLU and reaches 91.2 percent validation accuracy. The engineer swaps every ReLU for SiLU, keeps the optimizer and learning rate schedule unchanged and trains five runs with different seeds.

The Swish version averages about one percentage point higher accuracy, a gain larger than the spread between seeds, while training time per epoch rises by roughly eight percent. Because the model must run on the drone’s embedded processor with 8-bit integers, the engineer then replaces SiLU with hard-swish for deployment, keeping most of the accuracy gain while restoring inference speed close to the ReLU baseline.