C1_W2 Linear Regression

I’m confused.
When I run the test code; I get an error:

NameError: name ‘x_train’ is not defined

It’s indicating this line
5 cost = compute_cost(x_train, y_train, initial_w, initial_b)

I can’t figure out how to fix it.

Start by running all of the cells from the top of the notebook. You have to do this every time you open the notebook.

Also, inside the compute_cost() function, the variable is x, not ‘x_train’. Variable names are local to their scope.

1 Like

Ah thank you so much that did it. I did not know that you had to run all the cells from top to bottom! Thank you!