Week 1 - Assignment "Gradient Checking"

Hey guys,

just a suggestion:
In the Gradient Checking Assignment “Exercise 3 - gradient_check”, at the end of the “gradient_check” function, I would alter the checked condition to “if abs(difference) > 2e-7” from “if difference > 2e-7”.
I had a bug in the code that resulted in difference being negative 1, which never triggered the second (error-)message and instead incorrectly told me “everything works perfectly fine” so that I never reviewed my code as I got no error message. However, I only received a grade of 80%. Ultimately, I wouldn’t find the reason for the missing points before thorough investigation of all of the seemingly correct code…

Narrowing down the checked condition for correctness is super easy and might prevent people from falling into the same trap in future.

Cheers, apart from that really enjoying the course!
David

Hi, David.

Thanks for pointing that out. Exactly as you say, it would be nice if the test cases gave a bit more assistance in catching that type of mistake. I will file a bug and hope that the course staff will take your suggestion. As you also point out, it wouldn’t be hard to implement such a test in this case.

Regards,
Paul

Well, to be fair, it should be clear from the formula for the difference that it can’t be negative if correctly implemented, so that should have been a clue.

But still, your point is well taken: writing a test case that would have “thrown” in that case would be easy to do and reasonably expected based on how things have worked everywhere else in these courses.