lenskit.math.sparse#

Sparse matrix utility functions.

Functions

normalize_sparse_rows()

Normalize the rows of a sparse matrix.

torch_sparse_from_scipy(M[, layout])

Convert a SciPy sps.coo_array into a torch sparse tensor.

torch_sparse_to_scipy(M)

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.

Parameters:
Return type:

Tensor