Foundations to Frontier
Tests
E. Deep Learning › E1 Activation Functions (one page each)

Mish

Mish, z·tanh(softplus(z)), is another smooth, self-gated, non-monotonic activation in the family of SiLU and GELU. Its gate tanh(softplus(z)) is steeper than SiLU's sigmoid, so it passes 60% of a small input instead of 50%, and its dip reaches −0.309. It was popularised by YOLOv4, where it gave small accuracy gains in detection backbones. This page covers the definition, its gradient, a one-exponential implementation, its minimum, the initialisation gain it needs, and the claim that it degrades less with depth. In the exercises you implement Mish efficiently, then train plain 8- and 24-layer networks with ReLU, SiLU and Mish, each with its own variance-preserving initialisation.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A gate built from tanh and softplus

Mish follows the SiLU recipe of multiplying an input by a gate computed from itself, but with a different gate: tanh(softplus(z)). That gate is 0 for very negative inputs, 1 for large positive ones, and 0.6 at zero. The curve looks like SiLU, slightly steeper near zero and with a slightly deeper dip.

Activation lab: the curve, its slope, and what a network learns with it
z from −4 to 4 · orange f · dashed blue f′
Mish: training accuracy after 300 steps 0.993
Compare activations at the same number of steps. Smooth, non-saturating units usually fit the spirals fastest. Sigmoid and the hard-threshold units learn slowly or need surrogate gradients. Gated and maxout units use twice as many hidden pre-activations. Learning rates are fixed per activation and not tuned, so treat small differences as noise (press "new data and weights").
Why engineers care

Mish became widely known through YOLOv4, an object detector used on drones, robots and traffic cameras. It costs more than ReLU per element (an exponential, a logarithm and a tanh in the naive form), which matters on embedded hardware, so an efficient implementation and an honest view of its benefit both matter.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Mish(z) =
  2. 2. Mish's gate at z = 0 is…
  3. 3. Mish is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Values by hand

  • Definition: Mish(z) = z·tanh(softplus(z)) = z·tanh(log(1 + eᶻ)).
  • Values: Mish(0) = 0; Mish(1) ≈ 0.865; Mish(−1) ≈ −0.303; Mish(50) = 50 to double precision.
  • Gradient: with t = tanh(softplus(z)), Mish′(z) = t + z(1 − t²)σ(z). Mish′(0) = 0.6 and Mish′(1) ≈ 1.049.
  • Slope at the origin: for any f(z) = z·g(z), f′(0) = g(0). So Mish’s slope at 0 is tanh(log 2) = 0.6, against 0.5 for SiLU and GELU.
  • Minimum: ≈ −0.309 at z ≈ −1.192, deeper than SiLU’s −0.278 and GELU’s −0.170.
  • One exponential: with e = eᶻ and n = e(e + 2), tanh(softplus(z)) = n/(n + 2). Algebra: tanh(log u) = (u² − 1)/(u² + 1) with u = 1 + e, and u² − 1 = e(e + 2).
📝 Quick check (Level 1)
0/3 answered
  1. 1. Mish′(0) =
  2. 2. Mish's minimum is about…
  3. 3. tanh(log u) equals…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Implementing it efficiently

Exercise 1. The analytic gradient matches finite differences. The one-exponential form agrees with the definition to within 10⁻¹² over [−40, 40] (the exponent is capped at 20, where the gate already equals 1 in double precision). A golden-section search finds the minimum, −0.3088 at z = −1.1924. The slope at 0 is exactly 0.6.

Initialisation. A variance-preserving gain is 1/E[f(z)²] for z ~ N(0, 1), so that Var(w) = gain/fan-in keeps the second moment near 1.

activation gain
ReLU 2.000 (He)
Mish 2.211
SiLU 2.811

Using He’s gain of 2 for SiLU or Mish shrinks the signal layer by layer. Iterating the variance map for 24 layers from 1 gives about 2 × 10⁻⁷ for SiLU and 0.004 for Mish.

Cost. The naive Mish needs exp, log1p and tanh; the one-exponential form needs one exp and a division. Frameworks provide fused kernels.

nn.Mish()            # PyTorch built-in
x * torch.tanh(F.softplus(x))
🐍 Exercise 1: Mish, its gradient and a fast form
Implement Mish and its gradient, a one-exponential version, and find the minimum by golden-section search.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Mish's variance-preserving gain is about…
  2. 2. Initialising SiLU with He's gain 2 makes deep signals…
  3. 3. The fast form of Mish needs…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Design. Misra (2019) searched for activations similar to Swish and found z·tanh(softplus(z)). The properties he emphasised are shared with SiLU and GELU:

  • unbounded above, which avoids saturation for positive inputs;
  • bounded below, a mild regulariser;
  • smooth, which he argued gives a smoother loss landscape;
  • non-monotonic, keeping small negative signals.

Mish versus SiLU. Both are z times a gate. Mish’s gate rises more steeply around 0 (0.6 at the origin, against 0.5), so near zero Mish is closer to the identity on the positive side and a little more nonlinear around the bend. In most benchmarks the two perform within noise of each other.

Reported results.

  • Misra reported small accuracy gains over Swish and ReLU on CIFAR and ImageNet. He also reported that Mish networks lost less accuracy as plain networks grew deeper (MNIST, 15–25 layers).
  • Bochkovskiy, Wang and Liao (2020) used Mish in the CSPDarknet53 backbone of YOLOv4 and reported a gain of about 1 point of top-1 accuracy on ImageNet for the backbone.
  • These gains are modest and depend on the architecture, the training recipe and normalisation.

What makes deep plain networks fragile. Without normalisation or residual connections, deep networks are sensitive to:

  • initialisation (E0-7);
  • the activation’s slope near zero;
  • the learning rate.

The outcome can change completely with tiny changes in the initial weights. Exercise 2 saw exactly this, which is why results at depth 24 must be read across seeds.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Mish was popularised by…
  2. 2. Mish versus SiLU in most benchmarks…
  3. 3. Misra's depth claim concerned…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Does Mish survive depth better?

History.

  • D. Misra (2019) introduced Mish.
  • A. Bochkovskiy, C.-Y. Wang and H.-Y. M. Liao (2020) used it in YOLOv4.
  • Later detectors (YOLOv5 onward) mostly switched to the cheaper SiLU.

Exercise 2. Plain MLPs (width 32, no normalisation, no residual connections) on spirals, trained for 300 steps of minibatch SGD at learning rate 0.05. Each activation uses its own variance-preserving gain, so that the initialisation is fair. Training accuracy per seed (nan = diverged):

activation depth 8 depth 24
ReLU 1.000, 1.000, 1.000 1.000, 0.547, 0.328
SiLU 1.000, 0.998, 0.998 nan, 0.777, nan
Mish 1.000, 0.998, 1.000 0.998, 1.000, 0.840

Three further seeds at depth 24 gave ReLU 0.628, 0.760, 0.833; SiLU 0.998, 0.478, nan; Mish 0.865, 1.000, 0.985.

  • At depth 8 there was no difference. Every activation trained perfectly.
  • At depth 24, Mish was the most reliable. It never diverged, and averaged 0.95 over six seeds against 0.68 for ReLU. SiLU diverged in half the runs.
  • The depth-24 regime is chaotic. Changing ReLU’s gain from 2 to 1.99999999999 (a rounding difference) changed its seed-by-seed results completely. Only the pattern across seeds is meaningful.
  • It was not an initialisation artefact. An earlier probe that gave all activations He’s gain of 2 also found Mish trained well at depth 24, while SiLU stalled at about 0.35 in all six seeds.
  • Caveats. One task, one learning rate and one width. In practice, normalisation and residual connections (E0-9) remove most of this depth sensitivity, and with them the activations perform similarly.
🐍 Exercise 2 (research): does Mish survive depth better?
Train plain 8- and 24-layer networks with ReLU, SiLU and Mish, each with its own variance-preserving initialisation gain, and compare training accuracy across seeds.

Mish in AI, robotics and aerospace

  • Detection: YOLOv4 with Mish was widely deployed for real-time detection on drones, robots and edge GPUs.
  • Embedded deployment: because of its cost, Mish is often replaced by SiLU, hard-swish or a lookup table when porting models to microcontrollers and NPUs. Re-validate accuracy after any such substitution.
  • Deep plain networks: where normalisation layers are undesirable (very small batches, some control networks), activation choice and initialisation matter more, as exercise 2 shows.

References

  1. D. Misra (2020). “Mish: a self regularized non-monotonic activation function.” Proc. BMVC. (arXiv:1908.08681, 2019.)
  2. A. Bochkovskiy, C.-Y. Wang, H.-Y. M. Liao (2020). “YOLOv4: optimal speed and accuracy of object detection.” arXiv:2004.10934.