Storing numpy sparse matrix in HDF5 (PyTables)

后端 未结 3 455
耶瑟儿~
耶瑟儿~ 2020-11-30 01:32

I am having trouble storing a numpy csr_matrix with PyTables. I\'m getting this error:

TypeError: objects of type ``csr_matrix`` are not supported in this co         


        
3条回答
  •  北海茫月
    2020-11-30 01:51

    A CSR matrix can be fully reconstructed from its data, indices and indptr attributes. These are just regular numpy arrays, so there should be no problem storing them as 3 separate arrays in pytables, then passing them back to the constructor of csr_matrix. See the scipy docs.

    Edit: Pietro's answer has pointed out that the shape member should also be stored

提交回复
热议问题