That error message means that the shape of the dA value that you passed down to relu_backward
does not match the shape of the Z value that was in the activation cache you passed. So how could that happen? I think you’re right that one place to look is to make sure you’re managing the l values correctly. Try putting some instrumentation in your linear_activation_backward
code or in the loop in L_model_backward
to print those shapes and see what happens.
Also the way to start debugging is to write out the “dimensional analysis” for the test case here. What are the shapes of W, A and Z for every layer in the network. Then compare that to what you are seeing. Why does it come out wrong in your code?
If your linear_activation_backward
code passes the test cases, then that means the bug is in L_model_backward
, right?