23/31
Part 5 of 6 · A Linear layer, proved by gradcheckLearn and do

gradcheck builds the Jacobian two ways

gradcheck builds the Jacobian, the grid of every output's slope against every input, twice. Then it compares the two with allclose:

SideHow it builds the Jacobian
Numericalnudge one input entry by ±1e-6 and see how every output moves: one column per input entry
Analyticalrun your backward with grad_out = 1 at one output entry and 0 elsewhere: one row per output entry
Thencompare the two grids with allclose

The numerical side takes the central difference: the change in the outputs between the two nudges, divided by 2×10−62 \times 10^{-6}.

Predict

y is (2, 3, 5), a is (2, 3, 4) and b is (4, 5). How big is the Jacobian gradcheck builds?

Pick an answer above to see the rest