I think I have a problem with dZ1 since it leads to both miscalculations on both db1 and dW1, but as I checked thoroughly and read the tips given I don’t see anything wrong with the code on dZ1. I used (1 - np.power(A1, 2)) to replace 𝑔[1]′(𝑧) as described in the tasks. Could you please give me a hint on what could go wrong?
Please be aware that would be a violation of the Course Honor Code. We are not supposed to share code publicly. Sorry, I realize that makes debugging more difficult.
In terms of how to approach this, how about adding some print statements to your code to show the intermediate values. Here’s what I get when I do that with the standard test case in the notebook:
@paulinpaloalto I have seen other people posting snippets of their code that is why I asked. I’m sorry for asking code screenshot. I was just trying to help
Hi, @Nero. Sorry, you’re right that a lot of people are doing it. I was just taking the opportunity to point out the rules. Of course you’re 100% right that it’s way easier to debug when you can see the code. If everyone would just go back and delete the code segments once the problems are solved, posting the code would probably a good way to go. The point is that the rules are set up try to avoid the scenario that all the code is just out there on the forums. In the old Coursera Forums, the mentors actually had the tools to remove the code, but apparently here we don’t. All we can do is ask nicely …
Actually I can produce the exact incorrect results that you show @wipadaw by making what I think is the most common mistake in the formula for dZ1. Take another look at your code and compare to the math formula. Note that the formula makes no reference to dW2.
Compare your dW2 values to the “expected” ones and you’ll see that they are wrong. All the other values appear correct, so that should be a clue. The mistake only affects dW2. It can’t be that your dZ2 calculation is wrong, because that is input to the db2 formula also and that answer came out correctly. The formula for dW2 is pretty simple:
dW2 = \displaystyle \frac {1}{m} dZ2 \cdot A1^T
So you know where to look for the mistake. There must be something just in that one line of code that you got wrong.