Implement Inverted Dropout and Explain Its Inference-Time Behavior

Last updated: November 29, 2026

Quick Overview

Implement the forward and backward pass of dropout using inverted scaling, and explain why outputs must have the same expected value at training and inference time.

Meta
Machine Learning
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Machine Learning
Easy

0

0

0 solved


Implement the forward and backward pass of dropout using inverted scaling, and explain why outputs must have the same expected value at training and inference time.

A short implementation question for engineers joining ML teams at Meta, often paired with a question about a model behaving differently in production. The interviewer checks scaling, the backward pass, and the eval-mode switch.

What the Interviewer Expects
  • Generate a Bernoulli mask with drop probability p
  • Scale kept units by 1/(1-p) during training
  • Pass inputs through unchanged at inference
  • Reuse the same mask in the backward pass
  • Explain the expected value argument
Key Topics to Cover
dropout
regularization
train versus inference
backpropagation
NumPy
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • What is the alternative to inverted dropout, and why is it less convenient?
  • Why do large language models often use little or no dropout during pretraining?
  • How can Monte Carlo dropout give uncertainty estimates?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

p is the probability of dropping a unit. During training we zero units at random; at inference the layer must be deterministic. I will return the mask from the forward pass so the backward pass can ...

Approach

For each unit, keep it with probability 1−p1 - p. If kept, output x/(1−p)x / (1-p); otherwise 0. Expected output is (1−p)⋅x1−p=x(1-p) \cdot \frac{x}{1-p} = x, the same as the inference output. Gradient of output with...


Submit Your Answer
Markdown supported