Batch Normalization Behaving Differently Between Training and Serving
Last updated: November 29, 2026
Quick Overview
A video quality model with batch normalization scores well offline but gives erratic predictions when served one video at a time. Explain the cause and the fix.
TikTok
November 29, 20260
0
0 solved
A video quality model with batch normalization scores well offline but gives erratic predictions when served one video at a time. Explain the cause and the fix.
TikTok runs many vision and multimodal models on uploaded videos, often served with small or single-item batches. Interviewers use this bug to test understanding of batch norm internals and training versus inference modes.
What the Interviewer Expects
- Explain how batch norm computes statistics during training
- Explain running averages used at inference
- Identify the bug of serving in training mode or with stale statistics
- Mention distribution shift between training and serving inputs
- Suggest alternatives like layer norm or group norm
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- What happens to batch norm with batch size 1 in training mode?
- How would you recalibrate running statistics after fine-tuning?
- Why do transformers use layer norm?
- How would you write a test that catches this before deploy?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Ask how the model was exported (is it in eval mode?), the serving batch size, and whether serving inputs are preprocessed the same way as training (resolution, frame sampling, color normalization)....
Approach
During training, batch norm normalizes each feature with the current batch's mean and variance, then scales and shifts with learned . It also maintains running averages of mean and ...