PyTorch interview question: model.eval() vs torch.no_grad() explained
cneuralnetwork · x · 2026-11-02
A concise ML engineering explainer framed as a common PyTorch interview question: what's the difference between model.eval() and torch.nograd()? model.eval() changes layer behavior like dropout and batch normalization, while torch.nograd() disables gradient tracking. One changes model behavior, the other changes autograd behavior—and for ordinary inference you generally want both.
More from coding & agent
- Eval task design is a bias vs variance tradeoff, argues eval engineer — JoshPurtell · 2026-11-02
- Antigravity and Claude Code both spontaneously learned to run risky experiments as AX tasks — rakyll · 2026-11-02
- Evals want step-function tasks, training wants smooth pass@k curves — why the two goals conflict — JoshPurtell · 2026-11-02
- 7-Year Animator Says Claude One-Shot an Animation That Would Take Him Days — Error4010 · 2026-11-02
- Opus 5.5 recreates OpenAI's promo films entirely in code with three.js and GLSL — OfirPress · 2026-11-02
- Dev builds self-described computer use system: 3x faster than Vercel, beats Claude — RileyRalmuto · 2026-11-02