Why can extreme class weights cause optimization instability during gradient-based training?

Last updated 15 November 2026

  • 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.

  • https://www.tensorflow.org/tutorials/structured_data/imbalanced_data
  • https://arxiv.org/html/2402.19449v1
  • https://arxiv.org/html/2310.04752v2
All Imbalanced Datasets interview questions