i have been stuck on last quiz of the course for 2 weeks, the grader grades 0 even though my code implementation is right, please help me out. Here is the code
[ValidateApp | INFO] Validating ‘/home/jovyan/work/submitted/courseraLearner/W4A2/Deep Neural Network - Application.ipynb’
[ValidateApp | INFO] Executing notebook with kernel: python3
[ValidateApp | ERROR] Timeout waiting for execute reply (30s).
[ValidateApp | ERROR] Interrupting kernel
[ValidateApp | ERROR] Timeout waiting for execute reply (30s).
[ValidateApp | ERROR] Interrupting kernel
Tests failed on 2 cell(s)! These tests could be hidden. Please check your submission.
The following cell failed:
parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y)...
print("Cost after first iteration: " + str(costs[0]))
two_layer_model_test(two_layer_model)
The error was:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-f9ec5304d38d> in <module>
----> 1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n...
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)
==========================================================================================
The following cell failed:
parameters, costs = L_layer_model(train_x, train_y, layers_dims, num_iterations = 1...
print("Cost after first iteration: " + str(costs[0]))
L_layer_model_test(L_layer_model)
The error was:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-d5e7eb27c0fc> in <module>
----> 1 parameters, costs = L_layer_model(train_x, train_y, layers_dims, num_iterat...
2
3 print("Cost after first iteration: " + str(costs[0]))
4
5 L_layer_model_test(L_layer_model)
ValueError: too many values to unpack (expected 2)
What do the return statements look like in your two_layer_model
and L_layer_model
functions? They should be returning 2 values, but apparently they don’t. That logic was given to you as part of the template code and did not need to be changed. Did you change those statements?
One other thing to note is that the grader will always grade the “official” version of the notebook: the one that is opened by the “Work in Browser” link for that assignment. If you have created a copy with a different name and click “Submit” in that other notebook, the code you are looking at is not what is being graded.
Thank you for your reply, when I run my function with two return functions parameters, costs, the block after returns this error,
IndexError Traceback (most recent call last)
in
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)
IndexError: list index out of range
Ok, the error message seems pretty clear: it looks like your costs
variable is an empty list. You can find out by adding some print statements:
print(type(costs))
print(len(costs))
What does that show? Why does costs[0]
throw an error?
Debugging is part of the job: you start from the error message. What does it mean? Then work your way backwards one step at a time to find what the mistake is.
You can’t modify the actual test cell there, but I did “Insert → Cell Below” and added this debugging code:
print(f"type(parameters['W1']) = {type(parameters['W1'])}")
print(f"type(costs) = {type(costs)}")
print(f"len(costs) = {len(costs)}")
print(f"costs[-1] = {costs[-1]}")
Here’s what I see when I run that:
type(parameters['W1']) = <class 'numpy.ndarray'>
type(costs) = <class 'list'>
len(costs) = 2
costs[-1] = 0.6926114346158595
thank you very much, is there a way
that I can start the assignment from the very beginning, I have added and deleted so much code and the lab really got messed up, I have been trying to find a way to start the quiz from the very beginning disregarding everything I have written so far
Yes, there is a topic about that on the DLS FAQ Thread (the first one on the list).
For some reason the num of iterations is set to 2 in my lab, and I am not able to change it, I think that causes the error,as the model has not had enough training to converge
I have tried to implement the same thing with 1000 iterations and it worked perfectly fine, but because the default written block with 2 iterations is unchachangable i keep being graded 0
That is the “unit test” for the two_layer_model
function. You have to pass that as well. There must be something wrong with your code. The error messages are pretty clear: the “return” values from your functions are not of the correct type. You should be returning 2 values, but apparently you are returning more than that. So how did that happen? It should not have been necessary to change that part of the template code.
Or if you are now on the second problem, it looks like what you are returning for costs is not correct.
They specifically make the test cells unchangeable so that students don’t assume that if the test fails, the solution is to change the test. The correct action is to use the test failure to debug your code.