Traceback: x_train not defined Exercise 1 assignment 1

Hello,

I am having trouble with the first exercise on assignment 1. I think I figured out the __ and the cost lines to add however once i ran the code to “check if the implementation was correct” I kept getting the following error:

"NameError Traceback (most recent call last)
in
3 initial_b = 1
4
----> 5 cost = compute_cost(x_train, y_train, initial_w, initial_b)
6 print(type(cost))
7 print(f’Cost at initial w: {cost:.3f}')

NameError: name ‘x_train’ is not defined

So then I looked at the option labs and saw how Dr. Ng was writing the x_train and y_train in his code so I added it to hoping that would define x_train and y_train but the traceback persists.

can anyone give me some insight to where my code is incorrect?
Thanks

1 Like

the <x_train> and <y_train> is on the 2nd code cell

# load the dataset
x_train, y_train = load_data()

You should run the code cells from top to down.

Indeed, whenever you open a notebook, you always have to run every cell in the notebook from the top.

Don’t add extra code unless you’re specifically asked to.