-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use scipy.optimize.minimize method='CG' to run gradient descent #1
Comments
Further observation: method='CG' works for all cases i in range(9) except i=8, giving error: shapes (5000,401) and (1,1,401) not aligned: 401 (dim 1) != 1 (dim 1) |
Seems to be a bug in scipy. |
Observation: in certain circumstances, scipy.optimize.minimize(... method='CG'...) will add dimension to x0 (here x0=theta0) and thus making matrix multiplication in cost function error out. Temporary workaround: in my cost function, ravel theta0 first, make sure it is 1D; then add proper dimension to it to make it a 2D array (column vector). More comments:
|
This is in assignment3 section 1.4 function oneVsAll()
result = minimize(lrCostFucntion, theta0, args=(X, ylabel, lmd), method='TNC', jac=True, options={'disp': True, 'maxiter':1000})
Method='CG' should work, too, or even faster. But there's error.
Suspect a bug inside minimize function, it seems to change the shape of theta in the process, causing dimension issue when trying to do matrix multiplication.
The text was updated successfully, but these errors were encountered: