C1_W_4 Programming Assignment two Exercise 1 - two_layer_model

Dear ladies and gentlemen.
Hopefully, you enjoy nice weekend.
I’m facing AssertionError from the C1_W_4 Programming Assignment two Exercise 1 of this specialization. Does this the right place we get instructed as " Confusing Output from the AutoGrader" before proceeding to the programming assignment ?

I’m really confused. Seeking your awesome help.

Thank you very much.

Hello @Gerie_knu,

The message is because one of the datatype matching test was passed.

It actually checks the datatype of the returning costs which should be a list of numpy arrays. It is a list because it was so defined in the exercise, and each listed element (a cost) should be a numpy array. However, according to the message, it became a float64 which was unexpected. I think the cost is where you can focus on for investigations.


1 Like

Thank you so much, I fixed it. Cheers!

If you get that error, usually it means you hand imported your lower level functions like compute_cost from the Step by Step exercise. If that’s what you did, that is a mistake. You’ll then fail the L_layer_model as well, because the init routine they gave you is different.

Note that they did not tell you anywhere to actually copy the functions over and they provided an import file with versions of them.

1 Like

Thank you Sir, I was mistaken coz I directly hand coded the cost value of two_layer_model. But, I import cost function for L_layer_Model. By the way, I am not sure whether this is technically right, I converted my hand coded cost value of two_layer_model to array list using np.array() method then all tests pass as shown below.

{moderator edit - solution code removed}

That looks correct, but the point is that you don’t need to hand-code that: they gave you all the functions from the Step by Step exercise as imported functions. So just call compute_cost as you did in the previous exercise. You’re working harder than you need to. :nerd_face:

1 Like

Noted. Thank you very much!