压缩稀疏行,indptr有两个相同的值
Compressed Sparse Row, indptr has two same values
indptr 指向索引和数据中的行开始。我已经通过 np.savez() 将我的矩阵转换为 csr 矩阵。但是,我注意到 indptr 的第一个元素如下:
1
1
23
195
213
256
284
317
表示第一行和第二行以相同的数据开头。是什么原因导致此错误,或者这是一个错误?
表示第2行全为0
In [187]: from scipy import sparse
In [191]: M=sparse.csr_matrix([[0,0,1],[0,0,0],[0,1,0],[1,1,0]])
In [192]: M.A
Out[192]:
array([[0, 0, 1],
[0, 0, 0],
[0, 1, 0],
[1, 1, 0]], dtype=int32)
In [193]: M.indptr
Out[193]: array([0, 1, 1, 2, 4], dtype=int32)
(尽管 indptr
开头缺少 0 有点令人担心。)
.A
(toarray()
) 显示什么?
indptr 指向索引和数据中的行开始。我已经通过 np.savez() 将我的矩阵转换为 csr 矩阵。但是,我注意到 indptr 的第一个元素如下:
1
1
23
195
213
256
284
317
表示第一行和第二行以相同的数据开头。是什么原因导致此错误,或者这是一个错误?
表示第2行全为0
In [187]: from scipy import sparse
In [191]: M=sparse.csr_matrix([[0,0,1],[0,0,0],[0,1,0],[1,1,0]])
In [192]: M.A
Out[192]:
array([[0, 0, 1],
[0, 0, 0],
[0, 1, 0],
[1, 1, 0]], dtype=int32)
In [193]: M.indptr
Out[193]: array([0, 1, 1, 2, 4], dtype=int32)
(尽管 indptr
开头缺少 0 有点令人担心。)
.A
(toarray()
) 显示什么?