Equations · Srivastava et al., “Dropout: A Simple Way to Prevent Neural Networks from Overfitting” (2014)
The dropout formula, explained
During training, dropout zeroes a random subset of a layer's outputs on every step, so no unit can rely on any particular other unit being there. At test time nothing is dropped, and the outputs are rescaled so their expected size matches training.
Term by term
The outputs of layer . The is a layer index, not a power.
A random mask, drawn fresh for every example and every step: each entry is independently 1 with probability and 0 otherwise.
In the paper, is the probability of keeping a unit (0.5 for hidden layers, 0.8 for inputs). PyTorch's dropout argument p means the opposite: the probability of dropping. Check which one a paper means.
The thinned outputs: the mask times the outputs, entry by entry. The tilde marks a modified version of . This is what the next layer sees.
A small worked example
With , and a drawn mask : . The paper scales the weights by at test time, so outputs average what training saw. Most code uses "inverted dropout" instead: divide by during training, giving , and do nothing at test time.
In code
import numpy as np
def dropout(y, keep=0.8, training=True, rng=np.random.default_rng(0)):
if not training:
return y
r = rng.random(y.shape) < keep # Bernoulli(keep) mask
return y * r / keep # inverted dropout: rescale now, not at test timeEvery symbol in it
Other equations
- Scaled dot-product attention
- Softmax
- Cross-entropy loss
- Adam update
- Layer normalization
- RMSNorm
- The ELBO
- KL divergence
- Backpropagation through one layer
- LoRA
- GELU
- Batch normalization
- Rotary position embedding (RoPE)
- Multi-head attention
- PPO clipped objective
- DPO loss
- Policy gradient (REINFORCE)
- Bellman equation
- Q-learning update
- InfoNCE contrastive loss
- Diffusion forward process
- DDPM simplified loss
- VAE reparameterization trick
- GAN minimax objective
- AdamW
- Cosine learning-rate schedule
- Perplexity
- Logistic regression
- Normal equation (linear regression)
- Singular value decomposition (SVD)
- Principal component analysis (PCA)