PyTorch Geometric (PyG) Graph Neural Network Guide
A hands-on PyG skill covering node/link/graph tasks, custom message passing, heterogeneous graphs, and neighbor sampling for large graphs.
Dev & CodingAdvanced★ 33,030⑂ 3,248AI score 9/10Last updated: Aug 9, 2026
What it does
- Nails the PyG fundamentals:
Data/HeteroDataobjects and the critical[2, num_edges]edge_indexCOO layout. - Gives a decision table for conv layers (GCN, GAT/GATv2, SAGE, GIN, TransformerConv, EdgeConv, RGCN, HGT) plus ready training loops for node classification, graph classification, and link prediction.
- Covers scaling with
NeighborLoader,ClusterLoader,GraphSAINTSampler, and DDP guidance. - Shows three routes to heterogeneous GNNs (
to_hetero(),HeteroConv, nativeHGTConv) and custom layers viaMessagePassing. - Includes explainability with
torch_geometric.explainand an 8-item pitfalls checklist.
Who it's for
- ML engineers and researchers building models on graph-structured data.
- Developers working on recommenders, knowledge graphs, or molecular property prediction.
- PyG newcomers who keep tripping over edge formats, batching, or lazy initialization.
Example uses
- "Train a 2-layer GCN on Cora" → Planetoid loading, mask-based training and evaluation loop.
- "Build a user–movie heterogeneous link prediction model" →
HeteroDataconstruction,to_hetero()conversion,LinkNeighborLoader. - "My 2M-node graph won't fit in GPU memory" →
NeighborLoaderwithnum_neighbors=[15, 10]and correct seed-node slicing for the loss.
· · · Install guide · · ·
Try it now, no install
Paste this into Claude to use the skill without installing anything.
Read the instructions in this file and follow them to help me: https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/HEAD/skills/torch-geometric/SKILL.md What I want: (describe your task here)
If Claude can't open the link, open it yourself and paste the contents instead.
↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/torch-geometric folder from the GitHub repo K-Dense-AI/scientific-agent-skills into my ~/.claude/skills/torch-geometric/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git && mkdir -p ~/.claude/skills && cp -r scientific-agent-skills/skills/torch-geometric ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and clone the repository:
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git - Create the skills folder if needed:
mkdir -p ~/.claude/skills - Copy just this skill:
cp -r scientific-agent-skills/skills/torch-geometric ~/.claude/skills/ - Verify the bundled
references/markdown files came along. - Install the libraries in your environment:
pip install torchthenpip install torch_geometric(Python 3.10+, PyTorch 2.6+ recommended). - Restart Claude Code and ask something like "build a PyG graph classification model" to trigger the skill.
View source on GitHub ↗License: MIT