How does a dropout layer behave differently in training mode versus evaluation mode?

Last updated 3 November 2026

In training mode, dropout randomly zeroes each activation with probability p and scales the survivors by 1/(1−p). In evaluation mode, it is the identity: nothing is dropped and nothing is scaled, so outputs are deterministic.

  • Training mode:

    • A fresh Bernoulli mask is sampled every forward pass, so each minibatch sees a different thinned network.

    • With inverted dropout, survivors are multiplied by 1/(1−p) so the expected activation is unchanged.

    • Gradients flow only through the kept units.

  • Evaluation mode: The full network is used. Because scaling was already done in training, no correction is needed at inference.

  • How you switch modes:

    • PyTorch: model.train() / model.eval(). These set the training flag on every nn.Dropout (and on BatchNorm).

    • Keras: the training argument. fit() sets it to True, while predict() and evaluate() set it to False.

  • Common pitfalls:

    • Forgetting model.eval() gives noisy, non-reproducible predictions and underestimated validation accuracy.

    • model.eval() does not disable autograd. Wrap inference in torch.no_grad() for that.

    • Intentional exception: Monte Carlo dropout keeps dropout active at inference and averages several passes to estimate uncertainty.

[lang:python] drop = nn.Dropout(p=0.5) x = torch.ones(6) drop.train(); drop(x) # e.g. tensor([2., 0., 2., 2., 0., 0.]) drop.eval(); drop(x) # tensor([1., 1., 1., 1., 1., 1.])

  • https://medium.com/@praggrt/dropout-data-science-interview-questions-18f29037bf5a
  • https://www.youtube.com/watch?v=fu-DGOCL2yY
  • https://www.geeksforgeeks.org/machine-learning/dropout-in-neural-networks/
All Regularization interview questions