Four Places to Run the Check

BackpropagationHard+30 XP+30

Four Places to Run the Check

A tiny network reads one number xxx and predicts one number. It has two hidden ReLU neurons and an output neuron with no activation:

z1=w1x+b1,z2=w2x+b2z_1 = w_1 x + b_1, \qquad z_2 = w_2 x + b_2z1​=w1​x+b1​,z2​=w2​x+b2​

prediction=v1 ReLU(z1)+v2 ReLU(z2)+c,L=(prediction−target)2\text{prediction} = v_1\,\text{ReLU}(z_1) + v_2\,\text{ReLU}(z_2) + c, \qquad L = (\text{prediction} - \text{target})^2prediction=v1​ReLU(z1​)+v2​ReLU(z2​)+c,L=(prediction−target)2

Its parameters are

w1w_1w1​b1b_1b1​w2w_2w2​b2b_2b2​v1v_1v1​v2v_2v2​ccc
1110.50.50.5222−1-1−1222−0.5-0.5−0.50.50.50.5

A teammate has hand-written the backward pass, which returns a gradient for all seven parameters. It has exactly one bug. For each hidden neuron's bias, the code reuses the line it has for that neuron's weight: it multiplies the neuron's error signal ∂L∂z\dfrac{\partial L}{\partial z}∂z∂L​ by the input xxx. Everything else in the code is correct.

The teammate doesn't know about the bug yet. They plan to test the code with a gradient check on one example. For each of the seven parameters in turn, they nudge it up by 0.010.010.01 and down by 0.010.010.01, run the forward pass both times, and compare

L(p+0.01)−L(p−0.01)0.02\frac{L(p + 0.01) - L(p - 0.01)}{0.02}0.02L(p+0.01)−L(p−0.01)​

with the code's gradient for that parameter. On these examples no weighted sum gets anywhere near zero during the nudges, so the check measures every true slope exactly. It disagrees with the code precisely where the code's number is wrong.

They have four candidate examples:

examplexxxtarget
1222444
2333333
3−1-1−11.51.51.5
4111444

On which of these examples would the check show at least one disagreement?

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.

Select all that apply.