[Week 2 Exercise 6] - Wrong values for costs

Hi,

I’m getting a “wrong values for costs” assertion error in Exercise 6 Optimization. The tests for propogate() function above passed.

Here’s my cost function from the propogate() function:

{moderator edit - solution code removed}

In my optimize() function I call propogate() like this:

grads, cost = propagate(w, b, X, Y)

I’ve insured I have the latest version of the exercise file and public_tests.py. Below is the full assertion error from the Exercise 6 test. What am I missing?

@paulinpaloalto, is this related to this thread? I’ve updated my public_tests.py to the latest version and I only see one test in there where m=3, no m=4 test.

Thanks in advance for any help.

Hi, Matthew.

I think your cost code should work. You don’t need the np.sum call there, but I think it will give the correct answer. If I’m interpreting what you are saying correctly, I think you pass the test case for propagate, but fail the test for optimize. In the test case output that you show, notice that the first cost value agrees, but it is the second one that does not. That indicates that your cost code is correct, but that the problem is with some other aspect of the optimize logic. E.g. the “update parameters” portion may be wrong.

Doh! My w and b updates were incorrect. (I spent so much time validating my cost function.) I was multiplying the learning rate by w and b when I should have been multiplying them by the derivatives. Thanks for pointing me in the right direction.