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

Quick Overview

Asks why very large class weights for a rare class can make mini-batch gradient training unstable and how to fix it. Tests understanding of gradient scaling, mini-batch variance, how momentum and Adam react to sporadic spikes, overfitting to few examples, and imbalance mitigations.

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

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why can extreme class weights cause optimization instability during gradient-based training? A common fix for a rare positive class is to weight its examples by the inverse class frequency, which can mean weights in the hundreds or thousands. Explain how that can make mini-batch training unstable and what you would do about it. ```hint Look at one mini-batch Count how many rare examples land in a typical mini-batch, and work out how much of that batch's gradient a single one of them contributes when its weight is in the hundreds. ``` ```hint Check the optimizer state Think about what momentum and Adam's running averages remember after one unusually large gradient. ``` ### What a Strong Answer Covers - How a class weight scales each example's gradient and what that does to the effective step size - Why a rare class makes mini-batch gradients noisy - How momentum and adaptive optimizers such as Adam react to sporadic large gradients - The overfitting risk when a few examples, possibly mislabeled, carry huge weight - Practical mitigations and their trade-offs ### Follow-up Questions - With Adam and a weight of 1000, is the update on a spike step really 1000 times larger? What happens instead? - How do class-balanced batch sampling and class weighting differ in their effect on gradient variance? - How does logit adjustment handle imbalance without per-example weights? - After training with heavy class weights, can you trust the predicted probabilities?

Overview: Asks why very large class weights for a rare class can make mini-batch gradient training unstable and how to fix it. Tests understanding of gradient scaling, mini-batch variance, how momentum and Adam react to sporadic spikes, overfitting to few examples, and imbalance mitigations.

PracHub logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

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

A common fix for a rare positive class is to weight its examples by the inverse class frequency, which can mean weights in the hundreds or thousands. Explain how that can make mini-batch training unstable and what you would do about it.

What a Strong Answer Covers Guidance

  • How a class weight scales each example's gradient and what that does to the effective step size
  • Why a rare class makes mini-batch gradients noisy
  • How momentum and adaptive optimizers such as Adam react to sporadic large gradients
  • The overfitting risk when a few examples, possibly mislabeled, carry huge weight
  • Practical mitigations and their trade-offs

Follow-up Questions Guidance

  • With Adam and a weight of 1000, is the update on a spike step really 1000 times larger? What happens instead?
  • How do class-balanced batch sampling and class weighting differ in their effect on gradient variance?
  • How does logit adjustment handle imbalance without per-example weights?
  • After training with heavy class weights, can you trust the predicted probabilities?