W2_A2_Ex-8_'Costs' List length error

I’m getting the following error:

I believe the costs list is a collection of all cost values every few iterations.
‘costs – list of all the costs computed during the optimization, this will be used to plot the learning curve.’
This is the description given in the optimize(…) function for costs. So, its length should not be 1. It makes sense that for 2000 iterations, if the cost value is recorded for every 100 iterations, the length of the costs list should be 20.
I haven’t touched the code which computes the cost, returns it, and appends it to the costs list. Nor have I tweaked with any pre-given code. Why might I be getting this error? Any help would be much appreciated. Thank you!

Hello @Shashank_Srivatsav_V,

Thank you for your analysis of the problem. I checked the model_test (which is also available to you) and the problematic test uses 50 iterations, so I think we would both agree that the length of the costs list should be 1.

Now that the length is 20, so perhaps the test’s iteration setting of 50 is overrided by something else when you call optimize?


1 Like

Got it!

I was overloading the optimize function with num_iterations = 2000, so that is causing a problem.
I removed the overload and ran it, the error is resolved.

There’s another error coming up now. It’s about the ‘w’ parameter which is showing all zeros. I’ll put it up in another thread as this thread is a different topic.

Thanks for the help!