Exercise 5 passed, getting error for cost in Exercises 6, although cost drops

I already found the discussion here:

However I seem to have a different problem.

My exercise 5 passes, but in exercise 6 I get: AssertionError: Wrong values for costs. [array(5.80154737), array(0.71089735)] != [5.80154532, 0.31057104]

I do:

The cost also decreases, when I print the result in each itteration:

But it seem the learning rate is to low or there are more iterations needed?
I can’t figure the problem. Please help.

You can see from the values shown in the assertion failure that even your value of the cost at iteration 0 is wrong: an error in the 6th decimal place is not a rounding error. Your implementation of the first term (the Y = 1 term) is not correct. And at iteration 0, the gradients don’t yet have any effect, which is the clue that the bug must be in either the computation of A or the cost.

Then there must also be a problem that either you’re hard-coding the learning rate to the wrong value or perhaps your gradient computations are incorrect. Please compare your code to the formulas with the same level of attention to detail that was necessary to spot the error in your cost formula and see if you notice anything further.

Thank you so much for lending an experienced eye. :slight_smile:
Looked at it so many times, but did not see the error in the cost.
That was the solution.

(However one does not expect a capital error like this after getting an OK from the grader at ex.5)

1 Like

Indeed! It is a good point that both the test cases in the notebook and the grader report that bug as a problem in optimize, not in propagate. Heavy sigh. Thanks for pointing that out! I will file a bug about that right away …