怎么把稀疏矩阵scipy.sparse.csr.csr_matrix格式的变量转成正常numpy的array?
谢谢!
1个回答
s.A可以得到一个numpy array
>>> import numpy as np
>>> import scipy.sparse
>>> my_matrix = scipy.sparse.csr_matrix((2,2))
>>> my_array = my_matrix.A
>>> type(my_array)
numpy.ndarray
怎么把稀疏矩阵scipy.sparse.csr.csr_matrix格式的变量转成正常numpy的array?
谢谢!
s.A可以得到一个numpy array
>>> import numpy as np
>>> import scipy.sparse
>>> my_matrix = scipy.sparse.csr_matrix((2,2))
>>> my_array = my_matrix.A
>>> type(my_array)
numpy.ndarray