Expand description
Graph Neural Network (GNN) with message-passing, edge weighting, and multi-layer propagation.
This module implements a full message-passing GNN where nodes aggregate neighbour features, transform them through stacked linear layers (with bias and activation), and iteratively refine node embeddings.
§Quick example
use ipfrs_tensorlogic::graph_neural_network::{
GraphNeuralNetwork, GnnConfig, GnnLayer, GnnActivation, GnnAggregation,
};
// One hidden layer: 2-dim input -> 4-dim output, ReLU
let layer = GnnLayer {
weights: vec![
vec![0.5, -0.3],
vec![-0.1, 0.8],
vec![ 0.2, 0.4],
vec![-0.6, 0.1],
],
bias: vec![0.0, 0.0, 0.0, 0.0],
activation: GnnActivation::Relu,
};
let config = GnnConfig {
layers: vec![layer],
aggregation: GnnAggregation::Mean,
num_iterations: 2,
};
let mut gnn = GraphNeuralNetwork::new(config);
let a = gnn.add_node(vec![1.0, 0.0]);
let b = gnn.add_node(vec![0.0, 1.0]);
gnn.add_edge(a, b, 1.0).expect("example: should succeed in docs");
let embeddings = gnn.forward();
assert_eq!(embeddings.len(), 2);
assert_eq!(embeddings[0].len(), 4);Structs§
- GnnConfig
- Full configuration for a
GraphNeuralNetwork. - GnnEdge
- Directed edge in the graph with an optional scalar weight.
- GnnLayer
- A single linear + bias + activation layer inside the GNN.
- GnnNode
Id - Newtype wrapper for node indices.
- GnnStats
- Snapshot of graph and model statistics.
- Graph
Neural Network - Message-passing Graph Neural Network.
- Node
Features - Feature vector associated with a single node.
Enums§
- GnnActivation
- Activation function applied element-wise in a
GnnLayer. - GnnAggregation
- Neighbour feature aggregation strategy used during message passing.
- GnnError
- Errors that can arise when working with a
GraphNeuralNetwork.
Functions§
- xorshift64
- Xorshift64 pseudo-random number generator for test vector generation.