Online Hard Example Mining (OHEM): How It Works and When to Use It
A practical guide to Online Hard Example Mining (OHEM) for ML engineers: how the forward-select-backward mechanism concentrates gradient signal on informative samples, PyTorch implementation with per-sample cross-entropy and topk selection, segmentation-specific OHEM with threshold-based pixel selection, OHEM vs focal loss and when to combine them, OHEM for metric learning and embedding training, and tuning the keep_ratio hyperparameter without destabilising training.