torch-geometric

Build graph neural network pipelines with PyTorch Geometric and PyG data structures.

Updated May 24, 2026
One-click install
npx skills add https://github.com/Estrella-231/Mathematical_modeling_tongmeng --skill torch-geometric-estrella-231
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: torch-geometric
Source: https://github.com/Estrella-231/Mathematical_modeling_tongmeng/tree/main/.agents/skills/torch-geometric
Command: npx skills add https://github.com/Estrella-231/Mathematical_modeling_tongmeng --skill torch-geometric-estrella-231

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps you implement Graph Neural Networks (GNNs) efficiently in PyTorch Geometric, so you can learn from graph-structured data instead of treating it like independent rows.

Core Features & Use Cases

  • Graph data modeling: Create Data and HeteroData objects with correct edge_index formatting for node/edge/graph tasks.
  • Modern GNN architectures: Use built-in layers (GCN, GAT, GraphSAGE, GIN, RGCN, HGT) or implement custom MessagePassing layers.
  • Task coverage: Node classification, graph classification, link prediction, heterogeneous graph learning, and explanation workflows.

Quick Start

Ask the AI to generate a PyTorch Geometric training pipeline for node classification on a provided graph using Data and GCNConv, including an end-to-end example with edge_index, loss, and evaluation.

Frequently Asked Questions about torch-geometric

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a graph neural network pipeline for node classification in PyTorch Geometric?

To build a node classification pipeline in PyTorch Geometric, construct a `Data` object with `edge_index` and use layers like `GCNConv` to train on graph-structured data. You implement the forward pass, loss calculation, and evaluation loop to classify nodes.

What is the correct way to format edge_index for graph learning tasks?

The `edge_index` format for graph learning tasks is a tensor of shape [2, num_edges] defining source and target nodes. Correct `edge_index` conventions are required for `Data` and `HeteroData` objects to properly propagate features during message passing.

Can I handle heterogeneous graphs with different node and edge types in PyG?

Yes, you can handle heterogeneous graphs in PyG using the `HeteroData` object. It stores separate feature matrices and edge indices for different node and edge types, allowing architectures like HGT or RGCN to learn heterogeneous graph representations.

How does neighbor sampling work for scalable mini-batch training of Graph Neural Networks?

Neighbor sampling for scalable mini-batch training of Graph Neural Networks samples multi-hop neighborhoods around target nodes to construct manageable subgraphs. This prevents loading the entire graph into memory, enabling efficient training on large-scale graphs.

Does PyTorch Geometric support link prediction and graph classification?

Yes, PyTorch Geometric supports link prediction and graph classification tasks. For link prediction, it decodes node embeddings to predict edges, and for graph classification, it pools node representations to classify entire graph structures.

When should I implement custom MessagePassing layers instead of using built-in GNN architectures?

You should implement custom `MessagePassing` layers when built-in GNN architectures like GCN, GAT, or GraphSAGE cannot express your specific graph convolution logic. This allows defining custom message, aggregation, and update functions.