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
Machine Learning
Machine Learning Engineer
TikTok
November 29, 2026
Machine Learning Engineer
Technical Screen
Machine Learning
Medium

0

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
batch normalization
deep learning fundamentals
training-serving skew
layer normalization
debugging
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 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 Prep
Sample 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 γ,β\gamma, \beta. It also maintains running averages of mean and ...


Submit Your Answer
Markdown supported