Week 2 assignment, excercise 6 "wrong values for costs"

I have a problem in excercise 6 of week 2. Although excercises 1-5 give the right results, excercise 6 gives:


AssertionError Traceback (most recent call last)
in
7 print("Costs = " + str(costs))
8
----> 9 optimize_test(optimize)

~/work/release/W2A2/public_tests.py in optimize_test(target)
73 assert type(costs) == list, “Wrong type for costs. It must be a list”
74 assert len(costs) == 2, f"Wrong length for costs. {len(costs)} != 2"
—> 75 assert np.allclose(costs, expected_cost), f"Wrong values for costs. {costs} != {expected_cost}"
76
77 assert type(grads[‘dw’]) == np.ndarray, f"Wrong type for grads[‘dw’]. {type(grads[‘dw’])} != np.ndarray"

AssertionError: Wrong values for costs. [array(5.80154532), array(0.58923175)] != [5.80154532, 0.31057104]

Does anyone have a hint what the problem can be?

Hey @Peeteerrr,

This learner had reported the same error message as yours, so would you check it out and see if that is your case too?

Cheers,
Raymond

Hi Raymond,
Thanks for your quick response. Indeed, I had exactly the same issue. I update b in the wrong way. As I solved that, the code ran fine.
Thanks for your help.

Peter

That’s good news, @Peeteerrr!

It’s great that you were able to find the issue based on Raymond’s link. Notice that the clue there is your first cost value at 0 iterations was correct, but it was the one at 100 iterations that is wrong. That means that the problem is not in your actual cost code but in some part of the “back prop + update parameters” logic.