Classic ML interview trap: forget model.eval() and BatchNorm makes predictions batch-dependent
cneuralnetwork · x · 2026-11-06
A genuinely tricky ML interview question: why does BatchNorm behave differently between training and inference?
During training, BatchNorm normalizes using the current mini-batch statistics; during inference, it switches to running estimates collected throughout training. That mismatch is the whole answer.
The practical gotcha: if you forget to call model.eval() in PyTorch before evaluating, BatchNorm (and Dropout) stay in training mode, so your predictions end up dependent on how the input is batched—the same data can yield different outputs with different batch compositions.
More from Research
- Hugging Face co-launches RoboColosseum: open evals on 100+ real robots — DJiafei · 2026-11-06
- Anthropic report: full AI automation could yield 15-16x research output, labs remain the bottleneck — teortaxesTex · 2026-11-06
- Elastic's VP of AI: Treat search as test-time compute, latency is a currency to spend — gaganghotra_ · 2026-11-06
- Training-Free Speculative Decoding Cuts Latency for Full-Duplex Speech LMs — CUHKSZ · 2026-11-06
- TailSteer: Drift-Resistant Multi-Turn Image Editing from CUHK MMLab — MMLab-CUHK · 2026-11-06
- EvoMemState: State-Centric Long-Term Memory for Personal Agents — Zhishang Xiang · 2026-11-06