I working on my first lab and having these issues - help


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 ‘compute_cost’ is not defined

Hi, Tony.

Welcome to the Forums! You’ve filed your question in a generic “Discussion” category. Generally you’ll have better luck getting a quick and helpful response if you file course related questions in the appropriate “Course Q&A” category for your course. You can move the thread using the little “edit pencil” on the title. Or you can reply and tell us the name of the course and I can move it for you.

I don’t recognize the code as being from a course that I know, but one thing to check is whether you forgot to run the previous cells in the notebook. Just having the code sitting there does nothing until you actually run the cell to get the functions added to the runtime image of the notebook. Try:

Cell -> Run All Above

and then try running your test cell again.