MLS Week 3 assignment

My gradient descent code has the error below
name error ‘x’ not defined

Please assist

Thanks
Martins

The error massage is below:
NameError Traceback (most recent call last)
in
3 initial_b = 0.
4
----> 5 dj_db, dj_dw = compute_gradient(X_train, y_train, initial_w, initial_b)
6 print(f’dj_db at initial w (zeros):{dj_db}’ )
7 print(f’dj_dw at initial w (zeros):{dj_dw.tolist()}’ )

in compute_gradient(X, y, w, b, lambda_)
27 z_wb = 0
28 for j in range (n):
—> 29 z_wb_ij = x[i,j] * w[j]
30 z_wb+= z_wb_ij
31 z_wb=+ z_wb_ij + b

NameError: name ‘x’ is not defined

1 Like

Hi!

did you define a variable x?
from the definition of compute_gradient(X, y, w, b, lambda_) there is a variable X.

Thank you SamReiswig.

I sorted that, let me go for other errors