esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

What Is Batch Normalisation?

What batch normalisation does, why it speeds up training, what changes at test time and where it breaks, for your AI interview.

In short

Batch normalisation rescales each layer's inputs using the mean and spread of the current mini-batch, then lets the model learn a new scale and shift. It speeds up training, but its batch statistics get noisy with small batches.

11 min readIntermediateOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Batch normalisation is a layer that steadies the numbers flowing through a neural network. For each training step, it takes the average and spread of the batch, rescales the values to match, and then learns a small scale and shift. That lets the model train faster, with higher learning rates. At test time it uses running averages instead. Its weak spot is small batches, where the averages get noisy.

What is batch normalisation, in plain words?

A neural network is a stack of layers. Each layer's numbers come from the layer before, so when that layer learns, the numbers shift under the next one. The next layer keeps chasing a moving target.

Batch normalisation steadies those numbers. It works on a mini-batch, a small group of examples the model sees together in one training step. For each feature, it takes the group's average and spread, rescales every value to match, and then lets the model learn a new scale and shift on top.

Think of a bank's credit team scoring loan files. If one clerk writes incomes in thousands and another in full dollars, the scoring rules break. Converting each day's batch of files to one standard keeps the scorer steady. Picture a made-up card-fraud model where amounts run from $2 to $90,000. A hidden layer's numbers can differ wildly from one feature to the next during training, and batch normalisation keeps them in a range the next layer can use.

Key words

Mini-batch
A small group of examples the model processes together in one training step.
Mean and variance
The average of a set of numbers, and how far they spread from it. Variance is the spread squared.
Gamma and beta
The scale and shift the layer learns, so it can undo the rescaling if that works better.
Running average
A moving average of the batch statistics, kept during training for use at test time.

The 2015 paper called the problem internal covariate shift. Its authors wrote that "the distribution of each layer's inputs changes during training, as the parameters of the previous layers change". Covariate shift is a fancy name for a layer's inputs changing as training goes on.

How does batch normalisation work, step by step?

  1. 1

    Find the batch's mean and spread

    For each feature, add up the values in the mini-batch and divide by the count to get the average. Then measure the spread around that average.

  2. 2

    Normalise each value

    Subtract the average and divide by the spread. A tiny number, called eps, is added to the variance before the square root, so the code never divides by zero.

  3. 3

    Scale and shift

    Multiply by gamma and add beta. Both are learned during training, so the layer can keep the normalised values or undo them.

What batch normalisation does inside one layer

Batch of inputs

Many examples go through together

Normalise

Subtract the mean, divide by the spread

Scale and shift

Learned gamma and beta

Next layer

Gets steadier numbers

  1. 1The layer takes a whole mini-batch at once.
  2. 2It subtracts the batch mean and divides by the batch spread.
  3. 3It multiplies by a learned gamma, adds a learned beta, and passes the result on.
A layer takes a whole mini-batch, rescales it with that batch's own mean and spread, and passes on the result. Gamma and beta are learned, so the model can undo the rescaling if that helps.

Here is the arithmetic in plain Python. The numbers are made up: four transactions in one batch, one feature from a fraud model's hidden layer.

Python
# A fraud model's hidden layer, one feature, four made-up transactions in a batch.
batch = [12.5, 48.0, 230.0, 1900.0]   # one feature: amounts in dollars
gamma, beta, eps = 1.0, 0.0, 1e-5   # learned scale and shift; eps avoids dividing by zero
momentum = 0.1                      # how fast running averages follow each batch

mean = sum(batch) / len(batch)
var = sum((x - mean) ** 2 for x in batch) / len(batch)
out = [gamma * (x - mean) / (var + eps) ** 0.5 + beta for x in batch]

for x, y in zip(batch, out):
    print(f"{x} -> {y:.3f}")
print("batch mean:", mean, "batch variance:", var)

running_mean = (1 - momentum) * 0.0 + momentum * mean   # kept for test time
print("running mean after one batch:", running_mean)

Output

12.5 -> -0.682
48.0 -> -0.636
230.0 -> -0.405
1900.0 -> 1.722
batch mean: 547.625 batch variance: 616446.921875
running mean after one batch: 54.7625

The batch averages about 548 dollars. The 12.5 and 1900 amounts come out at about -0.682 and 1.722, and the whole batch now averages zero with a spread of about one. Gamma and beta then set the final scale. PyTorch's documentation describes the same step: the mean and standard deviation are calculated per-dimension over the mini-batches.

What changes at test time?

At test time the model may score one transaction, so there is no batch to average. PyTorch's documentation says that during training the layer keeps running estimates of the mean and variance, and uses them for normalisation during evaluation. In PyTorch you switch this with model.eval().

  • Training

    Use this batch

    Mean and spread come from the mini-batch in front of the layer, and the running averages are updated.

  • Scoring

    Use the running averages

    The layer uses the averages from training, so one transaction can be scored on its own.

Tip

Asked what changes at test time? Say the layer switches from batch statistics to running averages. Forgetting this switch is an easy bug to make.

Why does it help training, and is the reason settled?

The 2015 paper reported faster training. It said the method lets you use much higher learning rates, the step size the model takes each time it updates its weights, and that it acts as a regulariser, a trick that stops the model memorising its training data. In some cases it removes the need for Dropout, a training method that randomly switches off neurons. On a state-of-the-art image model, it reported the same accuracy in 14 times fewer training steps.

  • “Batch Normalization allows us to use much higher learning rates and be less careful about initialization.”

    Ioffe and Szegedy, 2015

  • “it makes the optimization landscape significantly smoother”

    Santurkar and colleagues, 2018

The explanation is less settled. The 2015 idea was that batch normalisation fixes shifting inputs. A 2018 study found that keeping inputs stable has little to do with its success. Its finding was that the main effect is a smoother training problem, so the gradients, the signals that tell each weight how to change, become more predictive.

Tip

Asked why it works? Give the practical effect first, then say the cause is still argued over. Calling the shifting-inputs idea settled fact is a trap.

When does batch normalisation break down?

Batch normalisation needs a batch with enough examples to estimate the average and spread. With a small batch, the estimates swing and accuracy drops. In a fully connected layer, a batch of one has no spread to measure at all. GroupNorm is a related method that works out its average and spread inside each single example, so batch size does not affect it.

  • “BN's error increases rapidly when the batch size becomes smaller”

    Wu and He, GroupNorm, 2018

When the batch is too small

Batch of 2

A small GPU fits only two examples

Noisy statistics

Mean and spread jump between steps

GroupNorm

Statistics inside each example

  1. 1Two examples give a poor estimate of the batch's average and spread.
  2. 2GroupNorm works out its statistics inside each example, so its accuracy stays steady across a wide range of batch sizes.
A small batch gives noisy averages. GroupNorm computes its statistics inside each example instead. Its computation does not depend on batch size, so its accuracy stays stable across a wide range of batch sizes.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: normalise each layer's inputs per mini-batch, then learn a scale and shift.
  • The problem it targets, and that its real cause is still debated.
  • Training uses batch statistics; test time uses running averages.
  • Why small batches hurt, and a per-example alternative such as GroupNorm.
  • The payoff: faster training and higher learning rates, with a mild regularising effect.
  • Its limits, said plainly.

Common traps

  • Trap"It removes the need to tune the learning rate."

    BetterIt lets you use much higher learning rates. You still tune them.

  • Trap"Batch norm works the same at test time."

    BetterAt test time it uses running averages from training, not the current batch.

  • Trap"Just use batch norm with a batch of one."

    BetterWith one example in a fully connected layer there is no spread to measure. Use a per-example method.

Can you spot the bug?

Spot the bug

A fraud scorer runs once per transaction in a live service. Which snippet is a real bug?

Quick check

A team trains a vision model with batches of 2 on a small GPU, and the training error jumps around. What is the most sensible first fix?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q052What is layer norm; pre-norm vs post-norm?11 min
  2. Q417What does the learning rate do?11 min
  3. Q426Vanishing and exploding gradients?12 min
  4. Q438Why does weight initialisation matter?12 min

Last updated on 27 November 2026

Training a model that learns slowly or breaks in production?

I design and build AI products and agents, including the UI and the system behind them. Book a short call and say what you need.