Skip to content

DataListLoader

DataListLoader(
    dataset: Union[Dataset, Sequence[GraphData]],
    batch_size: int = 1,
    shuffle: bool = False,
    **kwargs,
)

Bases: Dataloader

Data loader yielding plain Python lists of graphs instead of a batch.

Useful to handle the collation yourself, e.g. to split a batch across devices. It takes the same arguments as Dataloader, except collate_fn and follow_batch.

Example:

loader = DataListLoader(graphs, batch_size=4, shuffle=True)
for graph_list in loader:
    assert isinstance(graph_list, list)
Source code in mlx_graphs/loaders/dataloaders.py
def __init__(
    self,
    dataset: Union[Dataset, Sequence[GraphData]],
    batch_size: int = 1,
    shuffle: bool = False,
    **kwargs,
):
    kwargs.pop("collate_fn", None)
    kwargs.pop("follow_batch", None)
    super().__init__(
        dataset, batch_size=batch_size, shuffle=shuffle, collate_fn=list, **kwargs
    )

from mlx_graphs.loaders import DataListLoader · mlx_graphs/loaders/dataloaders.py