我试图用^{
from scipy.optimize import minimize
def fun(x):
return (x[0] - 1)**2 + (x[1] - 2.5)**2
# solver
res = minimize(fun, (2, 0), method='dogleg', jac=False) # or jac=None, it doesn't matter
print(res)
我得到一个错误ValueError: Jacobian is required for dogleg minimization.
这类似于一个老问题:"Jacobian is required for Newton-CG method" when doing a approximation to a Jacobian not being used when jac=False?,它似乎没有得到解决。在
所以我的问题是:这个^{
必须传递一个雅可比函数才能使用} 的
dogleg
方法,因为它是基于梯度的优化方法。如果你看一下^{jac
参数,它表示如果你往下看页面底部的注释:
一些基于梯度的方法不需要显式的雅可比(和/或Hessian),因为它们将使用差分方法来近似它们。但是
dogleg
确实需要您显式地传递这样一个函数。在相关问题 更多 >
编程相关推荐