本文介绍了使用SciPy最小化估计逆黑森州的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SciPy的最小化"功能来最小化功能.该函数将返回最佳值以及估计的Jacobian和Hessian.如下:

I am using SciPy's 'minimize' function to minimize a function. The function returns the optimal value, along with an estimated Jacobian and Hessian. As below:

fun: -675.09792378630596
hess_inv: <8x8 LbfgsInvHessProduct with dtype=float64>
jac: array([  6.34713615e-02,   1.15960574e-03,   1.63709046e-03, 2.16914486e-02,  -8.02970135e-02,  -4.39513315e-02,
6.69160727e-02,  -5.68434189e-05])
message: b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH'
nfev: 684
nit: 60
status: 0
success: True
x: array([  9.93756778e-01,   3.51823214e+00,  -2.06368373e-01, 7.37395700e-04,   2.11222756e-02,   3.29367564e-02, 1.22886906e-01,  -2.75434386e-01])

我想要估计的Hessian,但是当我返回hess_inv时,我得到的只是

I want the estimated Hessian, but when I have it return hess_inv, all I get returned is

<8x8 LbfgsInvHessProduct with dtype=float64>

而不是maxtrix本身.如何让它返回矩阵?

rather than the maxtrix itself. How do I have it return the matrix?

推荐答案

来自 LbfgsInvHessProduct的SciPy文档;您可以使用方法 todense()获得LbfgsInvHessProduct的值作为密集数组.

From the SciPy documentation for the LbfgsInvHessProduct; you can use the method todense() to obtain the LbfgsInvHessProduct's values as a dense array.

但是,请记住LbfgsInvHessProduct仍然是矩阵!这是一种特殊的内存优化格式,但是您仍然可以调用其他矩阵函数,例如matmat(),transpose(),dot()等.

However, keep in mind the LbfgsInvHessProduct is still a matrix! It's a special memory-optimized format, but you can still call other matrix functions such as matmat(), transpose(), dot() etc.

这篇关于使用SciPy最小化估计逆黑森州的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:58