Weak 2 Exercise 6 - optimize

My code for the Exercise 5 is correct, but I cannot find why I cannot pass the Exercise 6. Thank you very much for help!!

The error code is following:

w = [[0.61865617]
[2.09693886]]
b = -0.0016486744297339539
dw = [[ 0.36559207]
[-0.09323194]]
db = -0.18318604774821712
Costs = [array(0.15900538)]

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.59716577)] != [5.80154532, 0.31057104]

Odds are good that your code for exercise 6 is wrong. The cost when i == 100 is wrong. The expected value is 0.31057104 and yours is 0.59716577.

Exactly. One key place to look would be the “update parameters” logic. If the cost is correct at 0 iterations (before any updates), but wrong at 100 iterations. Notice that your cost is actually higher after 100 iterations, so it’s going in the wrong direction. That could be a hint as to the nature of the bug. :nerd_face: