
What happened
The tester ran four combinations on PyTorch 2.12.0 with a Linear layer plus Dropout(p=0.5), and rows using inference_mode() but not eval() still printed both 0.0 and 2.0.
Why it matters
A gradient-disabling setting on its own leaves training-time randomness in the output, so checking requires_grad alone can miss a misconfiguration.
Summaries like this, every morning.
The test was set up deliberately: all inputs were 1, the Linear weight was the identity matrix, and the only nonlinearity was Dropout with p=0.5. That makes the output values a direct readout of whether Dropout was active. In the training rows, outputs contained 0.0 and 2.0; in the evaluation rows, they were 1.0 throughout.
The distinction the write-up draws is between two separate switches. eval() calls train(False), which recursively sets training=False on child modules, and Dropout reads that flag. inference_mode() targets autograd bookkeeping instead, and the same PyTorch documentation carries the note that it does not automatically set the model to evaluation mode. Because the switches are independent, a test that only checks requires_grad can pass while Dropout is still running.
The suggested practice is to set evaluation mode first, disable gradient recording, and include layers whose behavior changes at evaluation time in output tests, rerunning them when the model or wrapper is updated.
Pick your industry and the AI tools you use, and get news related to your work every day.
Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →
Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.
Yoon, who runs Seoul-based CPC AI Inc., laid out a 3–5 day MVP pipeline: day 0 wireframes by hand, day 1 a wor…

The author linked a private GitHub repository to Zenn, had the agent draft the setup and a CLAUDE.md rule file…

The author reviewed PR #17 (3 lines added, 1 removed in the CI matrix) and PR #13 (Dockerfile base image swap…

Inflab backend engineer Yakpoong recounted about seven months of CodeRabbit use, citing AI reviews that flagge…

On the same Canonical Zephyr article, the four-way Haiku/Sonnet/Opus split used 198,658 tokens over about 207…

On the same gemini-3.8-flash model, the prompt-only agent hit 20/20 functional tests but broke the 65-line lim…
