Loaders¶
- class PooledBatch(*args: Any, **kwargs: Any)[source]¶
Bases:
BatchA custom
Batchclass for handling graph data with pooled-graph data attributes intgp.
This class extends
Batchto support a batch of graphs along with precomputed pooled representations. It stores additional information needed to reconstruct individual graph data objects and manage multiple levels of pooled data.- classmethod from_data_list(data_list: List[BaseData], follow_batch: List[str] | None = None, exclude_keys: List[str] | None = None) PooledBatch[source]¶
Constructs a
PooledBatchfrom a list of graphDataobjects.This method collates node and edge attributes, as well as any sub-
Dataobject storing pooled data, from each graph indata_listinto a singlePooledBatch. It handles attribute increments and batch assignments, and stores metadata required to separate individual graphs later.- Parameters:
data_list (list) – A list of
DataorHeteroDataobjects to batch.follow_batch (Optional[List[str]]) – Keys for which to create additional batch assignment vectors (e.g., node-level attributes to track).
exclude_keys (Optional[List[str]]) – Attributes to exclude from collation.
- Returns:
- A batched object containing all graphs from
data_list, with_slice_dictand_inc_dictattributes set for reconstruction.
- Return type:
- get_example(idx: int) BaseData[source]¶
Retrieves an individual graph data object from the batch.
This method separates the batched data at the specified index
idx, using the stored_slice_dictand_inc_dictto reconstruct the originalBaseDataobject.- Parameters:
idx (int) – Index of the graph to extract from the batch.
- Returns:
- The reconstructed
DataorHeteroDataobject at positionidx.
- Return type:
BaseData
- Raises:
RuntimeError – If the batch was not created via
from_data_list(), making reconstruction impossible.
- class PoolCollater(dataset: Dataset | Sequence[BaseData] | DatasetAdapter, follow_batch: List[str] | None = None, exclude_keys: List[str] | None = None)[source]¶
Bases:
CollaterA custom collate function for pooling dataloaders.
This class extends the PyG collater to produce
PooledBatchobjects when collating a list ofDataorHeteroDataobjects. It invokesfrom_data_list()to perform the batching with optionalfollow_batchandexclude_keysarguments.
- class PoolDataLoader(dataset: Dataset | Sequence[BaseData] | DatasetAdapter, batch_size: int = 1, shuffle: bool = False, follow_batch: List[str] | None = None, exclude_keys: List[str] | None = None, **kwargs)[source]¶
Bases:
DataLoaderA DataLoader for pooled graph datasets, returning
PooledBatchobjects.This class extends
DataLoaderto integrate withPoolCollater, automatically batching pooled graph data. It acceptsfollow_batchandexclude_keysparameters to propagate to the collate function.- Parameters:
dataset (object) – The source dataset from which to load graph data.
batch_size (int) – Number of graphs per batch. (default:
1)shuffle (bool) – Whether to shuffle the data each epoch. (default:
False)follow_batch (list, optional) – Keys for which to create assignment vectors in the batch. (default:
None)exclude_keys (list, optional) – Attributes to exclude from collation. (default:
None)**kwargs – Additional keyword arguments forwarded to torch.utils.data.DataLoader.