Course: Neural Network and Deep Learning - Programming Assignment Logistic_Regression_with_a_Neural_Network_mindset: Length of costs in final model

While executing the line ln[112], the model_test(model) asserts the length of costs to be 1 while received 20.

The the ‘costs’ is defined as a list and in the every 100th iteration the ‘cost’ computed will be appended to ‘costs’

the number of iteration = 2000

That probably means you are hard-coding the number of iterations when you call optimize from model. It’s important to understand how “named parameters” work in python. Defining a function is a completely different thing than calling a function. You can’t just “copy/paste” the definition of the function when you want to call it.

You can examine the actual test function by clicking File -> Open and opening the file public_tests.py. What value does that test use for the number of iterations? Note that it is not 2000. So why did you end up with 2000?

The number of iteration 2000 was already defined while the assignment was opened

Hi @aswincs ,

The named parameter with set value in a function definition refers to the default value to be used if none is given when making a call to that function.

So if you made a call to the model() function without passing num_iterations as a parameter, then the execution of the model() function would take the default value of 2000.

Thanks for the support, it is working fine now

I have edited the thread title for correctness.