I got the error as below when I run my code. Please assist me as I am new in python
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
This error means that the function compute_cost is not defined maybe you are not running that cell or that function name is misspelled.
Thanks gent.spash, I have run the function but yet have the error massage below.
AssertionError Traceback (most recent call last)
in
9 # Public tests
10 from public_tests import *
—> 11 compute_cost_test(compute_cost)
~/work/public_tests.py in compute_cost_test(target)
17 initial_b = 1.0
18 cost = target(x, y, initial_w, initial_b)
—> 19 assert cost == 2, f"Case 2: Cost must be 2 but got {cost}"
20
21 # print(“Using X with shape (5, 1)”)
AssertionError: Case 2: Cost must be 2 but got 32.0
Please assist.
Thank you
This means that this function is not implemented properly, its not outputing right values. Check its implementation.