KatInterview

Normalization Strategies: Batch vs Layer Normalization

Machine LearningModel answer
HardModel answerMachine Learningnormalizationdeep-learningtraining

Last updated

Explain how batch and layer normalization differ in computation, statistics, parameters, and inference behavior, plus debugging approaches.

You're implementing normalization layers for a neural network. Explain the differences between batch normalization and layer normalization.

Your explanation should cover:

  1. Computation: Which dimensions each method normalizes over, with concrete examples for different input shapes
  2. Statistics: How mean and variance are computed and used during training versus inference
  3. Learned parameters: What trainable weights each method maintains
  4. Batch size sensitivity: How each method behaves with different batch sizes
  5. Debugging: How you would diagnose and fix issues when a model's accuracy drops between training and production

Start with feature vectors (shape [batch, features]), then extend to convolutional activations and sequences. Be specific about axis indexing and the role of running statistics.

Hints

Hint 1

Each normalization method computes statistics over different dimensions—identify which axes are reduced for mean and variance

Hint 2

Batch normalization maintains exponential moving averages during training that become crucial at inference time

Hint 3

Consider what happens when your training batch size is 64 but inference processes one example at a time