src.utils.sparse.ssp2torch¶
- src.utils.sparse.ssp2torch(M, batch='dim', dtype=torch.float32, device=None)[source]¶
Convert scipy.sparse matrix to torch sparse matrix. Since scipy.sparse has a dimension limit of 2, list of matrices is supported for batches. :param M: input scipy.sparse matrix :param batch: the type that represent batches in the output.
If batch=’list’, tensors are 2d and stored in list. If batch=’dim’, tensors are 3d ane the first dimension represents batch size.
- Parameters
dtype – output data type
device – device
- Returns
output torch sparse matrix