lenskit.torch#
PyTorch utility functions.
Functions#
|
Function decorator that puts PyTorch in inference mode. |
|
Get a row of a sparse (CSR) tensor. This is needed because indexing a |
|
Safely convert an array into a NumPy tensor. This includes copying it to |
Module Contents#
- lenskit.torch.inference_mode(func)#
Function decorator that puts PyTorch in inference mode.
- lenskit.torch.sparse_row(mat, row)#
Get a row of a sparse (CSR) tensor. This is needed because indexing a tensor does not work in inference mode.
- Parameters:
mat (torch.Tensor)
row (int)
- Return type:
- lenskit.torch.safe_tensor(array)#
Safely convert an array into a NumPy tensor. This includes copying it to writable memory if necessary.
- Return type: