lenskit.math.sparse#
Sparse matrix utility functions.
Functions
Normalize the rows of a sparse matrix. |
|
|
Sparse matrix-vector multiplication working around PyTorch bugs. |
|
Convert a SciPy |
|
- lenskit.math.sparse.normalize_sparse_rows(matrix: Tensor, method: Literal['center'], inplace: bool = False) tuple[Tensor, Tensor] #
- lenskit.math.sparse.normalize_sparse_rows(matrix: Tensor, method: Literal['unit'], inplace: bool = False) tuple[Tensor, Tensor]
Normalize the rows of a sparse matrix.
- lenskit.math.sparse.torch_sparse_from_scipy(M, layout='coo')#
Convert a SciPy
sps.coo_array
into a torch sparse tensor.
- lenskit.math.sparse.safe_spmv(matrix, vector)#
Sparse matrix-vector multiplication working around PyTorch bugs.
This is equivalent to
torch.mv()
for sparse CSR matrix and dense vector, but it works around PyTorch bug 127491 by falling back to SciPy on ARM.