[英]Scipy.linalg.solve max array size
Is there a maximum size that scipy.linalg.solve
( numpy.linalg.solve
also fails) can handle? 是否存在
scipy.linalg.solve
( numpy.linalg.solve
也会失败)可以处理的最大大小?
I'm working on porting some Matlab code (some poisson image cloning, which I didn't write) into python, and in Python I have the code: 我正在将一些Matlab代码(一些泊松图像克隆,我没有写过)移植到python中,在Python中我有以下代码:
print M.shape
print b.shape
x = scipy.linalg.solve(M,b)
Which keeps returning the output (and error): 不断返回输出(和错误):
(2550, 2550)
(2550, 1)
Traceback (most recent call last):
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\test_runner.py", line 19, in <module>
ibgFaceManipulator.main(testOut,pathName,ptsFile,subjectId,'2','0')
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\ibgFaceManipulator.py", line 70, in main
ManipulateFaceWrapper.main(outDir,subjectId,retry,attempts,listchoice,NewImageData,AllBlend,Patchizer)
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\ManipulateFaceWrapper.py", line 31, in main
ManipulateFace.main(outdir,newImageData,3,filename,patchizer,blendParam,eyeDistortionParams,mouthDistortionParams,[])
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\ManipulateFace.py", line 38, in main
FaceTex = PatchOverFaceWithSelectionPre.main(TexLib,FaceTex,OperationMaskNew,M,0)
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\PatchOverFaceWithSelectionPre.py", line 104, in main
tex = poissonImageCloneColor.main(tex,source_tex,imgProc.imerode(imMask,imgProc.strel('disk',1)))
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\poissonImageCloneColor.py", line 22, in main
imr = poissonImageClone.main(imir, imr,imMask)
File "D:\Other\WB_Lab\PythonPort\FaceManip\Code\poissonImageClone.py", line 81, in main
x = scipy.linalg.solve(np.squeeze(M),b)
File "C:\Python27\lib\site-packages\scipy\linalg\basic.py", line 78, in solve
raise ValueError('expected square matrix')
ValueError: expected square matrix
But I know for certain that M is square (of size 2550,2550
). 但我肯定知道M是正方形(大小为
2550,2550
)。 Both M and b are of dtype float64, and M is a csc formatted matrix. M和b均为dtype float64,M是csc格式的矩阵。
Has anyone seen similar errors before? 有没有人看过类似的错误?
I have found the numpy.linalg.cond(M)
also fails. 我发现
numpy.linalg.cond(M)
也失败。 This time saying that the Matrix M is 0-dimensional (which is the same error numpy.linalg.solve
gives me). 这次说矩阵M是0维的(
numpy.linalg.solve
给我同样的错误)。
I did some more research and found that sparse matrices (which I'm using) are actually a special case. 我进行了更多研究,发现稀疏矩阵(我正在使用的)实际上是一个特例。 Scipy has a different solve function for them scipy.sparse.linalg.spsolve .
Scipy对他们scipy.sparse.linalg.spsolve具有不同的求解功能。 Using this I was able to get solve the equation and get results.
使用此程序,我能够求解方程式并得到结果。
Hmmm... Interesting. 嗯...有趣。 Mine gave the correct result.
我的给出了正确的结果。 Could you try a simple matrix, like:
您能否尝试一个简单的矩阵,例如:
import numpy as np
from scipy.linalg import solve
M = np.eye(5)
b = np.ones(5)
solve(M, b)
to see whether the problem still remains? 看问题是否仍然存在? And also, what version is your scipy?
而且,您的密码是哪个版本?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.