GraphIsomorphismLayer<T>

Layers ยท AiDotNet.NeuralNetworks.Layers

Implements Graph Isomorphism Network (GIN) layer for powerful graph representation learning.

Inheritance: LayerBase<T> โ†’ GraphIsomorphismLayer<T>

Implements: IGraphConvolutionLayer<T>, IShapeContract

How It Works

Graph Isomorphism Networks (GIN), introduced by Xu et al., are provably as powerful as the Weisfeiler-Lehman (WL) graph isomorphism test for distinguishing graph structures. GIN uses a sum aggregation with a learnable epsilon parameter and applies a multi-layer perceptron (MLP) to the aggregated features.

The layer computes: h_v^(k) = MLP^(k)((1 + epsilon^(k)) * h_v^(k-1) + sum_{u in N(v)} h_u^(k-1)) where h_v is the representation of node v, N(v) is the neighborhood of v, epsilon is a learnable parameter (or fixed), and MLP is a multi-layer perceptron.

Production-Ready Features:

  • Fully vectorized operations using IEngine for GPU acceleration
  • Tensor-based weights for all parameters
  • Dual backward pass: BackwardManual() for efficiency, BackwardViaAutodiff() for accuracy
  • Full gradient computation through MLP and aggregation paths
  • Complete GetParameters()/SetParameters() for model persistence

Constructors

Constructor Summary
GraphIsomorphismLayer(int inputFeatures, int outputFeatures, int mlpHiddenDim, bool learnEpsilon, double epsilon, IActivationFunction<T> activationFunction, IInitializationStrategy<T> initializationStrategy) Initializes a new instance of the GraphIsomorphismLayer class.

Properties

Property Summary
bool SupportsTraining { get; }
int InputFeatures { get; }
int OutputFeatures { get; }

Methods

Method Summary
Dictionary<string, string> GetParameterRoles() Returns parameter roles for per-role optimizer configuration (e.g., weight decay exemption for biases).
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
IReadOnlyList<Tensor<T>> GetTrainableParameters() Returns all trainable parameter tensors marked with [TrainableParameter].
IReadOnlyList<ValueTuple<string, Tensor<T>>> GetRegisteredBuffers()
Tensor<T> GetAdjacencyMatrix()
void ClearGradients()
void ResetState()
void SetAdjacencyMatrix(Tensor<T> adjacencyMatrix)
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) Replaces trainable parameter tensors (e.g., with ParameterBuffer views).
void UpdateParameters(T learningRate)
void ZeroGrad() Clears all gradient fields discovered by convention ({paramName}Gradient).