Skip to main content

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.
Parameters:
  • in_channels (int): Size of input features
  • out_channels (int): Size of output features
  • aggr (str): Aggregation method (‘add’, ‘mean’, ‘max’)
  • bias (bool): Whether to use bias
  • normalize (bool): Whether to normalize by degree

GraphAttention (GAT)

Graph Attention Layer with multi-head attention mechanism.
Parameters:
  • in_channels (int): Size of input features
  • out_channels (int): Size of output features per head
  • heads (int): Number of attention heads
  • negative_slope (float): LeakyReLU slope
  • dropout (float): Dropout probability

GraphSAGE

GraphSAGE layer for inductive learning on large graphs.
Parameters:
  • in_channels (int): Size of input features
  • out_channels (int): Size of output features
  • aggr (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

  1. Normalization: Use normalize=True in GraphConv for better gradient flow
  2. Dropout: Apply dropout between layers to prevent overfitting
  3. Attention Heads: Use 4-8 heads in GAT for optimal performance
  4. Pooling: Choose appropriate pooling for your task (global for graph-level, hierarchical for interpretability)
  5. Batching: Use GraphDataLoader for 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?”

See Also