Why can extreme class weights cause optimization instability during gradient-based training?
Last updated
A class weight scales that example's gradient, so a weight of 1000 acts like a 1000× learning rate on rare samples, causing overshooting, loss spikes or NaNs.
Rare positives appear in only some mini-batches, making gradients very noisy. These spikes also distort Adam's moment estimates and momentum, and the model overfits a few heavily weighted points.
Mitigate by softening or capping weights, lowering the learning rate with warmup and gradient clipping, class-balanced batch sampling, or focal loss and threshold moving.