torch_geometric.datasets.BA2MotifDataset

class BA2MotifDataset(root: str, transform: Optional[Callable] = None, pre_transform: Optional[Callable] = None, force_reload: bool = False)[source]

Bases: InMemoryDataset

The synthetic BA-2motifs graph classification dataset for evaluating explainabilty algorithms, as described in the “Parameterized Explainer for Graph Neural Network” paper. BA2MotifDataset contains 1000 random Barabasi-Albert (BA) graphs. Half of the graphs are attached with a HouseMotif, and the rest are attached with a five-node CycleMotif. The graphs are assigned to one of the two classes according to the type of attached motifs.

This dataset is pre-computed from the official implementation. If you want to create own variations of it, you can make use of the ExplainerDataset:

import torch
from torch_geometric.datasets import ExplainerDataset
from torch_geometric.datasets.graph_generator import BAGraph
from torch_geometric.datasets.motif_generator import HouseMotif
from torch_geometric.datasets.motif_generator import CycleMotif

dataset1 = ExplainerDataset(
    graph_generator=BAGraph(num_nodes=25, num_edges=1),
    motif_generator=HouseMotif(),
    num_motifs=1,
    num_graphs=500,
)

dataset2 = ExplainerDataset(
    graph_generator=BAGraph(num_nodes=25, num_edges=1),
    motif_generator=CycleMotif(5),
    num_motifs=1,
    num_graphs=500,
)

dataset = torch.utils.data.ConcatDataset([dataset1, dataset2])
Parameters:
  • root (str) – Root directory where the dataset should be saved.

  • transform (callable, optional) – A function/transform that takes in an torch_geometric.data.Data object and returns a transformed version. The data object will be transformed before every access. (default: None)

  • pre_transform (callable, optional) – A function/transform that takes in an torch_geometric.data.Data object and returns a transformed version. The data object will be transformed before being saved to disk. (default: None)

  • force_reload (bool, optional) – Whether to re-process the dataset. (default: False)

STATS:

#graphs

#nodes

#edges

#features

#classes

1000

25

~51.0

10

2