Python 点积可以执行多大的scipy.csr_矩阵?
我正在尝试对大数组执行点积Python 点积可以执行多大的scipy.csr_矩阵?,python,scipy,Python,Scipy,我正在尝试对大数组执行点积 L_mat=csr_matrix(L_mat) # L_mat is (24, 1226880) L_mat_t=csr_matrix(L_mat_t) # L_mat_t is (1226880, 24) # Following is possible? LT_dot_L=L_mat_t.dot(L_mat) # I'm expecting (1226880, 1226880) but when I did this, # I got MemoryError
L_mat=csr_matrix(L_mat)
# L_mat is (24, 1226880)
L_mat_t=csr_matrix(L_mat_t)
# L_mat_t is (1226880, 24)
# Following is possible?
LT_dot_L=L_mat_t.dot(L_mat)
# I'm expecting (1226880, 1226880) but when I did this,
# I got MemoryError
当我执行更小的数组时,我得到了相同的内存错误
(523776, 24) dot (24, 523776)
这是可以执行的
(24, 523776) dot (523776, 24) = (24, 24)
我如何用CSRL矩阵或其他方法来执行大的数组点积?
< P>我不打算尝试内存错误,但是考虑这个测试In [300]: from scipy import sparse
In [301]: M = sparse.random(10,10000, format='csr')
In [302]: M
Out[302]:
<10x10000 sparse matrix of type '<class 'numpy.float64'>'
with 1000 stored elements in Compressed Sparse Row format>
In [303]: M.dot(M.T)
Out[303]:
<10x10 sparse matrix of type '<class 'numpy.float64'>'
with 66 stored elements in Compressed Sparse Row format>
In [304]: M.T.dot(M)
Out[304]:
<10000x10000 sparse matrix of type '<class 'numpy.float64'>'
with 100310 stored elements in Compressed Sparse Column format>
[300]中的:来自scipy导入稀疏
[301]中:M=sparse.random(1010000,format='csr')
In[302]:M
Out[302]:
In[303]:M.dot(M.T)
出[303]:
In[304]:M.T.dot(M)
Out[304]:
M
稀疏度为0.01,Out[304]
为.001,但仍有100倍以上的非零值。对于(12268801226880)矩阵,我可以很容易地想象一个不适合内存的矩阵,即使它很稀疏。这个矩阵有多稀疏?(241226880)就像3x3对角矩阵。所以,6/9可能是零,3/9有值。我测试了(1010000)形状的点积是可能的。但是有了这个大的(241226880)形状,这似乎是不可能的。