HaiAI123

Curated Global AI Tools Directory

Industry update
Flat

Post-mortem: missing model.eval() skewed inference scores

11/26/2026 — 11/26, 15:20·1 sources (all)·1 reports (all)

Key takeaways

  • An engineering post-mortem explains that a PyTorch model stays in training mode after loading weights, so torch.no_grad() alone leaves Dropo…
  • calling model.eval() before inference fixes it.

Background & analysis

On November 26, 2026, a postmortem published on DEV Community described a PyTorch inference bug that caused unstable scores in production. The author used a damage classifier called DamageNet as the example. In the notebook, the model scored 94 percent. The serving script then loaded the weights with model.load_state_dict(torch.load("best.pt")) and wrapped the scoring function in @torch.no_grad(), but it never called model.eval() before inference. A returns clerk uploaded the same photo twice and received 0.81 the first time and 0.62 the second, despite identical pixels. Over the following week, every score drifted slightly lower. The postmortem explains the mechanism: a PyTorch model has two modes, training and evaluation, and a newly created model starts in training mode. torch.no_grad() does not change that. As a result, Dropout kept randomly dropping parts of the network during inference, and BatchNorm kept using per-image statistics while updating its running mean. The fix the author gives is to call model.eval() before inference. The report does not say when the issue was found or fixed, or whether the service has been redeployed.

AI-generated from 1 reports · updated 3 days ago

updream
24-hour heatHeat index 25 · peak 26 · 23h ago
24 hours agonow

Reports on this story headlines open the original

Nov 26
  1. A postmortem explains why a served PyTorch classifier scored the same photo 0.81 and then 0.62: loading weights leaves a model in training mode, and torch.no_grad() does not change that. Dropout kept dropping parts of the network per request and BatchNorm normalized each image by its own statistics, so scores also drifted downward over the week. Calling model.eval() before inference fixes it.

    DEV Community · AIAI score 53

Other stories people are talking about

How is heat calculated?About the method

Heat counts how many independent sources covered a story in the last 48 hours: one source counts once no matter how many posts it published, decaying with a 24-hour half-life. What ranks first is what many people are talking about.

This page aggregates public feeds. Headlines and summaries are machine-organized and remain the property of the original authors; verify important facts at the source. If you believe a headline or summary infringes your rights, email the contact address in the footer with the page URL and basis of your claim, and we will remove or replace it after review.

Surge
Discussion rising fast
New
First report within 6 hours
Rising
Still gathering discussion

Back to AI industry updates →