Course 1 Week3 Assignment problems with back-propagation

Hi,

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:

dZ1 = [[ 0.00528712 -0.00528824  0.00528716]
 [ 0.00453054 -0.00454038  0.00453968]
 [-0.00275488  0.00275645 -0.00275366]
 [-0.01145044  0.01145559 -0.0114478 ]]
dW1 = [[ 0.00301023 -0.00747267]
 [ 0.00257968 -0.00641288]
 [-0.00156892  0.003893  ]
 [-0.00652037  0.01618243]]
db1 = [[ 0.00176201]
 [ 0.00150995]
 [-0.00091736]
 [-0.00381422]]
dW2 = [[ 0.00078841  0.01765429 -0.00084166 -0.01022527]]
db2 = [[-0.16655712]]

@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 :slight_smile:

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 :nerd_face:

1 Like

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.

2 Likes

I’m sorry, I already deleted the part of the code and left with the result only.

1 Like

I think I got it! Thank you so much. You got me I missed that part actually :frowning:

1 Like

Hi,
i have a similar problem, but in my case the program doesn’t show the output with variable wrong .

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.

Thanks, @paulinpaloalto