Skip to content

LRGBDataset

LRGBDataset(
    name: str,
    split: LRGB_SPLITS = "train",
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
)

Bases: Dataset

The Peptides datasets of the "Long Range Graph Benchmark" (LRGB).

Graphs are peptides (molecules made of chains of amino acids) and the tasks require long-range interactions. Node and edge features are the categorical atom and bond features of OGB (9 and 3 integer features per node and edge, to be embedded e.g. with one nn.Embedding per feature).

  • "peptides-func": multi-label graph classification of 10 peptide functions (graph_labels of shape [1, 10], float), evaluated with the average precision.
  • "peptides-struct": graph regression of 11 3D structural properties (graph_labels of shape [1, 11], float), evaluated with the mean absolute error.

This dataset follows the implementation of PyG and reads the same raw files, without requiring PyTorch. The graphs are the same, in the same order, with int32 indices and features. The superpixel datasets "pascalvoc-sp" and "coco-sp" (382 MB and 4.1 GB downloads) and "pcqm-contact" are not available.

Name #graphs #nodes (avg) #edges (avg) #features #tasks
peptides-func 15,535 ~150.9 ~307.3 9 10
peptides-struct 15,535 ~150.9 ~307.3 9 11

The splits have 10,873 (train), 2,331 (val) and 2,331 (test) graphs. The download is ~30 MB (~1.1 GB extracted).

Parameters:

Name Type Description Default
name str

Name of the dataset, "peptides-func" or "peptides-struct" (case insensitive).

required
split LRGB_SPLITS

The split to load, "train", "val" or "test". Default: "train"

'train'
base_dir Optional[str]

Directory where to store dataset files. Default is in the local directory .mlx_graphs_data/.

None
pre_transform Optional[Callable]

A function/transform applied to each graph once, before it is saved.

None
transform Optional[Callable]

A function/transform applied to each graph at every access.

None

Example:

from mlx_graphs.datasets import LRGBDataset

dataset = LRGBDataset("peptides-func", split="train")
>>> peptides-func(num_graphs=10873)

dataset[0]
>>> GraphData(
        edge_index(shape=(2, 682), int32)
        node_features(shape=(338, 9), int32)
        edge_features(shape=(682, 3), int32)
        graph_labels(shape=(1, 10), float32))
Source code in mlx_graphs/datasets/lrgb.py
def __init__(
    self,
    name: str,
    split: LRGB_SPLITS = "train",
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
):
    name = name.lower()
    if name in self.unsupported_names:
        raise ValueError(
            f"LRGB dataset '{name}' is not available in mlx-graphs "
            f"(supported: {self.names})"
        )
    if name not in self.names:
        raise ValueError(f"Unknown LRGB dataset '{name}' (got {self.names})")
    if split not in ("train", "val", "test"):
        raise ValueError(
            f"Split '{split}' found, but expected 'train', 'val' or 'test'"
        )
    self.split = split
    super().__init__(
        name=name,
        base_dir=base_dir,
        pre_transform=pre_transform,
        transform=transform,
    )

from mlx_graphs.datasets import LRGBDataset · mlx_graphs/datasets/lrgb.py