Week 2, Logistic Regression assignment, Exercise 8

Hi,
Although passing all tests before part 8, when calling optimize function with given arguments(even using all of those needed like iteration number and learning rate and print_cost base on the model function) I cannot pass the test after that and encounter this error:


I know that in propagation function it basically tries to print cost every 100 iteration so that in the number of iterations given in model function, we would have 20 costs saved in an array.
What I cannot understand is how to fix the problem because I tried some ways like using [costs[0]] to let the model use the first element as the final cost which did not work. Even using np.sum(costs) did not work as well and resulted in an error related to wrong values in dw!( I tried to use all of the needed optimization function arguments and cannot figure out why this happens!)
So any help would be appreciated.
The best

You may be passing all the parameters on the call to optimize, but my guess is that you are not passing them correctly. Are you perhaps hard-coding the number of iterations to 2000, rather than passing through the value that was passed to model for that test case.

Thanks. It worked. This is the case " Are you perhaps hard-coding the number of iterations to 2000, rather than passing through the value that was passed to model for that test case".
Regards

1 Like

Glad to hear you found the solution! Thanks for confirming.