function
to_torch_loader
PythonWrap a re-iterable of NumPy batches, such as a Grain dataset, as a Torch DataLoader.
to_torch_loader(dataset: Iterable[Any]) -> torch.utils.data.DataLoaderWrap 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
| Name | Type | Default | Description |
|---|---|---|---|
dataset | Iterable[Any] | Required | Re-iterable whose ``iter()`` starts from the first element. |
Returns
| Type | Description |
|---|---|
torch.utils.data.DataLoader | torch.utils.data.DataLoader: With ``batch_size=None``, so elements pass through as they are. |
Raises
| Type | Description |
|---|---|
ImportError | If Torch is not installed (``helia-edge[torch]``). |