How does combining softmax with cross-entropy avoid vanishing gradients for confidently wrong predictions?

Quick Overview

Asks why pairing softmax with cross-entropy keeps gradients large when a classifier is confidently wrong. Tests whether you can derive the gradient with respect to the logits, contrast it with squared error on saturated outputs, and explain the limits of the fix.

How does combining softmax with cross-entropy avoid vanishing gradients for confidently wrong predictions?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How does combining softmax with cross-entropy avoid vanishing gradients for confidently wrong predictions? ```hint Simplify before differentiating Write the loss as a function of the logits and expand the log of the softmax. What happens to the exponential? ``` ```hint Compare with squared error Write the gradient of squared error on a sigmoid output with respect to its logit, and look for a factor that goes to zero when the output saturates. ``` ### What a Strong Answer Covers - The gradient of softmax cross-entropy with respect to the logits, and how the log cancels the exponential to give it. - Why that gradient is close to its largest possible size when the true class has probability near zero. - The contrast with squared error on sigmoid or softmax outputs, where the activation's derivative multiplies the error and vanishes under saturation. - The limits of the fix: it covers the output layer only, and the same large gradients make training sensitive to mislabeled examples. ### Follow-up Questions - Why should a framework's cross-entropy function receive raw logits instead of probabilities? - What happens during training when some labels are wrong, given that confidently wrong examples get the largest gradients? - How does label smoothing change the gradient, and what does it do to calibration?

Overview: Asks why pairing softmax with cross-entropy keeps gradients large when a classifier is confidently wrong. Tests whether you can derive the gradient with respect to the logits, contrast it with squared error on saturated outputs, and explain the limits of the fix.

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

How does combining softmax with cross-entropy avoid vanishing gradients for confidently wrong predictions?

What a Strong Answer Covers Guidance

  • The gradient of softmax cross-entropy with respect to the logits, and how the log cancels the exponential to give it.
  • Why that gradient is close to its largest possible size when the true class has probability near zero.
  • The contrast with squared error on sigmoid or softmax outputs, where the activation's derivative multiplies the error and vanishes under saturation.
  • The limits of the fix: it covers the output layer only, and the same large gradients make training sensitive to mislabeled examples.

Follow-up Questions Guidance

  • Why should a framework's cross-entropy function receive raw logits instead of probabilities?
  • What happens during training when some labels are wrong, given that confidently wrong examples get the largest gradients?
  • How does label smoothing change the gradient, and what does it do to calibration?