C1_W3_Logistic Regression

I am trying to submit my assignment but it shows the problem name “X” not defined.

NameError Traceback (most recent call last)
in
4 initial_w = np.zeros(n)
5 initial_b = 0.
----> 6 cost = compute_cost(X_train, y_train, initial_w, initial_b)
7 print(‘Cost at initial w and b (zeros): {:.3f}’.format(cost))

in compute_cost(X, y, w, b, *argv)
19 total_cost = 0
20 for i in range(m):
—> 21 z = np.dot(x[i], w) + b
22 f_wb = sigmoid(z)
23 loss = -y[i]*np.log(f_wb) - (1-y[i])*np.log(1-f_wb)

NameError: name ‘x’ is not define

Make sure you are run down all the cells from beginning to the cell you encountered this issue

Also note that python is a case sensitive language, so X is not the same thing as x. Note that the variable in the parameter list of the function is X.

2 Likes