Course 2 week 2 programming assignment error


I just finished course 2 week 2 programming assignment, and I’m running into an error for implementing Adam. I really appreciate it if someone could help.

Here I’ve attached my assignment as ipyn file. As you can see, my test for adam in exercise 5/6 passed successfully. In fact, it shows that I passed the entire assignment with 100% score. However, during 6.1 and 7.3.3 to evaluate the performance of Adam (w/ and w/o learning rate decay), I’m seeing nan for cost, accuracy of 0.5, and no decision boundary.

I’m quite confused what’s going on here. Could someone please help out?



{Moderator’s Edit: Solution Code Removed}

Hey @MrHuanwang,
Welcome to the community. Please check the code that you have written for s["dW" + str(l)] and s["db" + str(l)] in the update_parameters_with_adam function. In this, you have raised the gradients to power t, whereas as per the equations, the gradients are supposed to be squared. Let me know if this helps.

P.S. - Posting code publicly is strictly against the community guidelines, so please refrain from doing so in the future.


Thanks for helping out!

Also in the future, how do I raise questions without sharing my code?

The best thing is to show us the exception trace or error messages that you are seeing. If we can’t see how to help based on that, we can share code privately by using the DM feature of Discourse. The point of the rule is not to publicly share solutions, because then the history is out there forever for people to copy.

1 Like