liveBook · Manning

PyTorch Geometric Dataset

As explained in Graph Neural Networks in Action

A PyTorch Geometric base class for defining datasets and their raw-data processing, filtering, transformation, and retrieval behavior.

Use a PyTorch Geometric Dataset to turn raw graph files into repeatable data objects that support preprocessing, splitting, batching, and model ingestion. The Dataset and InMemoryDataset classes organize this pipeline, while Data represents each graph. section 8.3.4

Custom social-network dataset

A process() implementation reads an edge list with NetworkX, maps named nodes to integer indices, constructs edge_index, x, y, and masks, wraps them in Data, and collates the result.

Figure 8.15 Steps to preprocess data in PyG. From raw files, there are essentially two paths to prep data for ingestion by a PyG algorithm. The first path, shown here, directly creates an iterator of data instances, which is used by the dataloader. The second path mimics the first but performs this process within the dataloader class.
figure

Use the preprocessing figure to compare direct iteration from raw files with preprocessing performed within a dataloader. section 8.3.4

How Graph Neural Networks in Action covers it

How deep it goes
Explains initialization, file declarations, downloading, graph conversion, masking, collation, and processed-data loading without detailing Dataset internals.
Examples
Demonstrates a NetworkX edge-list conversion into indexed tensors, Data attributes, masks, a custom dataset, and a batched loader.
What it assumes
Assumes Python, PyTorch tensors, NetworkX graph data, and basic PyG Data objects; demonstrates node indexing and masks directly.
What you can do after
Build it from scratch by implementing a custom InMemoryDataset that processes raw graph files into collated Data objects.
How it connects
Connects Dataset with Data, InMemoryDataset, DataLoader, preprocessing, graph indexing, train/test masks, and batching.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.