C1_W2_Linear Regression "Name Error"

I am getting the “Name Error” when I’m trying to run the test code for the cost_funtion. All the cells above are marked and run without problems.

NameError Traceback (most recent call last)
5 cost_sum = 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 ‘cost’ is not defined

Hey @Simon_Strom,
It seems like you have modified the below line of code:

cost_sum = compute_cost(x_train, y_train, initial_w, initial_b)

Note that you are not supposed to modify any of the test cells. The original test cells use cost as the name of the variable and not cost_sum.

And if this is in a cell that you have created for debugging purposes, note that you have defined cost_sum and not cost, so, either rename your variable or either change the following lines of code. Also, delete any debugging cells that you might have created before submitting your assignment, otherwise these cells might interfere with the auto-grader. I hope this helps.


Thanks! It worked now!