[Week 2 Exercise 6] - Wrong values for cost

My propagate function has passed but the optimize function returns wrong costs.

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

I am surprised that the type of value does not look good (array vs float) and also, the 100th value is not correct.

The first cost is good so the error might come from a bad update of w and b but since my propagate function seems good I have no clue about what to do.

I update my parameters as follow

{moderator edit - solution code removed}

Could you help me to understande what could be wrong?


1 Like

I think your intuition is good that the problem is with your “update parameters” logic in optimize, not in your propagate code. The “update” code you show is correct, so the error must be elsewhere. Are you sure you are managing the variable names correctly for the parameters dictionary and the grads dictionary? E.g. maybe you are misspelling the variable names at some point in the code and are using a global variable instead of the correct local variable.

1 Like

The other thing to check is to make sure you are not hard-coding the learning rate in your code.

1 Like

Ok I found my mistake. I was actually misspelling b.
Thanks for your help!

1 Like