Course-1 - Week 3 Planar Assignment - 4.5 - Exercise 6 - Backward Propagation Error for dW1 values

I have been debugging the failed tests with Backward Propagation (4.5, exercise 6) implementation, where it says dW1 computed has wrong values. I suspect I am doing something wrong in dZ1 computation, which is having a cascading effect on dW1 and db1. Appreciate some pointers with this.

I have cross verified multiple times and followed exact same equations as per the lecture and the equations provided in the notebook as attached.

I understand I can’t paste the code here. Here is a quick description of what I do instead of pasting the code here. I hope it’s okay to describe this way.

  1. For dZ1, I compute in 3 steps - 1) compute dot product of W2.T, dZ2 2) compute g[1]′(Z[1]) using (1 - np.power(A1, 2)) 3) Element wise multiply 1) and 2) and then multiply with 1/m
  2. For dW1, I compute a dot product of dZ1 and X.T and then multiply with 1/m
  3. For db1, I compute np.sum of dZ1 with axis 1, keepdims True and then multiply with 1/m

Out of the expected assertions of the test, I see that dW2, db2 values and shapes are matching, where as dW1 and db1 don’t match with values, but shape is correct. All previous sections work fine with tests passed. Any clues please? The output traces of dW1, db1, dW2, db2 are attached.

Thanks,
Prakash

Hi @Prakash_Janjanam , welcome to the discourse community, I hope you are enjoying the course! You seem to strictly follow the formulas, except if you look at the screenprint of your formulas, the calculation of dZ1 is different from what you describe in the text underneath under point 1. That might explain part of the problem?

1 Like

Hi @sjfischer, Thank you very much for reverting very quickly. My bad, I can’t believe I have been ignoring that (1/m) should not be multiplied for dZ1 although I kept suspecting dZ1 as the source of my bugs. You saved me from wasting more time. Thanks a ton!!

Hi @Prakash_Janjanam , great to see you have solved the issue. Enjoy the rest of the course!