I have been using the following code:
options = {'maxiter':50, 'disp':True}
res = optimize.minimize(
fun=lrCostFunction,
x0=theta_k,
args=(X, y_k, lambda_),
method='CG',
options=options
)
And that gives me the following error:
TypeError: only size-1 arrays can be converted to Python scalars
The above exception was the direct cause of the following exception:
ValueError: setting an array element with a sequence.
But when I set jac = True
as following:
options = {'maxiter':50, 'disp':True}
res = optimize.minimize(
fun=lrCostFunction,
x0=theta_k,
jac=True,
args=(X, y_k, lambda_),
method='CG',
options=options
)
Everything works fine, but the documentation doesn't state that we must set jac = True
, so what's wrong here?