Where to apply batch normalization on standard CNNs
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Batch normalization is a technique that has become fundamental in training deep learning models, particularly convolutional neural networks (CNNs). By normalizing the inputs of each layer to have zero mean and unit variance, it stabilizes the learning process and reduces the number of training epochs required to train deep networks. But regardless of its benefits, there's often ambiguity about where to correctly apply batch normalization in a standard CNN architecture. This article will discuss the technical considerations, examples, and common practices for applying batch normalization in CNNs.
Overview of Batch Normalization
Batch normalization works by addressing the internal covariate shift problem, which refers to the changes in the distribution of network activations due to updating weights. By normalizing inputs before they pass through the next layer, it ensures that inputs to activations are consistent across mini-batches.
Mathematical Formulation
For a given mini-batch, the batch normalization is calculated as follows:
- Mini-batch mean:\
- Mini-batch variance:\
- Normalize:\
- Scale and shift:\
Where is the input, and are learnable parameters, and is a small constant to prevent division by zero.
Where to Apply Batch Normalization
Common Practice
- After Convolution and Before Activation: • A typical application is to place batch normalization after a convolutional (Conv) layer and before a nonlinear activation function like ReLU. This order stabilizes the inputs to activation functions, making the network less sensitive to weight initialization and learning rates.• Similar to convolutional layers, batch normalization can also be applied after fully connected (Dense) layers, generally before applying activations. • Output Layers: Typically, batch normalization is not applied after the final output layer, especially when the network is performing regression. For classification tasks, it may inadvertently affect softmax outputs. • Small Mini-batches: If the mini-batch size is very small, the mean and variance estimates may be unreliable, in which case other normalization techniques like Layer Normalization might be more appropriate.
Related reading
- Where to apply batch normalization on standard CNNs
- Where to find a documentation about default weight initializer in Keras?
- Which algorithms have been proposed to learn the architecture of a deep neural network?
- Which layers in a neural network use activation functions?
- Whether Data augmentation really needed in Machine Learning
- Which classification algorithm can be used for document categorization?
- Which algorithm can I use to find the next to shortest path in a graph?
- Which algorithm for assigning shifts discrete optimization problem

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.