LearnQuestion bank

You have just initialised a 1,000-class classifier and run one forward pass. What should the cross-entropy loss be close to, and what would you suspect if it were much higher?

ResearchTechnicalEasy

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Near-uniform 1,000-class predictions give cross-entropy ≈ ln(1000) ≈ 6.9.
  • Much higher means confidently wrong logits: large final-layer weights or bias, a poor init scale or unnormalised inputs; also check mean vs sum reduction and target alignment.
  • Softmax applied twice pins the loss near 6.9 and stops it falling; label bugs do not raise the initial loss but stop it falling later.
  • Fixes: small final-layer init and bias set to log class priors.
  • Sanity check: overfit a single small batch.

In full

If the classifier is initialised sensibly and the forward pass is correct, the 1,000-class probabilities should be close to uniform, so the cross-entropy should be close to −ln(1/1000) = ln(1000) ≈ 6.9. If it is much higher, the network is confidently wrong at initialisation: the logits have too large a spread, typically because of large final-layer weights or bias, a poor initialisation scale or unnormalised inputs. I would also check that the loss is averaged rather than summed over the batch, and that the targets line up with the outputs. Applying softmax twice (feeding probabilities to a loss that expects logits) has a different signature: the second softmax sees values between 0 and 1, so predictions are almost exactly uniform, and the loss sits at about 6.9 and then barely moves. Label bugs likewise do not raise the loss at initialisation, since near-uniform predictions cost about ln(1000) whatever the label, but they stop it falling later. The usual fixes are a small final-layer initialisation and setting the final bias to the log class priors, so the initial probabilities reflect the data distribution rather than arbitrary confidence. I would then overfit a single small batch: if the model cannot drive that batch’s loss towards zero, the bug is in the pipeline rather than the optimisation.

uniform prediction: p(correct class) = 1/1000 loss = −ln(1/1000) = ln(1000) = 3 × ln(10) = 3 × 2.3026 ≈ 6.91

Corrected by an independent AI reviewer.

What a strong answer covers

  • Near-uniform predictions give a loss of about ln(1000) ≈ 6.9.
  • Much higher suggests over-confident initialisation (large final-layer weights or bias, or unnormalised inputs inflating the logits), or a loss bug such as summing rather than averaging over the batch.
  • Fixes: small final-layer initialisation; bias set to class priors.
  • Another sanity check: overfit a single small batch.

Common mistakes

  • Answering 0 or 1.
  • Not seeing that the value is the log of the class count.