scipy.optimize.leastsq MemoryError

时间:2019-06-29 03:11:45

标签: python-3.x scipy

最近我尝试解决一个优化问题:使用scipy.optimize.lsq_linear求解AX = b,矩阵A的大小为(23250,14725),向量b的大小为(23250,),向量lb的大小ub是(14725,)。但是当我运行代码时,问题报告“ MemoryError”

我的python版本是python3.5,numpy的版本是1.11.0。 scipy版本为“ 0.17.1”

我使用的代码如下:

import numpy as np
import h5py
from scipy import optimize
#construct matrix A
mat=h5py.File('FLGJZ_norm.mat','r')
A = np.transpose(mat['FLGJZ'])
print(A.shape)
#construct vector b
mat2=h5py.File('NEUJZ_norm.mat','r')
b1=np.transpose(mat2['NEUJZ'])
print(b1.shape)
b = np.asarray(b1).reshape(-1)
print(b.shape)
#construct lower constraint vector lb
mat3=h5py.File('lb.mat','r')
lb1=(mat3['lb'])
print(lb1.shape)
lb = np.asarray(lb1).reshape(-1)
#construct upper constraint vector ub
mat4=h5py.File('ub.mat','r')
ub1=(mat4['ub'])
print(ub1.shape)
ub = np.asarray(ub1).reshape(-1)

res=optimize.lsq_linear(A, b, bounds=(lb,ub), method='trf', tol=1e-2, lsq_solver=None, lsmr_tol='auto', max_iter=300, verbose=2)

我期望结果为'x',但是它报告如下的'MemoryError':

![Memory Error] 1

0 个答案:

没有答案