Overview of GNNGraphs.jl
masterGraphNeuralNetworks.jl and GNNLux.jl.repository·master·Indexed 43 days ago
https://github.com/juliagraphs/graphneuralnetworks.jlA suite of Julia libraries for deep learning on graphs, providing specialized convolutional layers and message-passing frameworks. The ecosystem includes GraphNeuralNetworks.jl for Flux.jl users, GNNLux.jl for Lux.jl users, GNNGraphs.jl for graph data structures (including GNNGraph, GNNHeteroGraph, and TemporalSnapshotsGNNGraph), and GNNlib.jl for framework-agnostic building blocks. It supports batched graph computation, CUDA and AMDGPU, and integration with Graphs.jl and MLDatasets.jl.
GraphNeuralNetworks.jl and GNNLux.jl.GNNlib.jl provides a collection of framework-agnostic building blocks for deep learning on graphs. It includes message passing operators and various implementations of graph convolutional layers.
Because it is framework-agnostic, it serves as a core library that can be used by different deep learning frontends in the Julia ecosystem. If you are looking for a specific deep learning framework integration, consider using:
The project is split into several packages to support different deep learning backends while sharing core logic:
Both frontend packages support:
Graphs.jl.GNNlib.jl provides low-level implementations of basic message passing functions and functional graph convolutional layers.
When to use GNNlib.jl: Use this package if you are a developer looking to create new GNN architectures from scratch. It is designed to work with both Flux.jl and Lux.jl frameworks.
When to use other packages: For most standard users, it is recommended to use the higher-level packages instead:
TemporalSnapshotsGNNGraph type is used to represent graphs that change over time. It is specifically designed to handle graphs where both the topology (edges/nodes) and the features associated with them vary across different time snapshots. This type is part of the GNNGraphs module and is intended for use in temporal Graph Neural Network tasks.TemporalSnapshotsGNNGraph type. These layers allow for performing convolutions on graph structures where edges or node features evolve across discrete time snapshots.In GNNLux.jl, a graph is represented by a GNNGraph object. This object stores all information required for Graph Neural Network operations across three main NamedTuple attributes:
g.ndata: Contains node-related information (e.g., node features x, labels y, or training masks train_mask).g.edata: Holds edge-related information.g.gdata: Stores global data that is neither node-specific nor edge-specific.You can access specific feature arrays using dot notation, such as g.ndata.x.
g = GNNGraph(base_graph, ndata = (; x = node_features, y = labels, train_mask = mask))The GNNGraph type is the primary graph representation in GNNGraphs.jl. It inherits from Graphs.AbstractGraph, meaning you can use the extensive functionality provided by Graphs.jl alongside GNN-specific features. You can use Base.copy to create copies of a GNNGraph instance.
# Example usage of GNNGraph
using GNNGraphs
using Graphs
# Assuming a GNNGraph object 'g' exists
g_copy = copy(g)GNNGraphs.jl provides three specialized graph types designed for different neural network application scenarios:
GNNGraph): The basic graph type where nodes and edges can have associated features. Use this when the graph structure is fixed, but node or edge features may change.GNNHeteroGraph): Supports multiple types of nodes and edges, each with its own properties and relationships. Ideal for multi-relational data like citation graphs.TemporalSnapshotsGNNGraph): Represents graphs that change over time. Use this for tracking time-dependent relationships (e.g., social networks) where edges and features evolve dynamically.The GNNChain type is a concise alternative to Flux.Chain. It allows you to compose layers sequentially while automatically propagating both the input graph and the node features.
Key Behavior:
GNNLayer.Flux.Parallel branches, correctly propagating the graph into those branches.Use GNNChain for standard architectures where node features are transformed through a sequence of graph convolutional layers.
model = GNNChain(GraphConv(din => d),
BatchNorm(d),
x -> relu.(x),
GraphConv(d => d, relu),
Dropout(0.5),
Dense(d, dout))In GNNGraphs.jl, heterogeneous graphs (or heterographs) are graphs where nodes and edges have specific types.
:user, :movie).(source_node_type, relation_type, target_node_type), such as (:user, :rate, :movie).Heterographs allow different node and edge types to store distinct groups of features, making them highly flexible for complex data modeling. They are implemented using the GNNHeteroGraph type.