16/32
Part 4 of 6 · The ReLU mask, and a worked exampleLearn and do

A unit that's off for the whole batch gets no gradient

The mask has a side effect worth naming in an interview.

Unit 1 was off for every example
dpre (3, 3)
unit 0unit 1unit 2example 00.30-0.1example 1-0.200.4example 20.500.2

Unit 1's column is all 0. So its column of W1, from x.T @ dpre, gets 0. Its entry of b1, from dpre.sum(axis=0), gets 0. Its row of W2, from h.T @ dlogits, gets 0 too, since its h is 0.

A unit that's off for every example in the batch gets an all-zero column in dpre. So its column of W1 and its entry of b1 get no gradient. Its row of W2 gets none either, because its column of h is 0.

If no input ever turns it back on, it never learns again. That's a dead ReLU.

In the editor, write hidden_backward(dh, pre, x, W1): the gate, then the linear layer below it. linear_backward from earlier is written for you.