Compare Batch Norm and Layer Norm and Why Transformers Use Layer Norm

Last updated: November 29, 2026

Quick Overview

Explain what batch normalization and layer normalization compute, how they behave differently at training and inference time, and why transformers for language use layer norm (often in a pre-norm arrangement).

Microsoft
Machine Learning
Machine Learning Engineer
Microsoft
November 29, 2026
Machine Learning Engineer
Technical Screen
Machine Learning
Medium

0

0

0 solved


Explain what batch normalization and layer normalization compute, how they behave differently at training and inference time, and why transformers for language use layer norm (often in a pre-norm arrangement).

A deep learning fundamentals question common for MLE candidates on Microsoft's AI platform and Copilot teams. The interviewer checks the normalization axes, the inference-time difference, and practical reasons tied to variable-length sequences and small per-device batches.

What the Interviewer Expects
  • State which axes each method normalizes over
  • Explain batch norm's running statistics at inference and the train/test mismatch
  • Explain why layer norm is independent of batch size and sequence padding
  • Discuss pre-norm vs post-norm stability
  • Mention RMSNorm as a cheaper variant
Key Topics to Cover
batch normalization
layer normalization
pre-norm
RMSNorm
training stability
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • What goes wrong with batch norm at batch size 1 or in distributed training?
  • Why does pre-norm make deep transformers easier to train?
  • What does RMSNorm drop and why does it still work?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

Input to a normalization layer in a transformer: a tensor of shape (batch BB, sequence TT, features dd). For a CNN: (B, C, H, W)....

Approach

Both compute x^=x−μσ2+ϵ\hat x = \frac{x - \mu}{\sqrt{\sigma^2 + \epsilon}} followed by a learned scale and shift γx^+β\gamma \hat x + \beta. They differ in which values μ\mu and σ\sigma are computed over....


Submit Your Answer
Markdown supported