Skip to content
heliaEDGE
Reference
HELIA

torch_data

Torch DataLoader over batches produced by another loader.

Machine-readable model

  • to_torch_loaderfunctionWrap a re-iterable of NumPy batches, such as a Grain dataset, as a Torch DataLoader.
function

Wrap a re-iterable of NumPy batches, such as a Grain dataset, as a Torch DataLoader.

helia_edge/data/torch_data.py:29

to_torch_loader(dataset: Iterable[Any]) -> torch.utils.data.DataLoader

Wrap a re-iterable of NumPy batches, such as a Grain dataset, as a Torch DataLoader.

The loader adds no batching, shuffling or workers of its own: each iter() iterates dataset once more in this process and converts its NumPy leaves to tensors, keeping the structure (dicts, lists, tuples) and the order. Arrays in worker shared memory are copied first, so tensors stay valid after the next element arrives. Do batching and parallel reads in dataset.

Parameters of to_torch_loader
NameTypeDefaultDescription
datasetIterable[Any]RequiredRe-iterable whose ``iter()`` starts from the first element.
Returns of to_torch_loader
TypeDescription
torch.utils.data.DataLoadertorch.utils.data.DataLoader: With ``batch_size=None``, so elements pass through as they are.
Errors raised by to_torch_loader
TypeDescription
ImportErrorIf Torch is not installed (``helia-edge[torch]``).