C1W2 Assigment Ex. 8 Model

Hi everyone!

I am having issues with the ex. 8 of the Week 2 assigment.

I have done all the other ex. but in this one I got an AssertionError: Wrong lenght for d[‘costs’]. 20 !=1

I don’t get why I have that issue, the ‘costs’ is defined as a list of arrays (it is a part that was already given in the code notebook). We are supposed to use 2000 iterations and as the ‘costs’ was defined as a list of the ‘cost function’ every 100 iterations the list must have 20 values.

I hope you can help me

Where does it say we are supposed to use 2000 iterations? That is just the default value of that parameter in the definition of the model function. Check the actual test case that you are failing. I’ll bet it does not pass 2000 as that value.

Probably this means that you are hard-coding it to 2000, so that you end up ignoring the value that is passed in at the top level to the model function.

1 Like

Note that if you want to examine the test case, you can click “File → Open” from the notebook and then open the file public_tests.py and find the function model_test.

You were right!! Thank you!!!

I was so obfuscated with the AssertionError that I did not realize that I was harcoding the values.

Thank you

Great! Well, you had exactly the correct analysis of what the error message was telling you. That’s always the crucial first step in debugging. But once you understand that, then you have to ask the next question: “Ok, how did that happen?” :nerd_face:

1 Like