For , how do you derive the full Jacobian matrix for both diagonal () and off-diagonal () entries, and why does shifting every logit by a constant leave unchanged?
Deep learning, Neurons and activations
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can compute the full vector-valued derivative of softmax cleanly and express it in matrix form.
Key idea
Writing and , the quotient rule gives , or in matrix form. Adding to all multiplies numerator and denominator by , which cancels.
Steps
- Write with , noting .
- Diagonal case (): .
- Off-diagonal case (): does not depend on , so .
- Combine with the Kronecker delta ( if , otherwise): , so . In backprop, multiplying by upstream gradient costs via without forming the matrix.
- Shift invariance: . Choosing keeps all exponents and prevents overflow.
Common mistakes
- Treating softmax as an element-wise activation like sigmoid and ignoring the off-diagonal terms.
- Materialising the Jacobian in code instead of computing in time.
How long your answer should be
Half a page; 4–5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Deep learning: How do you express the derivatives of and purely in terms of and , what are their maximum values, and why is generally preferred over in hidden layers?
Next in Deep learning: What are the GELU and SiLU (Swish) activation functions, what is the exact derivative of , and why do modern deep architectures often prefer them over ReLU?