liveBook · Manning

PyG data module

As explained in Graph Neural Networks in Action

The PyTorch Geometric data module provides classes and operations for creating and manipulating graph data objects.

The PyG data module, imported from torch_geometric.data, creates, inspects, and manipulates graph data objects for GNN workflows. Its objects can combine node, edge, subgraph, and graph-level attributes. section 8.3.4

Loading a NetworkX graph

Convert an existing NetworkX graph with data = utils.from_networkx(social_graph), or construct Data directly after indexing nodes and edges.

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

Trace the two ingestion paths from raw files to iterable data instances: direct preprocessing or preprocessing inside a dataloader. section 8.3.4

How Graph Neural Networks in Action covers it

How deep it goes
Demonstrates tensor construction, Data objects, InMemoryDataset processing, and DataLoader batching without detailing framework internals.
Examples
Uses an edge-list social graph, indexed edge tensors, node features, labels, masks, and a custom InMemoryDataset.
What it assumes
Assumes raw graph data can be standardized into indexed nodes, edges, features, labels, and split masks.
What you can do after
Build and batch PyG graph objects from NetworkX graphs or custom files for downstream GNN processing.
How it connects
Connects graph preprocessing with NetworkX, PyTorch tensors, InMemoryDataset, DataLoader, and train/test masks.

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.