EdgeConditionalConvolutionalLayer<T>

Layers · AiDotNet.NeuralNetworks.Layers

Implements Edge-Conditioned Convolution for incorporating edge features in graph convolutions.

Inheritance: LayerBase<T> → EdgeConditionalConvolutionalLayer<T>

Implements: IGraphConvolutionLayer<T>, IShapeContract

For Beginners

This layer lets connections (edges) have their own properties.

Think of a transportation network:

  • Regular graph layers: All roads are treated the same
  • Edge-conditioned layers: Each road has properties (speed limit, distance, traffic)

Examples where edge features matter:

  • Molecules: Bond types (single/double/triple) affect how atoms interact
  • Social networks: Relationship types (friend/colleague/family) influence information flow
  • Knowledge graphs: Relationship types (is-a/part-of/located-in) determine connections
  • Transportation: Road types (highway/street/path) affect travel patterns

This layer learns how to use these edge properties to better aggregate neighbor information.

How It Works

Edge-Conditioned Convolutions extend standard graph convolutions by incorporating edge features into the aggregation process. Instead of treating all edges equally, this layer learns edge-specific transformations based on edge attributes.

The layer computes: h_i’ = σ(Σ_{j∈N(i)} θ(e_ij) · h_j + b) where θ(e_ij) is an edge-specific transformation learned from edge features e_ij.

Constructors

Constructor Summary
EdgeConditionalConvolutionalLayer(int inputFeatures, int outputFeatures, int edgeFeatures, int edgeNetworkHiddenDim, IActivationFunction<T> activationFunction) Initializes a new instance of the EdgeConditionalConvolutionalLayer 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 SetEdgeFeatures(Tensor<T> edgeFeatures) Sets the edge features for this layer.
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).