我正在将一些高斯过程回归的代码从MATLAB转换为Python,而我的Python版本比Matlab版本慢得多。我从程序的cProfile
中发现瓶颈是Linalg库中Numpy函数solve
的瓶颈。此函数比MATLAB的对应函数(即mldivide
或\
运算符)慢得多,并且要慢得多,而且调用频率很高,以致整个代码的效率受到损害。我可以做些什么来加快solve
的速度,还是在Python中有更好的替代方法?
这里是我的np.show_config(),以防万一:
blas_mkl_info:
NOT AVAILABLE
blis_info:
NOT AVAILABLE
openblas_info:
NOT AVAILABLE
atlas_3_10_blas_threads_info:
NOT AVAILABLE
atlas_3_10_blas_info:
NOT AVAILABLE
atlas_blas_threads_info:
NOT AVAILABLE
atlas_blas_info:
NOT AVAILABLE
blas_opt_info:
extra_compile_args = ['-msse3', '-
I/System/Library/Frameworks/vecLib.framework/Headers']
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
lapack_mkl_info:
NOT AVAILABLE
openblas_lapack_info:
NOT AVAILABLE
openblas_clapack_info:
NOT AVAILABLE
atlas_3_10_threads_info:
NOT AVAILABLE
atlas_3_10_info:
NOT AVAILABLE
atlas_threads_info:
NOT AVAILABLE
atlas_info:
NOT AVAILABLE
lapack_opt_info:
extra_compile_args = ['-msse3']
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]