GraphConvolutionalLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a Graph Convolutional Network (GCN) layer for processing graph-structured data.
Inheritance: LayerBase<T> → GraphConvolutionalLayer<T>
Implements: IAuxiliaryLossLayer<T>, IGraphConvolutionLayer<T>, IShapeContract
For Beginners
This layer helps neural networks understand data that’s organized like a network or graph.
Think of a social network where people are connected to friends:
- Each person is a “node” with certain features (age, interests, etc.)
- Connections between people are “edges”
- This layer helps the network learn patterns by looking at each person AND their connections
For example, in a social network recommendation system, this layer can help understand that a person might like something because their friends like it, even if their personal profile doesn’t suggest they would.
How It Works
A Graph Convolutional Layer applies convolution operations to graph-structured data by leveraging an adjacency matrix that defines connections between nodes in the graph. This layer learns representations for nodes in a graph by aggregating feature information from a node’s local neighborhood. The layer performs the transformation: output = adjacency_matrix * input * weights + bias.
Constructors
| Constructor | Summary |
|---|---|
GraphConvolutionalLayer(int inputFeatures, int outputFeatures, IActivationFunction<T> activationFunction, bool implicitIdentityWhenUnset) |
Initializes a new instance of the GraphConvolutionalLayer class with the specified dimensions and activation function. |
GraphConvolutionalLayer(int inputFeatures, int outputFeatures, IActivationFunction<T> activationFunction, bool implicitIdentityWhenUnset, bool useBias, IInitializationStrategy<T> initializationStrategy) |
Initializes a graph convolution with explicit bias and initialization settings. |
GraphConvolutionalLayer(int inputFeatures, int outputFeatures, IVectorActivationFunction<T> vectorActivationFunction) |
Initializes a new instance of the GraphConvolutionalLayer class with the specified dimensions and vector activation function. |
GraphConvolutionalLayer(int inputFeatures, int outputFeatures, IVectorActivationFunction<T> vectorActivationFunction, bool useBias, IInitializationStrategy<T> initializationStrategy) |
Initializes a graph convolution with a vector activation and explicit bias settings. |
Properties
| Property | Summary |
|---|---|
T AuxiliaryLossWeight { get; set; } |
Gets or sets the weight for the auxiliary loss contribution. |
T SmoothnessWeight { get; set; } |
Gets or sets the weight for Laplacian smoothness regularization. |
bool SupportsTraining { get; } |
Gets a value indicating whether this layer supports training. |
bool UseAuxiliaryLoss { get; set; } |
Gets or sets a value indicating whether auxiliary loss is enabled for this layer. |
bool UseBias { get; } |
Gets whether this layer includes a trainable bias vector. |
bool UsesSparseAggregation { get; } |
Gets whether sparse (edge-based) aggregation is currently enabled. |
int InputFeatures { get; set; } |
Gets the number of input features per node. |
int OutputFeatures { get; set; } |
Gets the number of output features per node. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, string> GetAuxiliaryLossDiagnostics() |
Gets diagnostic information about the auxiliary loss computation. |
Dictionary<string, string> GetDiagnostics() |
Gets diagnostic information about this component’s state and behavior. |
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() |
|
T ComputeAuxiliaryLoss() |
Computes the Laplacian smoothness regularization loss on node features. |
Tensor<T> GetAdjacencyMatrix() |
Gets the adjacency matrix currently being used by this layer. |
void ClearEdges() |
Clears the edge list and switches back to dense adjacency matrix aggregation. |
void ClearGradients() |
Clears the stored gradients for this layer. |
void EnableImplicitIdentityAdjacency() |
Sets the adjacency matrix that defines the graph structure. |
void ResetState() |
Resets the internal state of the layer. |
void SetAdjacencyMatrix(Tensor<T> adjacencyMatrix) |
|
void SetEdges(Tensor<int> sourceIndices, Tensor<int> targetIndices) |
Sets the edge list representation of the graph structure for sparse aggregation. |
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void UpdateParameters(T learningRate) |
Updates the parameters of the layer using the calculated gradients. |
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |