DenseDataLoader
¶
DenseDataLoader(
dataset: Union[Dataset, Sequence[GraphData]],
batch_size: int = 1,
shuffle: bool = False,
**kwargs,
)
Bases: Dataloader
Data loader stacking dense graphs along a new batch dimension.
Every array attribute must have the same shape in all graphs (e.g. graphs
padded to the same number of nodes with a dense adj matrix). Each
batch is a GraphData whose arrays have shape
[batch_size, ...]. It takes the same arguments as Dataloader,
except collate_fn and follow_batch.
Example:
graphs = [
GraphData(
edge_index=mx.zeros((2, 0), dtype=mx.int32),
node_features=mx.ones((5, 3)),
adj=mx.zeros((5, 5)),
)
for _ in range(8)
]
loader = DenseDataLoader(graphs, batch_size=4)
next(iter(loader)).adj.shape # [4, 5, 5]
Source code in mlx_graphs/loaders/dataloaders.py
from mlx_graphs.loaders import DenseDataLoader · mlx_graphs/loaders/dataloaders.py