GNNBenchmarkDataset
¶
GNNBenchmarkDataset(
name: str,
split: GNN_BENCHMARK_SPLITS = "train",
base_dir: Optional[str] = None,
pre_transform: Optional[Callable] = None,
transform: Optional[Callable] = None,
)
Bases: Dataset
Datasets of the "Benchmarking Graph Neural Networks" paper.
"PATTERN"and"CLUSTER": node classification on graphs sampled from stochastic block models. In PATTERN, the task is to find the nodes of a planted pattern (2 classes); in CLUSTER, to find the cluster of each node, given a single labelled node per cluster (6 classes). Node features are given innode_featuresand labels innode_labels."CSL": graph classification of Circular Skip Link graphs into 10 isomorphism classes. The graphs have no features (onlynum_nodes) and the labels are ingraph_labels. CSL has no standard split: only the"train"split exists and contains all the graphs (5-fold stratified cross-validation is recommended), as in PyG.
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 labels.
"MNIST" and "CIFAR10" are available as
SuperPixelDataset, and "TSP" (a 459 MB
download) is not available.
| Name | #graphs | #nodes (avg) | #edges (avg) | #features | #classes | Download |
|---|---|---|---|---|---|---|
| PATTERN | 14,000 | ~118.9 | ~6,079 | 3 | 2 | 88 MB (1.4 GB extracted) |
| CLUSTER | 12,000 | ~117.2 | ~4,302 | 7 | 6 | 64 MB (1.1 GB extracted) |
| CSL | 150 | 41 | 164 | 0 | 10 | 27 KB |
PATTERN has 10,000 / 2,000 / 2,000 and CLUSTER 10,000 / 1,000 / 1,000 train / val / test graphs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the dataset, |
required |
split
|
GNN_BENCHMARK_SPLITS
|
The split to load, |
'train'
|
base_dir
|
Optional[str]
|
Directory where to store dataset files. Default is
in the local directory |
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 GNNBenchmarkDataset
dataset = GNNBenchmarkDataset("PATTERN", split="train")
>>> PATTERN(num_graphs=10000)
dataset[0]
>>> GraphData(
edge_index(shape=(2, 4884), int32)
node_features(shape=(108, 3), float32)
node_labels(shape=(108,), int32))
Source code in mlx_graphs/datasets/gnn_benchmark.py
from mlx_graphs.datasets import GNNBenchmarkDataset · mlx_graphs/datasets/gnn_benchmark.py