Graph Neural Networks
The GNN module provides implementations of various graph neural network architectures for processing graph-structured data, enabling applications like molecular property prediction, social network analysis, and knowledge graph reasoning.Overview
Graph Neural Networks operate on graph-structured data by passing messages between nodes and aggregating information from neighbors. Neurenix provides efficient implementations of popular GNN layers and models.Core Layers
GraphConv (GCN)
Graph Convolutional Layer implementing the spectral graph convolution.in_channels(int): Size of input featuresout_channels(int): Size of output featuresaggr(str): Aggregation method (‘add’, ‘mean’, ‘max’)bias(bool): Whether to use biasnormalize(bool): Whether to normalize by degree
GraphAttention (GAT)
Graph Attention Layer with multi-head attention mechanism.in_channels(int): Size of input featuresout_channels(int): Size of output features per headheads(int): Number of attention headsnegative_slope(float): LeakyReLU slopedropout(float): Dropout probability
GraphSAGE
GraphSAGE layer for inductive learning on large graphs.in_channels(int): Size of input featuresout_channels(int): Size of output featuresaggr(str): Aggregation method (‘mean’, ‘max’, ‘add’)normalize(bool): Whether to L2-normalize output
EdgeConv
Edge Convolutional Layer for learning edge features.GINConv
Graph Isomorphism Network layer for powerful graph representations.Complete Models
GCN Model
GAT Model
Graph Pooling
Pooling operations for graph-level predictions.Global Pooling
Hierarchical Pooling
Data Handling
Graph Data Structure
Graph Dataset
Utilities
Graph Utilities
Example: Node Classification
Example: Graph Classification
Advanced Features
Relational GCN
For knowledge graphs with multiple edge types:Gated Graph Convolution
Best Practices
- Normalization: Use
normalize=Truein GraphConv for better gradient flow - Dropout: Apply dropout between layers to prevent overfitting
- Attention Heads: Use 4-8 heads in GAT for optimal performance
- Pooling: Choose appropriate pooling for your task (global for graph-level, hierarchical for interpretability)
- Batching: Use
GraphDataLoaderfor efficient mini-batch training
References
- GCN: Kipf & Welling (2017) - “Semi-Supervised Classification with Graph Convolutional Networks”
- GAT: Veličković et al. (2018) - “Graph Attention Networks”
- GraphSAGE: Hamilton et al. (2017) - “Inductive Representation Learning on Large Graphs”
- GIN: Xu et al. (2019) - “How Powerful are Graph Neural Networks?”