5/31
Part 1 of 6 · Derive the two gradientsLearn and do

One entry of B reaches one column of Y

BpjB_{pj} feeds column jj of YY, and in each YijY_{ij} it's multiplied by AipA_{ip}:

An entry of B reaches one column of YInteractive
A (2, 3)
120013
B (3, 2)
Y = A @ B
5-123
dY
10-12
Tap an entry of B to nudge it.
B[0, 1] feeds column 1 of Y and nothing else, each entry times column 0 of A, [1, 0]. So dB[0, 1] = column 0 of A · column 1 of dY = (1)(0) + (0)(2) = 0.

Add up its effect down the column:

∂L∂Bpj=∑i=1nAip dYij\frac{\partial L}{\partial B_{pj}} = \sum_{i=1}^{n} A_{ip}\, dY_{ij}

That's column pp of AA times column jj of dYdY. Column pp of AA is row pp of A⊤A^\top, so it's entry (p,j)(p, j) of A⊤dYA^\top dY.

In the editor, write dB_entry(A, dY, p, j): that sum down column j, as a loop.