C1_W3_Assignment Question 5

1 Like

Please post a screen capture image that shows the first dozen lines of the cell that has the forward_propagation() function.

1 Like

Also, when you opened the notebook today, did you get a pop-up message that the lab had recently been updated?

2 Likes

no

1 Like

Thanks. I need to see the first 12 lines of your forward_propagation() function definition.

1 Like

1 Like

1 Like

I can’t seee the problem

1 Like

The assignment notebook file has been updated, and you still have the old version.

It takes 3 parameters now:

Check your Files menu, do you have a version of the C1_W3_Assignment notebook file that includes text for the day-and-time?

Example from my workspace:
image

1 Like

from were i get the new onee

1 Like

You should have gotten it automatically, that’s what happened for me when I opened my notebook to check on your report. I got a popup and the new file.

The w3_unittests.py file should also be new.

What is in your Files menu?

1 Like

1 Like

I have the old one so if you know how to solve the problem in code

1 Like

OK, you have the new w3_unittest.py file.
But you don’t have the new notebook.

Try this procedure to update the notebook:

  • From the Files menu, check the box next to the notebook file, and then click on “Shutdown”.
  • With the box still checked, use the “Rename” button and change the name to “C1_W3_Assignment_old.ipynb”.
  • With the box still checked, click on the View button. Now you’re back at the notebook editor.
  • From the “Help” menu, click on “Get latest version”, then “Update lab”.
  • Now go to Files, then Open, then double-click on the new C1_W3_Assignment.ipynb" file.

Now you should have the new notebook. If you scroll down to the forward_propgation() cell, it should require three parameters.

Now you can open a second copy of the assignment, so you can see both your old and the new notebook. You can copy your code over between the two, so you don’t lose all your owrk.

Note that the C1 W3 assignment was partially re-written, so you’ll have to read carefully and maybe start over on some parts of it.

1 Like

in question 5
parameters = nn_model(X, Y, num_iterations=15, print_cost=True)
print("W = " + str(parameters[“W”]))
print("b = " + str(parameters[“b”]))

W_simple = parameters[“W”]
b_simple = parameters[“b”]

TypeError Traceback (most recent call last)
in
----> 1 parameters = nn_model(X, Y, num_iterations=15, print_cost=True)
2 print("W = " + str(parameters[“W”]))
3 print("b = " + str(parameters[“b”]))
4
5 W_simple = parameters[“W”]

in nn_model(X, Y, num_iterations, print_cost)
24 ### START CODE HERE ### (~ 2 lines of code)
25 # Forward propagation. Inputs: “X, parameters”. Outputs: “Y_hat”.
—> 26 Y_hat = forward_propagation(X, parameters)
27
28 # Cost function. Inputs: “Y_hat, Y”. Outputs: “cost”.

TypeError: forward_propagation() missing 1 required positional argument: 'n_y

1 Like

GRADED FUNCTION: nn_model

def nn_model(X, Y, num_iterations=10, print_cost=False):
“”"
Arguments:
X – dataset of shape (n_x, number of examples)
Y – labels of shape (n_y, number of examples)
num_iterations – number of iterations in the loop
print_cost – if True, print the cost every iteration

Returns:
parameters -- parameters learnt by the model. They can then be used to make predictions.
"""

n_x = layer_sizes(X, Y)[0]
n_y = layer_sizes(X, Y)[1]
# Initialize parameters
### START CODE HERE ### (~ 1 line of code)
parameters = initialize_parameters(n_x, n_y)
### END CODE HERE ###

# Loop
for i in range(0, num_iterations):
     
    ### START CODE HERE ### (~ 2 lines of code)
    # Forward propagation. Inputs: "X, parameters". Outputs: "Y_hat".
    Y_hat = forward_propagation(X, parameters)
    
    # Cost function. Inputs: "Y_hat, Y". Outputs: "cost".
    cost = compute_cost(Y_hat, Y)
    ### END CODE HERE ###
    
    
    # Parameters update.
    parameters = w3_tools.train_nn(parameters, Y_hat, X, Y) 
    
    # Print the cost every iteration.
    if print_cost:
        print ("Cost after iteration %i: %f" %(i, cost))

return parameters
1 Like

With the new notebook, you have to use all three parameters each time you call the forward_propagation() function.

image

You haven’t made the required change here.

1 Like

It looks like the comment line does not mention the 3rd parameter, I’ll report that to the course staff.

That comment should be:

# forward propagation. Inputs "X, parameters, n_y" ...

1 Like

Note that another new version of the notebook was just posted, to fix the error in that comment.

1 Like