界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

gnn-models

gnn-models

【效率与协作】Guides Spektral graph neural network layers, pooling, ready-made models, message passing, and explanation workflows.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: gnn-models description: "Guides Spektral graph neural network layers, pooling, ready-made models, message passing, and explanation workflows." disable-model-invocation: true metadata: disco-role: operating license: MIT

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.md for convolution, pooling, base layer, and mode-support summaries.
  • references/api-reference.md for verified model, layer, utility, and explainer signatures.
  • references/workflows.md for GCN, GeneralGNN, custom MessagePassing, batch-mask, and explainer recipes.
  • references/troubleshooting.md for sparse/dense adjacency, mask propagation, Keras compatibility, layer-input, pooling, and explainer failures.
  • scripts/smoke_models.py for a tiny no-download CPU model/layer sanity check.

Core decisions

  1. Decide the data mode with ../graph-data/SKILL.md before selecting layers.
  2. Match layer mode support to loader output:
    • SingleLoader and DisjointLoader usually work with sparse-aware layers.
    • BatchLoader emits dense padded tensors; use only layers that support batch mode.
    • MixedLoader shares one adjacency matrix and needs layers/models that support mixed mode.
  3. Apply required adjacency preprocessing before training. Many layers implement preprocess(a) and can be paired with LayerPreprocess.
  4. Use GraphMasking when BatchLoader(mask=True) appends a mask feature for dense padded batches.
  5. Keep full training/benchmark runs separate from smoke checks; the bundled script only validates wiring.

Start points

TaskStart withNotes
Simple citation-style node predictionGCN or GCNConvGCN outputs node predictions and accepts (x, a) or (x, a, i)
General graph classification/regressionGeneralGNN plus DisjointLoaderDefaults use GeneralConv blocks and global sum pooling
Custom architectureKeras functional/subclassed model plus Spektral layersUse layer catalog to match data mode and edge-feature needs
Custom sparse message passingMessagePassing subclassSingle/disjoint sparse adjacency only
Dense poolingBatchLoader(mask=True), GraphMasking, then dense pooling layerMinCut/DiffPool-style layers expect batch-compatible shapes
ExplanationGNNExplainerNode 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 Graph or Dataset objects, 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.
我的收藏