load_np#

deepinv.utils.load_np(fname, as_memmap=False, dtype=np.float32, **kwargs)[source]#

Load numpy array from file as torch tensor.

Parameters:
  • fname (str, pathlib.Path) – file to load.

  • as_memmap (bool,) – open this file as a memmap, which does not load the entire array into memory. This is useful when extracting patches from large arrays or to quickly infer dtype and shape.

  • dtype (numpy.dtype, str) – data type to use when loading the numpy array. This is ignored if as_memmap is True.

Returns:

torch.Tensor containing loaded numpy array. If as_memmap is True, returns a numpy memmap object instead.

Return type:

Tensor | ndarray