Skip to content

WordNet18RR

WordNet18RR(
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
)

Bases: _KnowledgeGraphDataset

The WordNet18RR dataset from the "Convolutional 2D Knowledge Graph Embeddings" paper, containing 40,943 entities, 11 relations and 93,003 fact triplets.

The three splits are merged in a single graph sorted by (head, tail), with edge_type holding the relation of each triplet and the train_mask, val_mask and test_mask edge masks telling the split of each triplet. The relation ids are given by WordNet18RR.edge2id.

This dataset follows the implementation of PyG.

Parameters:

Name Type Description Default
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 the graph once, before it is saved.

None
transform Optional[Callable]

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

None

Example:

from mlx_graphs.datasets import WordNet18RR

dataset = WordNet18RR()
>>> WordNet18RR(num_graphs=1)

dataset[0]
>>> GraphData(
        edge_index(shape=(2, 93003), int32)
        edge_type(shape=(93003,), int32)
        train_mask(shape=(93003,), bool)
        val_mask(shape=(93003,), bool)
        test_mask(shape=(93003,), bool)
        num_nodes=40943)
Source code in mlx_graphs/datasets/knowledge_graph.py
def __init__(
    self,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
):
    super().__init__(
        name="WordNet18RR",
        base_dir=base_dir,
        pre_transform=pre_transform,
        transform=transform,
    )

from mlx_graphs.datasets import WordNet18RR · mlx_graphs/datasets/knowledge_graph.py