TorchedUp
ProblemsPremium
TorchedUp
Dropout ForwardMedium
ProblemsPremium

Dropout Forward (Training)

Implement the dropout forward pass in training mode.

Signature: def dropout_forward(x: np.ndarray, p: float, seed: int = 0) -> np.ndarray

  • Each element is zeroed independently with probability p
  • Surviving elements are scaled by 1/(1-p) (inverted dropout)
  • Use np.random.default_rng(seed) for reproducibility

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○p=0 no dropout
○p=0.5 with seed 42
○p=0.5 with seed 0🔒 Premium
○p=0 → output equals input (negative values too)
○idempotent when p=0
Advertisement