The diagonal Jacobian, and what breaks without it
gradient▲▲△The first assumption of this chapter is elementwiseness. Compute the Jacobian of sigmoid applied to , then the Jacobian of softmax on the same vector. Count the non-zero off-diagonal entries in each, and state the cost consequence.
Hint
For softmax, use from the Apparatus.
Solution
Sigmoid. , , , so the diagonal entries are :
Off-diagonal non-zeros: 0, and not approximately — exactly, because does not contain at all.
Softmax. With and (The softmax Jacobian 0.MC.06):
Off-diagonal non-zeros: 6 — every one of them.
The row sums are zero. , and likewise for the other rows. That is the shift-invariance of softmax: adding a constant to every logit changes nothing, so the derivative in that direction must vanish.
The cost consequence. For a length- vector:
| storage | backward pass | |
|---|---|---|
| elementwise | multiplies | |
| softmax | multiply–adds |
At that is against million — a factor of . This is why activations are elementwise. It is not an aesthetic preference: a non-diagonal activation at every layer would make the backward pass cost as much as the forward matrix multiplies, doubling training cost for no representational gain.
And why softmax is worth its cost where it is used. It appears once per model at the output, or once per attention head — never at every hidden layer. In attention (II.3) the Jacobian is unavoidable and is exactly the score matrix already being formed, so the cost is shared rather than added. Placement is the whole difference.
What breaks if the assumption is dropped. Everything in I.3.B03’s depth analysis assumed a scalar derivative per layer. With a dense Jacobian the product over layers is a product of matrices, whose growth is governed by singular values rather than by a single number (Rank, eigenvalues and the singular value decomposition 0.LA.04), and vanishing becomes a statement about spectral radius — precisely the analysis Chapter I.9 has to do for recurrent networks, where the Jacobian genuinely is dense.