Recommended resources
The freely available resources this lesson will direct you to.
- Batch Normalization | Internal Covariate Shift | Deep Learning Part 8www.youtube.com
- Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shiftwww.youtube.com
- [1502.03167] Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shiftar5iv.labs.arxiv.org
- Batch normalization in 3 levels of understandingtowardsdatascience.com
Introduction
Welcome to our next lesson on the essential techniques for training deep neural networks. In our previous session, we examined dropout, a clever regularization method that prevents overfitting by stochastically deactivating neurons during training. Now, we turn our attention from regularization to another fundamental challenge: the stability and speed of the training process itself.
This lesson introduces Batch Normalization (BN), a technique that has become a standard component in most modern deep learning architectures. We will explore its mechanism, the problem it was originally designed to solve—known as internal covariate shift—and the critical differences in its behavior during the training and inference phases. Finally, we will go beyond the original paper's hypothesis to discuss the modern understanding of why Batch Normalization is so effective.
The Problem: Internal Covariate Shift
Training a very deep neural network is notoriously difficult. As training progresses, the weights in each layer are updated. This means that the distribution of the inputs to a subsequent layer is constantly changing. For example, the distribution of activations fed into layer 4 will change every time the weights in layers 1, 2, and 3 are updated.
The original authors of Batch Normalization termed this phenomenon Internal Covariate Shift (ICS). Each layer in the network is essentially trying to learn from a moving target, continuously adapting to a new input distribution from the preceding layer. This instability creates several problems:
- It forces the use of very small learning rates to prevent the training process from becoming unstable or diverging.
- It makes the network highly sensitive to the initial values of the weights.
- It can cause neurons with saturating activation functions (like the sigmoid) to get "stuck" in their saturated regions, where gradients are close to zero, effectively halting learning.
To understand the authors' original motivation, let's turn to the seminal paper that introduced this concept.
This is the original paper by Ioffe and Szegedy. Reading the abstract and introduction will provide you with the formal definition of Internal Covariate Shift and the authors' high-level reasoning for proposing Batch Normalization.
Please read the Abstract for a concise overview. Then, read the Introduction section, paying close attention to the paragraphs where the authors define and explain Internal Covariate Shift and its detrimental effects on training deep networks.
The core idea proposed to solve this is deceptively simple: what if we could force the distribution of each layer's inputs to remain more stable throughout training?
The Mechanism of Batch Normalization
Batch Normalization addresses ICS by explicitly normalizing the inputs to a layer. The "batch" in the name refers to the fact that this normalization is performed using the statistics (mean and variance) of the current mini-batch of data.
The process is typically applied to the pre-activations, , which are the linear outputs of a layer before the non-linear activation function is applied. For a mini-batch of examples, the BN algorithm performs the following steps for each feature (or neuron output) independently:
-
Calculate Mini-Batch Mean: Compute the mean of the activations for the current mini-batch.
-
Calculate Mini-Batch Variance: Compute the variance of the activations for the current mini-batch.
-
Normalize: Normalize each activation using the mini-batch mean and variance. A small constant is added for numerical stability to avoid division by zero.
At this point, the activations for the mini-batch have a mean of approximately 0 and a variance of 1. -
Scale and Shift: Simply forcing the activations to a standard normal distribution could limit the network's expressive power. For example, for a sigmoid activation function, this would constrain the inputs to its linear regime. To overcome this, BN introduces two new learnable parameters for each feature: a scale parameter and a shift parameter . The final output of the BN layer is:
These parameters and are learned via backpropagation along with the network's weights. They allow the network to learn the optimal mean and variance for each layer's inputs. In the extreme case, if the network determines that the original activations were best, it can learn to set and , effectively recovering the identity transformation.
The following video provides a clear walkthrough of this process.
Batch Normalization | Internal Covariate Shift | Deep Learning Part 8
This segment from ByteQuest explains the mathematical steps of Batch Normalization and the role of the learnable gamma and beta parameters.
Please watch the section from this timestamp. Pay attention to how the learnable parameters \gamma and \beta allow the network to control the distribution and why the original bias term of a layer becomes redundant when using BN.
When visualized across a data tensor (N, C, H, W for images), Batch Norm computes its statistics across the batch dimension (N) for each channel (C), as shown below.

The Critical Distinction: Training vs. Inference
The dependency on mini-batch statistics creates a crucial difference between how Batch Normalization operates during training versus during inference (or testing).
During Training: We use the mean and variance of the current mini-batch to perform the normalization, as described above.
During Inference: We often want to make a prediction for a single input example. In this case, a "mini-batch" of size one has a meaningless variance of zero. Furthermore, we need the model's output to be deterministic for a given input; it shouldn't depend on what other inputs are processed alongside it.
The solution is to use an estimate of the entire training set's population statistics. During the training phase, BN layers not only calculate mini-batch statistics but also maintain an exponentially moving average of the mean and variance seen across all mini-batches.
At inference time, these fixed, pre-computed population statistics are used in the normalization step instead of mini-batch statistics. The BN layer effectively becomes a simple linear transformation, applying a fixed scale and shift to the activations.
This distinction is fundamental to understanding and correctly implementing BN.
Batch normalization in 3 levels of understanding
This article provides an excellent breakdown of how BN's behavior changes between training and evaluation, and some of the practical consequences of this design.
Please read the sections B.1.1) Training and B.1.2) Evaluation for a clear summary of the two modes. Then, read section C.2.3) and C.2.4), which discuss the practical challenges and potential instabilities that can arise from this train/test discrepancy, especially when the test data distribution differs from the training data.
The visual effect of Batch Normalization is striking. The distributions of activations in deeper layers remain much more stable throughout training, preventing the erratic shifts and saturation seen in standard networks.

Why Does Batch Normalization Really Work?
For several years after its publication, the reduction of Internal Covariate Shift was the accepted explanation for BN's success. However, subsequent research has challenged this view. A 2018 paper titled "How Does Batch Normalization Help Optimization?" showed that even in the presence of significant internal covariate shift, BN still improved performance. They also found that BN's impact on the stability of layer input distributions was not as significant as previously believed.
This has led to a new, more widely accepted hypothesis: Batch Normalization works primarily by smoothing the optimization landscape.
What does this mean?
- The loss surface becomes less "jagged" and more predictable. This makes the gradient a more reliable estimate of the direction of steepest descent.
- By making the landscape smoother, BN allows for the use of much higher learning rates, dramatically accelerating convergence. With a jagged landscape, a large learning rate step could easily "overshoot" a minimum and land in a region of high loss, causing instability. On a smoother surface, larger steps are safer.
- It makes the performance of gradient descent less dependent on the initial parameter values.
In addition to this primary effect, BN also provides a mild regularization benefit. The noise introduced by using mini-batch statistics (which are only an estimate of the true population statistics) for normalization at each step prevents the network from relying too heavily on any single training example, similar to the effect of dropout.
Batch Normalization | Internal Covariate Shift | Deep Learning Part 8
This final segment of the video concisely summarizes the shift in understanding from the original ICS hypothesis to the modern view of a smoothed loss landscape.
Please watch from this timestamp to understand the current consensus on why Batch Normalization is so effective.
This evolution in understanding is a fantastic example of the scientific process within the machine learning field. An initial hypothesis (reducing ICS) explained an observed phenomenon (faster training) and led to a powerful technique, but further investigation revealed a deeper, more fundamental reason for its effectiveness (smoothed optimization landscape).
Conclusion
In this lesson, we have dissected Batch Normalization, a technique that is indispensable for training today's deep neural networks. It not only accelerates training but also makes it more stable and less sensitive to hyperparameter choices.
Here are the key takeaways:
- Mechanism: BN normalizes the pre-activations of a layer using the mean and variance of the current mini-batch, followed by a learnable scale () and shift () to preserve the network's representational power.
- Original Hypothesis: It was proposed to solve the problem of Internal Covariate Shift, where the changing distributions of layer inputs slow down and destabilize training.
- Training vs. Inference: BN operates differently in these two modes. It uses mini-batch statistics for training and fixed, pre-computed population statistics (via moving averages) for deterministic inference.
- Modern Understanding: The primary benefit of BN is now understood to be its effect on smoothing the loss landscape, which enables the use of higher learning rates and leads to faster, more stable convergence. It also provides a secondary regularization effect.
With your understanding of advanced optimizers, dropout, and now batch normalization, you have a solid grasp of the core toolkit for training deep networks. In our next lesson, we will delve deeper into the geometry of deep learning, analyzing the structure of loss surfaces and the roles of local minima and saddle points in the optimization process.