gammagl.data.InMemoryDataset

class InMemoryDataset(root: str | None = None, transform: Callable | None = None, pre_transform: Callable | None = None, pre_filter: Callable | None = None, force_reload: bool = False)[source]

Bases: Dataset

Dataset base class for creating graph datasets which easily fit into CPU memory. Inherits from gammagl.data.Dataset. See here for the accompanying tutorial.

Parameters:
  • root (str, optional) – Root directory where the dataset should be saved. (default: None)

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

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

  • pre_filter (callable, optional) – A function that takes in an gammagl.data.Graph object and returns a boolean value, indicating whether the graph object should be included in the final dataset. (default: None)

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

property raw_file_names: str | List[str] | Tuple

The name of the files in the self.raw_dir folder that must be present in order to skip downloading.

property processed_file_names: str | List[str] | Tuple

The name of the files in the self.processed_dir folder that must be present in order to skip processing.

download()[source]

Downloads the dataset to the self.raw_dir folder.

process()[source]

Processes the dataset to the self.processed_dir folder.

property num_classes: int

Returns the number of classes in the dataset.

len() int[source]

Returns the number of graphs stored in the dataset.

get(idx: int) Graph[source]

Gets the data object at index idx.

static collate(data_list: List[Graph])[source]

Collates a Python list of gammagl.data.Graph objects to the internal storage format of InMemoryDataset.

copy(idx: slice | ndarray | Sequence | None = None) InMemoryDataset[source]

Performs a deep-copy of the dataset. If idx is not given, will clone the full dataset. Otherwise, will only clone a subset of the dataset from indices idx. Indices can be slices, lists, tuples, and a Tensor or np.ndarray of type long or bool.