Week 3, exercise 8: troubles with backward propagation

I’m trying to implement the nn_model() function in exercise 8, but I have a strange error with the backward propagation function:

I wrote backward_propagation() in exercise 6 and all tests passed.
I can’t understand what is the problem, can someone help me?

Thank you.

Note that passing a test in the notebook does not prove your code is perfect.
In backward_propagation(), there is a problem with the shape of either A2 or Y.
Could be the problem is in nn_model() where you compute A2.

After one day of debug, I’ve found that I wrote A2, “chache = forward_propagation” instead of “A2, cache = forward_propagation”… in function “nn_model”
So, in the next line my code used the value of the global variable cache defined in a previous exercise.
Now exercise 8 works properly.

Thank you.

1 Like

That’s difficult to catch. Nice work!

Re-using function parameter names as global variables (i.e. using “cache” in more than one execution scope within the notebook) is not a great design for the assignment.