hello i used the codes correctly it is still showing error and my assignment is not passed . please help me out .
error i am getting is :
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-14-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)
The function two_layer_model and L_layer_model returns only a single variable parameters. So you cannot unpack/assign the function to 2 variables. Try removing the costs variable while calling the function.
Hi @h_M maybe there are some lines not well indented (as python mandates) before the return statement? For example a line of the function with no indentation at all?
dear @h_M I think your problem is that you have changed the final part of the cell that contains the function two layer model. Probably you missdeleted some lines.
The original (it is not the graded part of the function) finish like this, be super careful with indentation:
# Print the cost every 100 training example
if print_cost and i % 100 == 0 or i == num_iterations - 1:
print("Cost after iteration {}: {}".format(i, np.squeeze(cost)))
if i % 100 == 0 or i == num_iterations:
costs.append(cost)
return parameters, costs
def plot_costs(costs, learning_rate=0.0075):
plt.plot(np.squeeze(costs))
plt.ylabel('cost')
plt.xlabel('iterations (per hundreds)')
plt.title("Learning rate =" + str(learning_rate))
plt.show()
NameError: name ‘train_x’ is not defined
sir when i check the next cell which is not modified it is showing this error hence the same problems next cells are not showing results
Please note this means you are on the old version of the course, even though you are on Discourse. So your results may not match what we see on the new version of the course.
That error means that the costs array returned by your two_layer_model function must be an empty list. So how could that happen? With 2 iterations, you should have returned one cost value for iteration 0, right?
Are you sure you didn’t copy over the template code from the previous version of the course? Here’s what the template code should look like for the last section of the two_layer_model function:
# Print the cost every 100 training example
if print_cost and i % 100 == 0 or i == num_iterations - 1:
print("Cost after iteration {}: {}".format(i, np.squeeze(cost)))
if i % 100 == 0 or i == num_iterations:
costs.append(cost)
return parameters, costs
In the old version of the notebook from the previous course, the costs are not added to the array if print_cost is False, as it is in the test case in question here. You can’t just copy over everything from the previous course without looking. It gets you in trouble in some ways, e.g. this example.