gnn-models
Guides Spektral graph neural network layers, pooling, ready-made models, message passing, and explanation workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- gnn-models
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides Spektral graph neural network layers, pooling, ready-made models, message passing, and explanation workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md5.9 KB
- 参考文档references/layer-catalog.md4.7 KB
- 参考文档references/troubleshooting.md4.0 KB
- 参考文档references/workflows.md4.3 KB
- 脚本scripts/smoke_models.py3.6 KB
03 SKILL.md 正文
Spektral GNN Models
Use this sub-skill when the task is about building, selecting, debugging, or explaining graph neural network layers and models with Spektral.
Read first
references/layer-catalog.mdfor convolution, pooling, base layer, and mode-support summaries.references/api-reference.mdfor verified model, layer, utility, and explainer signatures.references/workflows.mdfor GCN, GeneralGNN, customMessagePassing, batch-mask, and explainer recipes.references/troubleshooting.mdfor sparse/dense adjacency, mask propagation, Keras compatibility, layer-input, pooling, and explainer failures.scripts/smoke_models.pyfor a tiny no-download CPU model/layer sanity check.
Core decisions
- Decide the data mode with
../graph-data/SKILL.mdbefore selecting layers. - Match layer mode support to loader output:
SingleLoaderandDisjointLoaderusually work with sparse-aware layers.BatchLoaderemits dense padded tensors; use only layers that support batch mode.MixedLoadershares one adjacency matrix and needs layers/models that support mixed mode.
- Apply required adjacency preprocessing before training. Many layers implement
preprocess(a)and can be paired withLayerPreprocess. - Use
GraphMaskingwhenBatchLoader(mask=True)appends a mask feature for dense padded batches. - Keep full training/benchmark runs separate from smoke checks; the bundled script only validates wiring.
Start points
| Task | Start with | Notes |
|---|---|---|
| Simple citation-style node prediction | GCN or GCNConv |
GCN outputs node predictions and accepts (x, a) or (x, a, i) |
| General graph classification/regression | GeneralGNN plus DisjointLoader |
Defaults use GeneralConv blocks and global sum pooling |
| Custom architecture | Keras functional/subclassed model plus Spektral layers | Use layer catalog to match data mode and edge-feature needs |
| Custom sparse message passing | MessagePassing subclass |
Single/disjoint sparse adjacency only |
| Dense pooling | BatchLoader(mask=True), GraphMasking, then dense pooling layer |
MinCut/DiffPool-style layers expect batch-compatible shapes |
| Explanation | GNNExplainer |
Node or graph explanations after a model is trained or otherwise produces predictions |
Minimal validation
Run from the generated skill tree after installing Spektral:
python sub-skills/gnn-models/scripts/smoke_models.py
Expected signal: successful tiny forward passes for GeneralGNN, GCN, GCNConv with batch masking, and a custom MessagePassing subclass, followed by smoke_ok.
Important compatibility note
This Spektral source revision was verified with TensorFlow 2.15.1 and Keras 2.15.0. In a latest TensorFlow/Keras 3 environment, GCN/GCNConv mask handling may fail with an error about converting None to a tensor. If that happens, use the troubleshooting page to pin a TensorFlow/Keras 2.x-compatible stack or rewrite the model call path to avoid the incompatible mask behavior.
Route away when
- The task is about constructing
GraphorDatasetobjects, choosing loaders, or configuring dataset downloads: use../graph-data/SKILL.md. - The task is about generic Keras layer authoring unrelated to graph matrices: use TensorFlow/Keras guidance first.
- The task asks for PyTorch Geometric, DGL, or NetworkX-only algorithms without Spektral layers.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).