You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`
def oneVsAll(X, y, num_labels, lambda_):
# Some useful variables
m, n = X.shape
# You need to return the following variables correctly
all_theta = np.zeros((num_labels, n + 1))
# Add ones to the X data matrix
X = np.concatenate([np.ones((m, 1)), X], axis=1)
# ====================== YOUR CODE HERE ======================
initial_theta = np.zeros((n+1,1))
options = {'maxiter': 50}
for c in np.arange(1, num_labels+1):
res = optimize.minimize(lrCostFunction,
initial_theta,
(X, (y == c), lambda_),
jac=True,
method='TNC',
options=options)
all_theta[c-1] = res.x
# ============================================================
return all_theta
`
Hi,Dib,
Could you please tell me what's wrong with my code? I am confused.
Thanks.
The text was updated successfully, but these errors were encountered:
I'm facing problems in the same block. Here's my code:
`
# Some useful variables
m, n = X.shape
# You need to return the following variables correctly
ll_theta = np.zeros((num_labels, n + 1))
# Add ones to the X data matrix
X = np.concatenate([np.ones((m, 1)), X], axis=1)
# ====================== YOUR CODE HERE ======================
for c in np.arange(num_labels):
initial_theta=np.zeros(n+1)
options={'maxiter':50}
res=optimize.minimize(lrCostFunction,initial_theta,(X,(y==c),lambda_),jac=True,method='TNC',options=options)
all_theta[c]=res.x
# ============================================================
return all_theta`
I'm able to call the function without errors, from the next block lambda_ = 0.1 all_theta = oneVsAll(X, y, num_labels, lambda_)
Then, when I try to submit the work, no error is thrown, but following is the result:
The scores aren't shown on Coursera either. Please help.
Uh oh!
There was an error while loading. Please reload this page.
`
def oneVsAll(X, y, num_labels, lambda_):
# Some useful variables
m, n = X.shape
`
Hi,Dib,
Could you please tell me what's wrong with my code? I am confused.
Thanks.
The text was updated successfully, but these errors were encountered: