Convert a list of scipy sparse matrices to PyTorch 3D sparse tensor

I have a list of scipy lil_matrix and want to convert it to a 3D PyTorch sparse tensor.

I read the document TORCH.SPARSE but I did not find too much information about how to construct a 3D sparse tensor. The document mentions

You can also construct hybrid sparse tensors, where only the first n dimensions are sparse, and the rest of the dimensions are dense.

In my case, I want to construct the sparse tensor with the shape like batch_size * M * N.

1 Like