ML & Deep Learning Foundations·Question 4 of 55Basic

How does dropout work - and what changes between training and inference?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

During training, dropout independently zeroes each activation with probability p (commonly 0.1-0.5), forcing the network not to rely on any single unit and breaking co-adaptation. It's often described as training an implicit ensemble of exponentially many thinned subnetworks that share weights.

Full worked answer

During training, dropout independently zeroes each activation with probability p (commonly 0.1-0.5), forcing the network not to rely on any single unit and breaking co-adaptation. It's often described as training an implicit ensemble of exponentially many thinned subnetworks that share weights.

The train/inference asymmetry is the part interviewers actually probe. With inverted dropout (what every modern framework implements), surviving activations are scaled by 1/(1−p) at training time, so the expected activation magnitude matches between train and inference - at inference, dropout is simply disabled and no rescaling is needed. The classic bug: forgetting model.eval() in PyTorch, so dropout stays active in production and predictions are noisy and degraded. (The same call also switches BatchNorm to running statistics - two bugs for the price of one.)

mask = (torch.rand_like(x) > p).float()
x = x * mask / (1 - p)   # inverted dropout: rescale at train time

Where it's used today: the original Transformer applied dropout to each sub-layer's output before the residual add and to the embedding sums (p=0.1); standard implementations also drop attention weights. But large-scale LLM pretraining typically uses dropout of 0 - with a massive, single-epoch data stream there's little memorization pressure, and dropout just wastes capacity. It reappears in fine-tuning, where datasets are small: LoRA setups commonly apply dropout ~0.05-0.1 to the adapter inputs.

Variants worth naming if asked: DropPath/stochastic depth (drop whole residual branches, common in vision transformers) and Monte Carlo dropout (keep dropout on at inference and sample repeatedly for a crude uncertainty estimate).

What a good answer covers

  • During training, dropout independently zeroes each activation with probability p (commonly 0.1-0.5),…
  • It's often described as training an implicit ensemble of exponentially many thinned subnetworks that…
  • With inverted dropout (what every modern framework implements), surviving activations are scaled by…
  • The classic bug: forgetting model.eval() in PyTorch, so dropout stays active in production and…
  • (The same call also switches BatchNorm to running statistics - two bugs for the price of one.)

Key terms: inverted dropout

Interviewer follow-ups to expect

  1. Why do large pretraining runs set dropout to 0?

  2. What does model.eval() change besides dropout?

  3. How would you use MC dropout to get uncertainty estimates?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep