我正在使用Optim.jl库来最小化Julia中的函数,使用BFGS算法。今天,我问了一个question关于同一个库,但为了避免混淆,我决定将它分成两部分。Optim.jl:负反Hessian
我还想在优化后得到负反Hessian的估计值,以便进一步计算。
在库中的Optim的GitHub的网站,我发现下面的工作例如:
using Optim
rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
result = optimize(rosenbrock, zeros(2), BFGS())
我怎样才能得到结果优化后的负逆海森?是否有任何字段可以识别Hessian,Inverse Hessian或负Hessian?
编辑
感谢您的意见。你认为编辑“optimize.jl”会使函数返回逆Hessian更有效吗?请参阅下面的工作示例 - 编辑已经在管线226被引入:
if state.method_string == "BFGS"
return MultivariateOptimizationResults(state.method_string,
initial_x,
f_increased ? state.x_previous : state.x,
f_increased ? state.f_x_previous : state.f_x,
iteration,
iteration == options.iterations,
x_converged,
options.x_tol,
f_converged,
options.f_tol,
g_converged,
options.g_tol,
f_increased,
tr,
state.f_calls,
state.g_calls,
state.h_calls), state.invH
else
return MultivariateOptimizationResults(state.method_string,
initial_x,
f_increased ? state.x_previous : state.x,
f_increased ? state.f_x_previous : state.f_x,
iteration,
iteration == options.iterations,
x_converged,
options.x_tol,
f_converged,
options.f_tol,
g_converged,
options.g_tol,
f_increased,
tr,
state.f_calls,
state.g_calls,
state.h_calls)
end
或者只是:
return MultivariateOptimizationResults(state.method_string,
initial_x,
f_increased ? state.x_previous : state.x,
f_increased ? state.f_x_previous : state.f_x,
iteration,
iteration == options.iterations,
x_converged,
options.x_tol,
f_converged,
options.f_tol,
g_converged,
options.g_tol,
f_increased,
tr,
state.f_calls,
state.g_calls,
state.h_calls), state
要使优化后全面进入“状态”。
EDIT 2
因为这种变化将在Optim.jl库的新版本推出,就没有必要继续讨论。就目前而言,extended_trace和after_while!技巧工作。就我个人而言,我更喜欢后者,所以我将结束讨论,给予丹茨茨正确的答案。
建议更改为'optimize.jl'会有效,但BFGS对'optimize.jl'的具体规定也是如此,并且没有解决访问任何优化器的最终优化状态的自然需求 –
最后一次编辑怎么样?含义:优化后允许访问“状态”。 – merch
这当然是我打算添加到Optim的东西。没有人需要编辑包中的文件! – pkofod