W2_Getting error_"NoneType object isn't subscriptable"

I receive an error: " ‘NoneType’ object is not subscriptable"
when I run the cell below the one where we define our model. I can run the next cell which examines the model but keep receiving this error in some cells. What should I do?

Hi there, welcome to the community!
This type of error usually occurs when you are trying to subscript from a NoneType, and NoneType represents a lack of value.
By saying

do you mean you start to get this error after exercise 8? Can you show more details about this error, i.e., in which variable did you get that?

I get this error in cell [114] while I can run the next one! Cells [116] and [117] cannot be run as well.

For the model() function, what’s your return?

It doesn’t have a return, as we’re not calling the function. However, the next cell, [114] which calls the model faces that error I sent you earlier. Can I send you my submission?

If you look at the model_test function, you’ll find that it also calls model. You can find the code by clicking “File → Open” and then opening the file public_tests.py. Note that a reference to the model function is passed as an argument to model_test.

Looking at what we can see in the image of your most recent post, it looks like you have modified the template code that they gave you at the end of the model function cell. Here’s what the template code looks like in a clean notebook:

    # Print train/test Errors
    if print_cost:
        print("train accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction_train - Y_train)) * 100))
        print("test accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction_test - Y_test)) * 100))

    d = {"costs": costs,
         "Y_prediction_test": Y_prediction_test, 
         "Y_prediction_train" : Y_prediction_train, 
         "w" : w, 
         "b" : b,
         "learning_rate" : learning_rate,
         "num_iterations": num_iterations}
    return d

It looks like you removed the return statement and replaced it with a call to model with no arguments. That will not end well, as we see. Why did you do that? There was no need to modify that section of the code.

Hi there, I think the error message indicates the lack of return from the call of model() function. As Paul @paulinpaloalto has mentioned, it is because some codes from the original assignment file are missing. I think refreshing the assignment file to the original one may solve this issue. You may also want to first save a copy of your answers though. LoL