AI Research Scientist · Softmax & Cross-Entropy
Softmax function and logits
Softmax function and logits
Softmax
Softmax converts logits into a distribution: . Every and they sum to 1, giving valid class probabilities.Numerically Stable Softmax
- 1Find the max logitTake from the vector — e.g. for $[2,1,0]$.
- 2Subtract before exponentiatingCompute for each entry, giving $[0,-1,-2]$ so no exponent can overflow.
- 3Exponentiate and normalizeExponentiate the shifted values and divide by their sum. The result is mathematically identical to the raw formula, just overflow-safe.
- 1Compute softmax at : probabilities .WhyThis is the baseline — already peaked toward the largest logit.
- 2Set : logits become $[8,2,0]$, softmax .WhyA small stretches the gaps between logits, pushing the distribution toward one-hot.
- 3Set : logits become $[0.8,0.2,0]$, softmax .WhyA large shrinks the gaps, flattening the distribution toward uniform.
Recall check from the same lesson
Because softmax squashes each logit into a probability, its Jacobian is a diagonal matrix where entry $i$ only depends on $p_i(1-p_i)$, just like the sigmoid derivative.
Review the explanation
Answer: False. This is false: softmax's normalization couples every output to every input, so the Jacobian is $\text{diag}(p)-pp^\top$, which has nonzero off-diagonal entries $-p_ip_j$ for $i\neq j$. Treating it as diagonal (like sigmoid, whose outputs are independent) ignores that changing one logit shifts the shared denominator and therefore every other output too.
Sources
One sitting · 20–30 minutes
A focused session on your AI Research Scientist interview
LearnBench starts from what you already know — skip what you have, master what you’re missing.
Start now