Batch normalization shifts and rescales each activation so that its mean and variance across the batch become values that are learned during training. It is primarily useful for training stability, alleviating issues such as exploding gradients in residual networks.

  • BatchNorm was originally developed to address the problem of Covariate Shift, but has been shown to not be useful; instead, it seems to make the loss surface smoother.
BatchNorm steps (batch size with activations )
  1. Calculate mean and standard deviation statistics across batch:
  1. Standardize to zero mean and unit variance, where is a small number that prevents division by zero:
  1. Scale and shift with learned variables and :

After this operation, the activations have mean and standard deviation across all members of the batch.

Batch normalization is applied independently to each hidden unit.

  • In a standard network with layers, each containing hidden units, there would be learned offsets and learned scales .
  • In a convolutional neural network, the normalizing statistics are computed over both the batch and the spatial positions. If there were layers with channels, there would be offsets and scales.
How does BatchNorm differ at test time vs. training?

At test time, we do not have a batch from which we can gather statistics. Thus, the statistics and are calculated across the whole training dataset (rather than just a batch) and frozen in the final network.

Benefits

How does BatchNorm improve forward pass stability?

It normalizes the hidden unit activations, keeping their magnitudes stable across layers.

  • In a regular network, this ensures the variance is stable during forward propagation at initialization.
  • In a residual network, the variance must still increase as we add a new source of variation to the input at each layer. However it will increase linearly with each residual block; the -th layer adds one unit of variance to the existing variance .

Adding BatchNorm to residual networks reduces variance scaling from exponential to linear.

Why does batch normalization allow us to use higher learning rate?

It makes the loss surface gradients smoother, reducing shattered gradients.

How does batch normalization provide regularization?

Because the normalization depends on the batch statistics, we essentially applying noise during training.

Weaknesses

Why does BatchNorm sometimes degrade performance with small batch sizes?

Because the mean and variance becomes less accurate.

Why is BatchNorm problematic for tasks that require strong independence assumptions between samples?

It introduces a dependency between the examples in a mini-batch as we use batch statistics in training.

How does BatchNorm produce redundancy/inefficiency with respect to the number of weights?

BatchNorm makes the network invariant to rescaling the weights and biases that contribute to each activation. Thus, there will be a large family of weights and biases that produce the same effect. It also adds scaling and bias parameters and at every hidden unit, making the model larger. Hence, it both creates redundancy in the weights and biases and adds extra parameters to compensate for that redundancy, which is obviously inefficient.