Forward vs. Reverse KL Under SGD
Mean-seeking or mode-seeking? Two ways to match a distribution, the same noisy optimizer, and very different behavior.
100
classes in the teacher
80
optimization runs
20
seeds per configuration
2
batch sizes (32, 128)
KL divergence is not symmetric. Forward KL punishes a model for missing anything the target covers, so it spreads out (mean-seeking). Reverse KL punishes it for putting mass where the target has none, so it locks onto a few modes (mode-seeking). Knowledge distillation usually uses the first and variational inference the second. This study isolates how that choice interacts with the noise of mini-batch SGD.
How it works
- step 1Teacher
Teacher
A fixed multimodal categorical distribution over 100 classes with four modes, sampled 10,000 times.
- step 2Student
Student
A softmax-parameterized distribution trained with mini-batch SGD with momentum, so every gradient step sees only a noisy sample of the teacher.
- step 3Design
Design
Two objectives × two batch sizes (32 and 128) × 20 independent seeds: 80 runs, everything else held fixed.
- step 4Measures
Measures
Iterations to convergence, final loss, total-variation distance to the teacher and mode coverage, compared with two-sample t-tests.
What it found
01
The results lined up with the theory: forward KL spread its mass across the teacher's modes, while reverse KL concentrated on fewer of them.
02
Reverse KL was the more sensitive of the two to mini-batch noise.
03
Larger batches reduced run-to-run variance for both objectives.
the takeaway
“Choosing a divergence is choosing a failure mode. If missing a mode is costly, forward KL is the safer default under noisy gradients.”
/tools
- Python
- NumPy
- Matplotlib
- SGD with momentum
- t-tests
next case file