Week 4 two_layer_model

Hi im getting this error :

ValueError Traceback (most recent call last)
----> 1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)
3 print("Cost after first iteration: " + str(costs[0]))
5 two_layer_model_test(two_layer_model)

ValueError: too many values to unpack (expected 2)

The first step in debugging is always to understand what the error message is telling you. In this case, you are invoking the function two_layer_model in a way that requires that it return exactly two distinct return values. But the error message says that it returned more than 2 values.

Ok, so how did that happen? Look at the return statement in that function. That was given to you in the template code and there should have been no reason to change it. Here’s what it looks like in a clean copy of that notebook:

return parameters, costs

What does it look like in your version of the notebook? Did you change it?

The version of the notebook is old i guess. I had no cost in the parameters. How can obtain a new copy please?

There is a topic about that on the DLS FAQ Thread.

Not sure this is applicable in your case, but please note as a general matter that copying solutions off the Internet is a) against the rules and b) may very well be a waste of time because the courses were heavily updated in April 2021. Any solution you find out there may pre-date that upgrade. You can’t just copy things and expect them to work.