Gradient checking Ex 4> Confusing instructions

The instructions on ex 4 are a little confusing.
The suggested line count is approx 1 but then asks for 3 lines.
numerator =
denominator =
difference =
not a major issue and although you could do this in 1 line it would be clumsy and prone to obscure errors hard to debug.

You can just ignore the numbers of lines. The grader does not care. Those are just hints. I assume they mean that you could just write it as:

difference = {formula for the numerator} / {formula for the denominator}

But itâs clearer if you write it as 3 lines. But most likely they just didnât notice the mistake.

1 Like

And âŚ wait for it âŚ they made the same mistake in gradient_check_n. Is âcopy/pasteâ a great thing or what?

I just updated the bug to add these issues âŚ

I am so glad you can keep your sense of humour in face of all these tribulations.

Hi again Paul.
With respect to Exercise 4 , Gradient_check_n,
I canât get any better than 2.4577e-07 even after the deliberate bugs are rectified.
This is slightly out of the expected range.
Ian

You can see the two âexpected valuesâ in the test cell:

expected_values = [0.2850931567761623, 1.1890913024229996e-07]

The first is what you get with correct code if you have not fixed the intentional bugs in the back prop routine and the second value is what you get with correct code and fixing the intentional bugs.

There are lots of ways to get the logic wrong here. Since your value is roughly 2x the correct value, the first place to check is the âorder of operationsâ on the gradapprox calculation that involves a factor of \frac {1}{2\epsilon}. Try the following and watch what happens:

m = 5.
x = 1. / 2. * m
y = 1. / (2. * m)

Got it thanks.
I was working my numerator, denominator and difference calcs inside the 'for loop;
Ian