how can i save a dok matrix?

As you’ve noticed, you can’t. But the notes on dok_matrix say:

Can be efficiently converted to a coo_matrix once constructed.

and coo_matrix does support saving with scipy.sparse.save_npz. So I would suggest converting with .tocoo() and then saving. You can convert back after loading (if you wish).

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top