मैं एक विरल वेक्टर एक scipy.sparse.csr_matrix
इसलिए की तरह का उपयोग कर निर्माण कर रहा हूँ:गुप्त scipy "पूर्णांक अदिश परिवर्तित नहीं सका" त्रुटि
csr_matrix((values, (np.zeros(len(indices)), indices)), shape = (1, max_index))
यह मेरा डेटा के अधिकांश के लिए ठीक काम करता है, लेकिन कभी कभी मैं एक ValueError: could not convert integer scalar
मिलता है।
यह समस्या reproduces:
In [145]: inds
Out[145]:
array([ 827969148, 996833913, 1968345558, 898183169, 1811744124,
2101454109, 133039182, 898183170, 919293479, 133039089])
In [146]: vals
Out[146]:
array([ 1., 1., 1., 1., 1., 2., 1., 1., 1., 1.])
In [147]: max_index
Out[147]:
2337713000
In [143]: csr_matrix((vals, (np.zeros(10), inds)), shape = (1, max_index+1))
...
996 fn = _sparsetools.csr_sum_duplicates
997 M,N = self._swap(self.shape)
--> 998 fn(M, N, self.indptr, self.indices, self.data)
999
1000 self.prune() # nnz may have changed
ValueError: could not convert integer scalar
inds
एक np.int64
सरणी है और vals
एक np.float64
सरणी है।
scipy sum_duplicates
कोड का प्रासंगिक भाग here है।
ध्यान दें कि यह काम करता है:
In [235]: csr_matrix(([1,1], ([0,0], [1,2])), shape = (1, 2**34))
Out[235]:
<1x17179869184 sparse matrix of type '<type 'numpy.int64'>'
with 2 stored elements in Compressed Sparse Row format>
तो समस्या नहीं है आयामों की है कि एक > 2^31
किसी भी विचार यही वजह है कि इन मूल्यों से समस्या हो रही किया जाना चाहिए?
कृपया उसी उदाहरण के साथ '2 ** 31' और' 2 ** 31-1' का उपयोग करने का प्रयास करें। – matiasg
हां, मैंने पोस्ट किया गया नमूना डेटा '2 ** 31-1' के साथ काम करता है लेकिन 2 ** 31 – Rok