Source code for torch_geometric.transforms.base_transform

from abc import ABC
from typing import Any

[docs]class BaseTransform(ABC): r"""An abstract base class for writing transforms. Transforms are a general way to modify and customize :class:`` or :class:`` objects, either by implicitly passing them as an argument to a :class:``, or by applying them explicitly to individual :class:`` or :class:`` objects: .. code-block:: python import torch_geometric.transforms as T from torch_geometric.datasets import TUDataset transform = T.Compose([T.ToUndirected(), T.AddSelfLoops()]) dataset = TUDataset(path, name='MUTAG', transform=transform) data = dataset[0] # Implicitly transform data on every access. data = TUDataset(path, name='MUTAG')[0] data = transform(data) # Explicitly transform data. """ def __call__(self, data: Any) -> Any: raise NotImplementedError def __repr__(self) -> str: return f'{self.__class__.__name__}()'