使用anaconda scipy对大型矩阵进行对角化时出错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用anaconda scipy对大型矩阵进行对角化时出错相关的知识,希望对你有一定的参考价值。
我最近在mac OS X上使用homebrew python切换到使用anaconda,并且在对大型(ish)矩阵进行对角化时我开始出错。使用大约3000x3000条目的矩阵调用scipy.linalg.eigvalsh(A)
会出错:
$HOME/anaconda2/lib/python2.7/site-packages/scipy/linalg/decomp.pyc in eigvalsh(a, b, lower, overwrite_a, overwrite_b, turbo, eigvals, type, check_finite)
762 overwrite_a=overwrite_a, overwrite_b=overwrite_b,
763 turbo=turbo, eigvals=eigvals, type=type,
--> 764 check_finite=check_finite)
765
766
$HOME/anaconda2/lib/python2.7/site-packages/scipy/linalg/decomp.pyc in eigh(a, b, lower, eigvals_only, overwrite_a, overwrite_b, turbo, eigvals, type, check_finite)
385 if eigvals is None:
386 w, v, info = evr(a1, uplo=uplo, jobz=_job, range="A", il=1,
--> 387 iu=a1.shape[0], overwrite_a=overwrite_a)
388 else:
389 (lo, hi) = eigvals
ValueError: On entry to ZHBRDB parameter number 12 had an illegal value
最后的错误消息看起来类似于这个古老的scipy问题:scipy/issues/5401,但我遇到问题的矩阵要小得多。
运行print np.__config__.show()
给出:
lapack_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$HOME/anaconda2/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['$HOME/anaconda2/include']
blas_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$HOME/anaconda2/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['$HOME/anaconda2/include']
lapack_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$HOME/anaconda2/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['$HOME/anaconda2/include']
blas_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['$HOME/anaconda2/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['$HOME/anaconda2/include']
None
答案
根据@brd490的讨论,这是一个MKL错误,由SciPy issue 8205友情报道,是accepted by the Intel MKL team
请注意,OpenBLAS构建的SciPy没有此问题。然而,与此同时,我们也注意到scipy.linalg.eigh
中的最佳工作空间数组大小不正确。一旦决定如何更改底层?SYEVR
/ ?HEEVR
包装器的签名,这也将得到纠正。
作为奖励,可能有人能够有选择地计算特征值,因为最初这些例程允许它但不暴露在scipy.linalg.eigh
中。
以上是关于使用anaconda scipy对大型矩阵进行对角化时出错的主要内容,如果未能解决你的问题,请参考以下文章