The Nonlinearity Index

Use cases

Which activation, for which job?

Tendencies, not territories.

No activation function belongs to a domain. What carries over between tasks are properties: smooth gradients, sparsity, bounded outputs, gating, usable higher derivatives. This guide shows which functions practitioners tend to reach for in 19 kinds of tasks and architectures, and explains which property makes each one a good fit.

19 use cases

Language

Transformer feed-forward blocks

LLMs, encoder and decoder Transformers

Typical picks

Properties that matter

  • Multiplicative gating
  • Smooth gradients

The feed-forward blocks hold most of a Transformer's parameters, so their activation matters. Smooth, self-gated units such as GELU beat ReLU slightly, and multiplicative GLU gates (SwiGLU, GEGLU) lower perplexity further at equal compute: the gate lets each hidden unit scale its value path by an input-dependent amount. Gating helps most, though Squared ReLU, which has no gate, is also competitive, so the gain isn't only about gating.

Watch out: GLU variants use three weight matrices instead of two; shrink the hidden size to about 2/3 to keep the parameter count equal.

LLaMA, PaLM, Mistral (SwiGLU) · T5 v1.1, Gemma (GEGLU) · BERT, GPT-2 (GELU)

Language

Attention weights

Self- and cross-attention in any Transformer

Typical picks

Properties that matter

  • Probabilistic output
  • Sparsity

Attention needs non-negative weights that sum to one over the keys. Softmax gives that smoothly but never assigns exact zeros, so some weight leaks to every token. Sparsemax and entmax can zero out irrelevant tokens, which makes attention easier to interpret and can help when only a few positions matter.

Watch out: Always subtract the maximum score before exponentiating; scaling scores by 1/√d keeps softmax out of its saturated regime.

Vision

Image classification CNNs

ResNets, EfficientNets, detectors such as YOLO

Typical picks

Properties that matter

  • Cheap to compute
  • Sparsity
  • Smooth gradients

ReLU has been the default since AlexNet: it's cheap, sparse and pairs well with batch normalisation. In larger and deeper models, smooth self-gated activations such as SiLU and Mish usually add a fraction of a percent of accuracy, because their gradients don't switch off abruptly and their small negative lobe keeps some information from negative inputs.

Watch out: Gains from swapping activations are small next to architecture, data augmentation and training schedule changes.

ResNet (ReLU) · EfficientNet (SiLU) · YOLOv4 (Mish) · MobileNetV3 (hard swish)

Vision

Medical image segmentation

U-Net style encoder–decoders for 2D and 3D scans

Typical picks

Properties that matter

  • Sparsity
  • No dead units
  • Probabilistic output

Encoders and decoders mostly use ReLU-family units: sparse activations act like a learned feature selector and stay cheap on large 3D volumes. Medical datasets are small and training often uses tiny batches with instance normalisation, which makes dead units more costly, so a small negative slope (Leaky ReLU, PReLU) is common. Per-voxel sigmoid or softmax outputs give the probabilities that overlap losses such as Dice work with.

Watch out: The output activation must match the label structure: sigmoid for overlapping structures, softmax for mutually exclusive classes.

U-Net (ReLU) · nnU-Net (Leaky ReLU, 0.01)

Efficiency

Mobile, edge and quantised inference

MobileNets, on-device models, int8 deployment

Typical picks

Properties that matter

  • Cheap to compute
  • Quantisation-friendly
  • Bounded output

On phones and microcontrollers, exponentials are slow and activations are often stored as 8-bit integers. Piecewise-linear functions need only comparisons and multiplications, and a bounded range (ReLU6 caps at 6) lets a fixed-point format cover every value without overflow. Hard swish and hard sigmoid keep most of the accuracy of their smooth versions at a fraction of the cost.

Watch out: Check which activations your target runtime fuses into the preceding convolution; an unfused activation can cost more than its arithmetic suggests.

MobileNetV2 (ReLU6) · MobileNetV3 (hard swish, hard sigmoid)

Sequences & time series

Financial and noisy time-series forecasting

LSTM/GRU forecasters, temporal convolutional and Transformer models

Typical picks

Properties that matter

  • Smooth gradients
  • Zero-centred
  • No dead units
  • Bounded output

Financial series have a low signal-to-noise ratio, shift between regimes and offer relatively little independent data. Smooth activations give smoother fitted functions and steadier gradients, so the model is less prone to the piecewise artefacts and abrupt switching of ReLU units on noisy inputs. Zero-centred, non-dying units (tanh, ELU, GELU) keep small signals alive, and tanh keeps recurrent state bounded over long sequences. Outputs follow the target: linear for returns, softplus or exponential for strictly positive volatility.

Watch out: Activation choice is a minor lever compared with leakage-free validation, regime shifts and feature design. Don't over-tune it on one backtest.

LSTM/GRU forecasters (tanh) · Temporal Fusion Transformer (ELU + GLU gating)

Sequences & time series

Recurrent networks (LSTM, GRU)

LSTM and GRU cells

Typical picks

  • Sigmoidinput, forget and output gates
  • Tanhcandidate state and output

Properties that matter

  • Bounded output
  • Multiplicative gating
  • Zero-centred

Gates need values in (0, 1) to act as soft switches that decide how much to keep, write and read, which is exactly the sigmoid's range. The candidate state uses tanh because it's bounded and zero-centred, which stops the cell state from drifting or blowing up as it's updated over hundreds of steps.

Watch out: Saturated gates stop gradients; initialising the forget-gate bias to about 1 helps the cell remember early in training.

Generative

Generative adversarial networks

DCGAN-style generators and discriminators, StyleGAN

Typical picks

Properties that matter

  • No dead units
  • Bounded output

The discriminator must pass useful gradients to the generator even for samples it confidently rejects, so a leaky slope (usually 0.2) is standard. The generator's output uses tanh because training images are scaled to [−1, 1], and a bounded output can't produce out-of-range pixels.

Watch out: GAN stability depends far more on the loss, normalisation and learning rates than on activation choice.

DCGAN · StyleGAN (Leaky ReLU 0.2)

Generative

Diffusion model denoisers

U-Nets and diffusion Transformers (DiT)

Typical picks

Properties that matter

  • Smooth gradients
  • Multiplicative gating

The denoiser has to represent a smooth function of the noisy input across many noise levels. SiLU paired with group normalisation became the standard in diffusion U-Nets after DDPM, and diffusion Transformers inherit the GELU MLPs of vision Transformers. Smooth activations avoid the blocky artefacts that hard kinks can introduce into generated images.

Watch out: Keep the activation consistent with any pretrained weights you fine-tune.

DDPM, Stable Diffusion U-Nets (SiLU) · DiT (GELU, tanh approximation)

Science & simulation

Implicit neural representations

Coordinate MLPs: NeRF, SIREN, neural fields

Typical picks

Properties that matter

  • Periodic bias
  • Usable higher derivatives
  • Smooth gradients

A plain ReLU MLP fed raw coordinates is biased toward low frequencies, so it blurs fine detail in images, shapes and scenes. Either encode the inputs with Fourier features (NeRF) or use periodic or Gaussian activations directly (SIREN). Sine activations also have smooth, non-zero derivatives of every order, which lets the network fit gradients and Laplacians of signals.

Watch out: Sine networks need their special initialisation and frequency scale ω₀; with a default initialisation they train poorly.

SIREN (sine) · NeRF (ReLU + positional encoding)

Science & simulation

Physics-informed neural networks

PINNs and neural PDE solvers

Typical picks

Properties that matter

  • Usable higher derivatives
  • Smooth gradients

The loss contains the PDE residual, which needs second or higher derivatives of the network's output with respect to its inputs. ReLU's second derivative is zero almost everywhere, so it can't represent terms such as a Laplacian. Infinitely differentiable activations like tanh and sine keep those derivatives informative.

Watch out: Tanh saturates in deep PINNs; adaptive (learned-slope) activations and input scaling are common fixes.

Science & simulation

Molecular and materials modelling

Interatomic potentials, message-passing networks on atoms

Typical picks

Properties that matter

  • Smooth gradients
  • Usable higher derivatives

Forces are the negative gradient of the predicted energy, and molecular dynamics integrates them over millions of steps. Smooth activations give smooth potential-energy surfaces and continuous forces; a kink in the activation becomes a discontinuous force, which breaks energy conservation in simulation.

Watch out: Also check that the network's other components (cutoffs, radial bases) are smooth.

SchNet (shifted softplus) · NequIP (SiLU)

Graphs & tabular

Graph neural networks

GCN, GAT, GraphSAGE and other message-passing networks

Typical picks

Properties that matter

  • Cheap to compute
  • No dead units

Message passing is applied at every node in every layer, so cheap activations are the norm. Graph attention computes its edge scores with a Leaky ReLU (slope 0.2) before the softmax so that negative scores still receive gradient, and uses ELU in hidden layers.

Watch out: Depth, over-smoothing and normalisation usually matter more than the activation in GNNs.

GCN (ReLU) · GAT (Leaky ReLU + ELU)

Graphs & tabular

Deep tabular models and deep MLPs

MLPs and Transformers on tabular features

Typical picks

  • SELUself-normalising MLPs
  • ReGLUFT-Transformer
  • ReLUbaseline MLPs
  • GELUTransformer variants

Properties that matter

  • Self-normalising
  • Multiplicative gating

Tabular data rarely suits convolutions, so models are deep fully connected networks. SELU lets those networks train without batch normalisation by keeping activations self-normalised, which helps with small batches and heterogeneous features. Tabular Transformers borrow GLU-style feed-forward blocks.

Watch out: Gradient-boosted trees remain a very strong baseline on tabular data; compare against one.

Self-normalising networks (SELU) · FT-Transformer (ReGLU)

Control

Reinforcement learning policies and value functions

Actor–critic MLPs (PPO, SAC, TD3)

Typical picks

  • Tanhhidden layers in many PPO setups; bounded actions
  • ReLUSAC, TD3 hidden layers
  • Identityvalue outputs
  • Softmaxdiscrete action probabilities

Properties that matter

  • Bounded output
  • Smooth gradients
  • Probabilistic output

On-policy methods such as PPO are sensitive to sudden changes in the policy, and many implementations use tanh hidden units because bounded, smooth activations keep updates steady. Off-policy methods (SAC, TD3) typically use ReLU. For continuous actions, a final tanh squashes the output into the action bounds, and discrete policies use a softmax over actions.

Watch out: Implementation details (observation normalisation, initialisation) often outweigh the activation; keep them fixed when comparing.

Stable-Baselines3 PPO (tanh by default) · SAC (ReLU)

Generative

Audio and waveform generation

Neural vocoders, autoregressive audio models

Typical picks

Properties that matter

  • Periodic bias
  • Multiplicative gating

Waveforms are dominated by periodic components. Snake adds a periodic term to the identity, which gives the generator an inductive bias toward pitch and harmonics and improves out-of-distribution audio. WaveNet's gated tanh unit lets each layer decide how much of its filtered signal to pass on.

Watch out: Periodic activations need sensible frequency initialisation; with learnable frequencies, monitor them during training.

WaveNet (gated tanh) · HiFi-GAN (Leaky ReLU) · BigVGAN (Snake)

Science & simulation

Sparse coding and denoising

Unrolled optimisation networks (LISTA), denoisers

Typical picks

Properties that matter

  • Sparsity

Iterative sparse-coding algorithms alternate a linear step with soft thresholding, the proximal operator of the L1 penalty. Unrolling those iterations into layers turns the threshold into the activation, so the network inherits the algorithm's sparsity and converges in far fewer steps.

Watch out: The threshold λ is usually learned per layer; initialise it from the regularisation strength.

Outputs

Output layers: matching the target

Final layer of any model

Typical picks

Properties that matter

  • Probabilistic output
  • Bounded output

The output activation encodes the range of the target and pairs with a likelihood: sigmoid with binary cross-entropy, softmax with categorical cross-entropy, identity with squared error, exponential or softplus with Poisson or Gaussian scale parameters. In medical survival analysis, the complementary log-log link gives a discrete-time proportional-hazards model.

Watch out: Use the fused, numerically stable loss (BCE with logits, cross-entropy on raw logits) rather than applying the activation yourself.

Efficiency

Binary and spiking neural networks

1-bit networks, neuromorphic and spiking models

Typical picks

Properties that matter

  • Cheap to compute
  • Sparsity

With ±1 activations and weights, multiplications become XNOR and bit-count operations, which saves a great deal of energy and memory. Spiking neurons emit binary events, so activity is sparse in time. Both are trained with surrogate gradients: the forward pass uses the hard step, and the backward pass pretends it was a smooth or clipped function such as hard tanh.

Watch out: Expect an accuracy gap compared with full-precision networks, especially on large tasks.

Property matrix

Which properties each use case relies on. Read down a column to see where a property matters; hover a heading for its definition.

By function

The same information turned around: every function that appears above, with the use cases it's picked for. Most show up in several unrelated areas, which is the point.

FunctionCurveUse casesWhere
ReLU10Transformer feed-forward blocks, Image classification CNNs, Medical image segmentation, Mobile, edge and quantised inference, Generative adversarial networks, Implicit neural representations, Graph neural networks, Deep tabular models and deep MLPs, Reinforcement learning policies and value functions, Sparse coding and denoising
Tanh6Financial and noisy time-series forecasting, Recurrent networks (LSTM, GRU), Generative adversarial networks, Physics-informed neural networks, Reinforcement learning policies and value functions, Output layers: matching the target
Leaky ReLU5Image classification CNNs, Medical image segmentation, Generative adversarial networks, Graph neural networks, Audio and waveform generation
SiLU / Swish5Image classification CNNs, Financial and noisy time-series forecasting, Diffusion model denoisers, Physics-informed neural networks, Molecular and materials modelling
Softmax4Attention weights, Medical image segmentation, Reinforcement learning policies and value functions, Output layers: matching the target
GELU3Transformer feed-forward blocks, Financial and noisy time-series forecasting, Deep tabular models and deep MLPs
Identity3Financial and noisy time-series forecasting, Reinforcement learning policies and value functions, Output layers: matching the target
Sigmoid3Medical image segmentation, Recurrent networks (LSTM, GRU), Output layers: matching the target
Softplus3Financial and noisy time-series forecasting, Physics-informed neural networks, Output layers: matching the target
ELU2Financial and noisy time-series forecasting, Graph neural networks
GEGLU2Transformer feed-forward blocks, Diffusion model denoisers
GELU (tanh approximation)2Transformer feed-forward blocks, Diffusion model denoisers
Hard swish2Image classification CNNs, Mobile, edge and quantised inference
PReLU2Image classification CNNs, Medical image segmentation
Sine (SIREN)2Implicit neural representations, Physics-informed neural networks
1.5-entmax1Attention weights
Binary step1Binary and spiking neural networks
Complementary log-log1Output layers: matching the target
Exponential1Output layers: matching the target
Gated tanh unit1Audio and waveform generation
Gaussian1Implicit neural representations
Hard shrink1Sparse coding and denoising
Hard sigmoid1Mobile, edge and quantised inference
Hard tanh1Binary and spiking neural networks
Mish1Image classification CNNs
ReGLU1Deep tabular models and deep MLPs
ReLU61Mobile, edge and quantised inference
SELU1Deep tabular models and deep MLPs
Shifted softplus1Molecular and materials modelling
Sign1Binary and spiking neural networks
Snake1Audio and waveform generation
Soft shrink1Sparse coding and denoising
Sparsemax1Attention weights
Squared ReLU1Transformer feed-forward blocks
SwiGLU1Transformer feed-forward blocks