Week 4 Neural network application

When creating a post, please add:

  • Week # must be added in the tags option of the post.
  • Link to the classroom item you are referring to:
  • Description (include relevant info but please do not post solution code or your entire notebook)

I’ m getting this error while trying to run the code from read-only cell in the notebook of Week4.

NameError Traceback (most recent call last)
in
----> 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)

NameError: name 'L_layer_model' is not defined

Definition for function:

GRADED FUNCTION: L_layer_model

def L_layer_model (X, Y, layers_dims, learning_rate= 0.0075, num_iterations = 3000, print_cost=False):

Function Call:

parameters, costs = L_layer_model(train_x, train_y, layers_dims, num_iterations = 1, print_cost = False)

print("Cost after first iteration: " + str(costs[0]))

L_layer_model_test(L_layer_model)

Wha am i missing?

You should try running the cells from top to the bottom. Cells that are on top must be run before the cells below it.

You need to run the cell containing the “def L_layer_model(…)” code first, before running the one containing “L_layer_model_test”.

I did run each cell. Did i mention that i get this error not while running each cell, but after submission.

Can you please post a screenshot of the error you get after submission?

I think that should help us with identifying the problem.


Please review the screenshot.

There seems to be something wrong with your implementation of the function L_layer_model. You need to figure out where it is failing. If you think there is something wrong with the kernel try reseting:

  • Kernel > Restart Kernel and Clear Output of all cells
  • Go to the cell block that has your ‘L_layer_model()’
  • Run > Run all above selected Cell
  • Run your cell block with L_layer_model()
  • Run the test Block

If you’re still seeing errors there is something wrong with your implementation. In which case you need to dig deeper into where it is failing. I suggest using some ‘print’ statements to debug. Make sure to remove/ comment them out prior to submitting.

The “…” at the end of the line looks suspicious, but I’m not sure whether or not that’s just the way it’s formatted by the autograder output.

It’s hard to tell what the issue is without the code. Send me a private message with a screenshot of your code and I can help you debug.