NLP course 2 week 4 assignment question 4

Could anyone please tell me what is the issue with question 4 (backpropagation)?

14 test case passed and 2 test case failed. It gives the following error.

Hi @Nesar_Ahmed_Titu!

it seems like you maybe redundantly applying the step function one extra time
(that would be the reason the values that are negative in the expected b1 vector, are equal to 0 in the b1 vector you get).

If this is case, it is redundant because the step funtion has already been applied in the provided code:

l1[z1 < 0] = 0 # use "l1" to compute gradients below

Thank you! It worked.

1 Like


Well first of all, you seem to have changed the given code quite a bit. This is generally not best the way to go, so I would suggest in the future changing & completing only the parts that are indicated in the assignment and keeping those that are meant to be kept, as in the case of this exercise:

l1[z1 < 0] = 0 # use "l1" to compute gradients below

normally you shouldn’t have changed that, but rather find a way to use it. You could reset the notebook if you lost the original code.

In terms of the logic you implemented,

result[result < 0] = 0

is not equivalent to

l1[z1 < 0] = 0

More specifically, in your implementation you are not using the argument W1 anywhere. Apart from that, the logic of your implementation is fine.

Please hide your solution code above, posting solution codes does not comply with the code of conduct.