Hello! Im having an issue when running the two_layer_model function that I’m not able to understand. I attach my code and also the error.
(Solution code removed, as posting it publicly is against the honour code of this community, regardless if it is correct or not)
error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-45-f9ec5304d38d> in <module>
----> 1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)
2
3 print("Cost after first iteration: " + str(costs[0]))
4
5 two_layer_model_test(two_layer_model)
ValueError: too many values to unpack (expected 2)
Nydia
September 20, 2023, 1:28am
2
How does your compute_cost(A2, Y) look like?
Nydia:
compute_cost(A2, Y)
Hi! In which part it should be?
Nydia
September 20, 2023, 1:35am
4
It should be up in your code cells, you can search it by pressing: control + F, then write: compute_cost(A2, Y)
Nydia:
compute_cost(A2, Y)
Do you mean this? Is the only place I see it, but its also in the code I had attached before
(Solution code removed, as posting it publicly is against the honour code of this community, regardless if it is correct or not)
Nydia
September 20, 2023, 2:59am
6
My best guess is that the problem comes from there, you can very this by obtaining the shape of “cost”, which should not be different than 2. You can do this by writing:
print(np.shape(cost))
TMosh
September 20, 2023, 3:04am
7
The compute_cost() function in this assignment is provided code, the student does not need to create or modify it.
It’s provided in the dnn_app_utils_v3.py file.
TMosh
September 20, 2023, 3:13am
8
Have you tried running all of the cells again in sequence, starting from the first cell at the top of the notebook?
TMosh
September 20, 2023, 3:14am
9
Also, just a reminder: Please do not post your code on the forum. That’s not allowed by the Code of Conduct.
If a mentor needs to see your code, we’ll contact you with instructions.