jestem konstruowaniu rzadki wektor uzywajac scipy.sparse.csr_matrix
tak:tajemnicze scipy „nie można przekonwertować całkowitą skalarne” błąd
csr_matrix((values, (np.zeros(len(indices)), indices)), shape = (1, max_index))
Działa to dobrze dla większości moich danych, ale od czasu do czasu dostaję ValueError: could not convert integer scalar
.
ten powtarza się problem:
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
jest np.int64
Array vals
jest np.float64
tablicy.
Istotna część kodu scipy sum_duplicates
to here.
Zauważ, że to działa:
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>
więc problemem nie jest to, że jeden z wymiarów jest > 2^31
wszelkie myśli, dlaczego te wartości powinny być przyczyną problemu?
proszę spróbować użyć '2 ** 31' i' 2 ** 31-1' z tym samym przykładem, który wysłałeś. – matiasg
tak, przykładowe dane Zamieściłem prace z '2 ** 31-1' ale nie 2 ** 31 – Rok