Table of Contents

Class OctonionNeuralNetwork<T>

Namespace
AiDotNet.NeuralNetworks
Assembly
AiDotNet.dll

Represents an Octonion-valued Neural Network for processing data in 8-dimensional hypercomplex space.

public class OctonionNeuralNetwork<T> : NeuralNetworkBase<T>, INeuralNetworkModel<T>, INeuralNetwork<T>, IFullModel<T, Tensor<T>, Tensor<T>>, IModel<Tensor<T>, Tensor<T>, ModelMetadata<T>>, IModelSerializer, ICheckpointableModel, IParameterizable<T, Tensor<T>, Tensor<T>>, IFeatureAware, IFeatureImportance<T>, ICloneable<IFullModel<T, Tensor<T>, Tensor<T>>>, IGradientComputable<T, Tensor<T>, Tensor<T>>, IJitCompilable<T>, IInterpretableModel<T>, IInputGradientComputable<T>, IDisposable

Type Parameters

T

The numeric type used for calculations (typically float or double).

Inheritance
OctonionNeuralNetwork<T>
Implements
IFullModel<T, Tensor<T>, Tensor<T>>
IModel<Tensor<T>, Tensor<T>, ModelMetadata<T>>
IParameterizable<T, Tensor<T>, Tensor<T>>
ICloneable<IFullModel<T, Tensor<T>, Tensor<T>>>
IGradientComputable<T, Tensor<T>, Tensor<T>>
Inherited Members
Extension Methods

Remarks

An Octonion Neural Network uses octonion algebra (8-dimensional non-associative division algebra) for its computations. This provides richer representational capacity than real, complex, or quaternion-valued networks, making it suitable for tasks requiring high-dimensional rotations and transformations.

For Beginners: Octonions are 8-dimensional numbers that extend complex numbers and quaternions. While regular neural networks use simple numbers, octonion networks use these 8-dimensional numbers which can capture more complex relationships in data. This is particularly useful for: - 3D graphics and physics simulations - Signal processing with multiple channels - Tasks requiring rich rotational representations

Constructors

OctonionNeuralNetwork(NeuralNetworkArchitecture<T>, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>>?, ILossFunction<T>?, double)

Initializes a new instance of the OctonionNeuralNetwork class.

public OctonionNeuralNetwork(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>>? optimizer = null, ILossFunction<T>? lossFunction = null, double maxGradNorm = 1)

Parameters

architecture NeuralNetworkArchitecture<T>

The architecture defining the structure of the neural network.

optimizer IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>>

The optimization algorithm to use for training. If null, Adam optimizer is used.

lossFunction ILossFunction<T>

The loss function to use for training. If null, MSE is used.

maxGradNorm double

The maximum gradient norm for gradient clipping during training.

Remarks

Note: Input and output dimensions should be multiples of 8 to properly represent octonions. Each octonion has 8 real components (1 real + 7 imaginary).

Properties

SupportsTraining

Indicates whether this network supports training.

public override bool SupportsTraining { get; }

Property Value

bool

Methods

Backward(Tensor<T>)

Performs a backward pass through the network to calculate gradients.

public Tensor<T> Backward(Tensor<T> outputGradient)

Parameters

outputGradient Tensor<T>

The gradient of the loss with respect to the network's output.

Returns

Tensor<T>

The gradient of the loss with respect to the network's input.

CreateNewInstance()

Creates a new instance of the OctonionNeuralNetwork with the same configuration.

protected override IFullModel<T, Tensor<T>, Tensor<T>> CreateNewInstance()

Returns

IFullModel<T, Tensor<T>, Tensor<T>>

Remarks

This creates a fresh network instance with a new optimizer to avoid state conflicts. Sharing an optimizer instance between networks would cause training issues since the optimizer maintains internal state (momentum, adaptive learning rates, etc.) that is specific to each network's parameters.

DeserializeNetworkSpecificData(BinaryReader)

Deserializes octonion neural network-specific data from a binary reader.

protected override void DeserializeNetworkSpecificData(BinaryReader reader)

Parameters

reader BinaryReader

Forward(Tensor<T>)

Performs a forward pass through the network with the given input tensor.

public Tensor<T> Forward(Tensor<T> input)

Parameters

input Tensor<T>

The input tensor to process.

Returns

Tensor<T>

The output tensor after processing through all layers.

GetModelMetadata()

Retrieves metadata about the octonion neural network model.

public override ModelMetadata<T> GetModelMetadata()

Returns

ModelMetadata<T>

A ModelMetaData object containing information about the network.

InitializeLayers()

Initializes the layers of the octonion neural network based on the provided architecture.

protected override void InitializeLayers()

IsValidInputLayer(ILayer<T>)

Determines if a layer can serve as a valid input layer for this network.

protected override bool IsValidInputLayer(ILayer<T> layer)

Parameters

layer ILayer<T>

Returns

bool

IsValidOutputLayer(ILayer<T>)

Determines if a layer can serve as a valid output layer for this network.

protected override bool IsValidOutputLayer(ILayer<T> layer)

Parameters

layer ILayer<T>

Returns

bool

Predict(Tensor<T>)

Makes a prediction using the octonion neural network for the given input tensor.

public override Tensor<T> Predict(Tensor<T> input)

Parameters

input Tensor<T>

The input tensor to make a prediction for.

Returns

Tensor<T>

The predicted output tensor.

SerializeNetworkSpecificData(BinaryWriter)

Serializes octonion neural network-specific data to a binary writer.

protected override void SerializeNetworkSpecificData(BinaryWriter writer)

Parameters

writer BinaryWriter

Train(Tensor<T>, Tensor<T>)

Trains the octonion neural network using the provided input and expected output.

public override void Train(Tensor<T> input, Tensor<T> expectedOutput)

Parameters

input Tensor<T>

The input tensor for training.

expectedOutput Tensor<T>

The expected output tensor for the given input.

UpdateParameters(Vector<T>)

Updates the parameters of all layers in the network.

public override void UpdateParameters(Vector<T> parameters)

Parameters

parameters Vector<T>

A vector containing all parameters for the network.