Activation Functions › Mish

Michael BrenndoerferApril 21, 20254 min read
Language AI HandbookAll chapters
Part 10 of 67Neural Network Foundations
Chapter 62Activation Functions › Mish
Reading section 8 of 16 · Mish · 4 minSection 8 of 16 · 4 min

Book contents

Section 8 of 16 · 4 min read

Activation Functions › MishOne section · Sections in this chapter8 / 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

Mish, proposed by Diganta Misra in 2019, is a self-regularized non-monotone activation that has been used successfully in computer vision and some NLP applications.

Definition

Mish is defined as:

Mish(z)=z⋅tanh⁡(softplus(z))=z⋅tanh⁡ ⁣(ln⁡(1+ez))\text{Mish}(z) = z \cdot \tanh(\text{softplus}(z)) = z \cdot \tanh\!\left(\ln(1 + e^z)\right)

where:

  • zz: the pre-activation value
  • softplus(z)=ln⁡(1+ez)\text{softplus}(z) = \ln(1 + e^z): a smooth approximation to the ReLU function that avoids the hard zero
  • tanh⁡(⋅)\tanh(\cdot): the hyperbolic tangent applied to the softplus output

Mish, like Swish and GELU, is non-monotone with a slight negative region near its minimum. Its output is unbounded above (the positive side grows like the identity) but bounded below by approximately −0.31-0.31. The softplus inner function smoothly transitions from near-zero for large negative inputs to near-linear for large positive inputs, and the tanh applied to it produces a gate that smoothly goes from 0 to 1. The product z⋅gatez \cdot \text{gate} then passes increasingly more of the input as zz grows more positive.

The derivative of Mish:

d Mish(z)dz=tanh⁡ ⁣(softplus(z))+z⋅sech2 ⁣(softplus(z))⋅σ(z)\frac{d\,\text{Mish}(z)}{dz} = \tanh\!\left(\text{softplus}(z)\right) + z \cdot \text{sech}^2\!\left(\text{softplus}(z)\right) \cdot \sigma(z)

where:

  • sech2(⋅)\text{sech}^2(\cdot): the derivative of tanh
  • σ(z)\sigma(z): the sigmoid function, which is the derivative of softplus

Mish is more computationally expensive than GELU or Swish due to the compound computation involving both a softplus and a tanh. However, benchmarks show it outperforms ReLU on image classification tasks, and it has been adopted in YOLO-based object detection architectures where the small accuracy gain per layer compounds across the many layers in the network. For NLP tasks, the differences compared to GELU are small enough that GELU remains the default.

The key insight behind Mish is that applying tanh to softplus creates a particularly smooth gate: softplus is infinitely differentiable, and applying another smooth function to it produces a gate with very gentle second-order derivatives. This smoothness in the gate function translates to smoothness in the overall activation, which tends to produce better-conditioned optimization landscapes.

The next figure compares GELU, Swish/SiLU, and Mish, showing how these modern smooth activations resemble each other while differing from ReLU in the negative region:

Out[6]:
Visualization
Line plot comparing GELU, Swish, Mish, and ReLU activation values.
GELU, Swish/SiLU, and Mish activation functions alongside ReLU for reference over the input range [-4, 4]. All three smooth activations have a slight negative dip before recovering to zero, unlike ReLU's hard clip at zero. GELU and Swish are nearly identical for inputs above -2.
Line plot comparing GELU, Swish, and Mish derivatives showing smooth nonzero gradients.
GELU, Swish/SiLU, and Mish activation functions alongside ReLU for reference over the input range [-4, 4]. All three smooth activations have a slight negative dip before recovering to zero, unlike ReLU's hard clip at zero. GELU and Swish are nearly identical for inputs above -2.