All articles
Machine Learning
ml-neural

Mastering Batch Normalisation in Deep Learning

Understand the mechanics of batch normalisation, a critical technique for training stable and efficient deep neural networks in modern machine learning.

Math Instructor AI 22 September 2026 8 min read

Mastering Batch Normalisation in Deep Learning

In the field of deep learning, training very deep neural networks often feels like balancing a spinning plate on a needle. As the parameters of earlier layers change during training, the distribution of inputs to subsequent layers shifts constantly. This phenomenon, known as internal covariate shift, forces us to use lower learning rates and makes the choice of initial weights incredibly sensitive. Batch normalisation (BN) is the elegant solution that stabilises this process.

By normalising the activations of each layer to have a zero mean and unit variance for every mini-batch, BN allows for significantly higher learning rates and reduces the reliance on careful weight initialisation. For your university exams, understanding the mathematical transformation behind BN is essential, as it is a foundational component of modern architectures like ResNet and EfficientNet.

The Mathematical Foundation

Batch normalisation operates by transforming the activations of a layer. Given a mini-batch $B = {x_1, x_2, ..., x_m}$ of size $m$, the transformation occurs in two distinct phases. First, we standardise the inputs to ensure they have a mean of zero and a variance of one. Second, we introduce learnable parameters to allow the network to undo the normalisation if it proves detrimental to the model's representational power.

Step 1: Normalisation

We calculate the mini-batch mean $\mu_B$ and variance $\sigma_B^2$:

$$\mu_B = \frac{1}{m} \sum_{i=1}^{m} x_i$$ $$\sigma_B^2 = \frac{1}{m} \sum_{i=1}^{m} (x_i - \mu_B)^2$$

Then, we normalise the input $x_i$ to get $\hat{x}_i$:

$$\hat{x}_i = \frac{x_i - \mu_B}{\sqrt{\sigma_B^2 + \epsilon}}$$

Here, $\epsilon$ is a small constant (e.g., $10^{-5}$) added for numerical stability to prevent division by zero.

Step 2: Scale and Shift

To ensure the layer can represent any distribution, we apply a linear transformation using learnable parameters $\gamma$ (scale) and $\beta$ (shift):

$$y_i = \gamma \hat{x}_i + \beta$$

Worked Example 1: Manual Calculation

Consider a mini-batch of size $m=2$ with activations $x_1 = 1.0$ and $x_2 = 3.0$. Assume $\epsilon = 0$.

  1. Calculate the mean: $\mu_B = (1.0 + 3.0) / 2 = 2.0$.
  2. Calculate the variance: $\sigma_B^2 = [(1.0 - 2.0)^2 + (3.0 - 2.0)^2] / 2 = [1 + 1] / 2 = 1.0$.
  3. Normalise: $\hat{x}_1 = (1.0 - 2.0) / \sqrt{1.0} = -1.0$ and $\hat{x}_2 = (3.0 - 2.0) / \sqrt{1.0} = 1.0$.
  4. If we set $\gamma = 1$ and $\beta = 0$, the output $y_i$ remains ${-1.0, 1.0}$.

Worked Example 2: Applying Learnable Parameters

Using the same normalised values $\hat{x} = {-1.0, 1.0}$, suppose the network has learned $\gamma = 2$ and $\beta = 5$ through backpropagation.

  1. Apply the transformation: $y_i = \gamma \hat{x}_i + \beta$.
  2. $y_1 = 2(-1.0) + 5 = 3.0$.
  3. $y_2 = 2(1.0) + 5 = 7.0$.

This demonstrates how the network can shift the mean and scale the variance to suit the specific requirements of the subsequent layer.

Why Batch Normalisation Improves Training Stability

Batch normalisation acts as a regulariser. Because the mean and variance are calculated over a mini-batch, they introduce a small amount of noise into the activations. This noise prevents the model from overfitting to specific training examples, often reducing the need for dropout. Furthermore, by keeping activations within a stable range, it prevents gradients from vanishing or exploding, which is particularly beneficial when using saturating activation functions like sigmoid or tanh.

Common Mistakes

  1. Ignoring the Test Phase: During inference, you cannot calculate a mini-batch mean. You must use the running average of the mean and variance calculated during training.
  2. Applying BN after Activation: While debated, BN is traditionally applied before the non-linear activation function to ensure the inputs to the activation are centred.
  3. Small Batch Sizes: BN relies on the batch statistics being representative of the dataset. If the batch size is too small, the noise in the mean and variance estimates can destabilise training.

Frequently Asked Questions

Does Batch Normalisation replace Dropout? Often, yes. BN provides a regularisation effect that can make dropout redundant, though some architectures use both.

What happens if the batch size is 1? BN cannot be computed because the variance would be zero. BN requires a batch size greater than 1, and typically performs best with sizes of 32 or higher.

Is BN used in Recurrent Neural Networks? Standard BN is difficult to apply to RNNs due to the temporal dependency of hidden states. Variants like Layer Normalisation are often preferred.

Conclusion

Batch normalisation is a cornerstone of modern deep learning, transforming how we train deep architectures. By mastering these concepts, you are well-equipped to tackle complex neural network design. To see these concepts in action with visual, narrated explanations, head over to MathInstructor AI and generate your free animated lesson on batch normalisation today.

Topics

batch normalisation
deep learning
neural networks
machine learning
training stability
ml-neural
gradient descent
internal covariate shift

Want this explained out loud?

Turn any question into a narrated, animated lesson in seconds.

Try the Studio free