lenskit.torch#

PyTorch utility functions.

Functions#

inference_mode(func)

Function decorator that puts PyTorch in inference mode.

safe_tensor(array)

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.safe_tensor(array)#

Safely convert an array into a NumPy tensor. This includes copying it to writable memory if necessary.

Return type:

torch.Tensor