# W2 Assignment Exercise 8

**URL:** <https://community.deeplearning.ai/t/w2-assignment-exercise-8/3884>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [May 7, 2021, 5:33pm UTC](https://community.deeplearning.ai/t/w2-assignment-exercise-8/3884 "2021-05-07T17:33:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![srkrish2](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@srkrish2](https://community.deeplearning.ai/u/srkrish2)\
**Post date:** [May 7, 2021, 5:33pm UTC](https://community.deeplearning.ai/t/w2-assignment-exercise-8/3884/1 "2021-05-07T17:33:23Z")

</div>

I am getting the following assertion error:

`AssertionError: Wrong length for d['costs']. 20 != 1`

However, I don’t understand how the length of d[‘costs’] could actually be 1. In `optimize()`, the code automatically appends the cost ever 100 iterations, and in `model_test()` the number of iterations is 2000. Therefore it makes sense that the length of d['costs] should be 20. Why is the code expecting it to be 1?

---

<div class="post-metadata">

**Author:** ![srkrish2](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@srkrish2](https://community.deeplearning.ai/u/srkrish2)\
**Post date:** [May 7, 2021, 7:24pm UTC](https://community.deeplearning.ai/t/w2-assignment-exercise-8/3884/2 "2021-05-07T19:24:09Z")

</div>

Sorry for the post. My question was answered in a previous one.

---

<div class="post-metadata">

**Author:** ![albertovilla](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/albertovilla/32/4530_2.png) [@albertovilla](https://community.deeplearning.ai/u/albertovilla)\
**Post date:** [May 7, 2021, 7:26pm UTC](https://community.deeplearning.ai/t/w2-assignment-exercise-8/3884/3 "2021-05-07T19:26:43Z")

</div>

In `model_test` the number of iterations is set to 50, you can check it by printing the `d` dictionary. Someone else has solved this issue by removing the default values in `optimize` function.

> [@Week 2 Programming: Error in model function](https://community.deeplearning.ai/t/week-2-programming-error-in-model-function/3510/10):
>
> I had copied the parameters of model when I used arguments in optimize in it. optimize(w,b,X\_train,Y\_train,num\_iterations = 2000, learning\_rate = 0.05, print\_cost = true) I changed them to optimize(w,b,X\_train,Y\_train,num\_iterations, learning\_rate , print\_cost) and am no longer getting any error.
