WK_2_EX_8: Wrong type for d['costs']?

Hello,

I am getting a wierd error for the type of d[costs]. I am not sure what to do.
my w.shape, X.shape, Y.shape is (4, 1) (2, 3) (1, 3).

Just to be clear, this is for the model function, All previous code blocks passed all tests. No values are hard coded.

For the Y_prediction_test var, I am using X_test in the predict call,This is the one thing I am not sure about. If I use Y_test, then I get a tuple index out of range error.

Any idea what is going on?

Hello @Thomas_Mc_Nulty,

Let’s discuss based on the error traceback.

It said your d['cost'] was a numpy array but it was looking for a list object. Since

 d = {"costs": costs,
      ...
     }

The next thing to look into would be the variable costs. How did you compute it? Were you using the correct function from earlier exercises? If so, and if that function returns a couple of variables including the costs, did your code receive them by the right variable names accordingly? Would you add some print lines to check the types of those returning variables and verify that the costs should be a list?

Cheers,
Raymond

Good catch! Yes, I had the optimize function returning params, grads, cost not costs, so once that was fixed it passed.

Thank you!!

You are welcome @Thomas_Mc_Nulty!

Cheers,
Raymond