SpikingNeuralNetwork<T>

Models & Types · AiDotNet.NeuralNetworks

Represents a Spiking Neural Network, which is a type of neural network that more closely models biological neurons with temporal dynamics.

Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → SequenceModelLayoutBase<T> → SpikingNeuralNetwork<T>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

Spiking Neural Networks (SNNs) work like real biological neurons: they communicate using timed electrical pulses (spikes) rather than continuous values. Each neuron accumulates input over time and only fires when a threshold is reached, then resets. This temporal coding makes SNNs extremely energy-efficient on neuromorphic hardware and naturally suited for processing time-varying signals like sensor data and event cameras.

Example

var architecture = new NeuralNetworkArchitecture<float>(
    InputType.OneDimensional, NeuralNetworkTaskType.MultiClassClassification,
    inputSize: 784, outputSize: 4);
var input = Tensor<float>.CreateRandom(new[] { 1, 784 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new SpikingNeuralNetwork<float>(
        architecture, scalarActivation: new ReLUActivation<float>()))
    .Build(trainX, trainY);
var output = result.Predict(input);

Constructors

Constructor Summary
SpikingNeuralNetwork() Initializes a new instance of the SpikingNeuralNetwork class with the specified architecture and a vector activation function.
SpikingNeuralNetwork(NeuralNetworkArchitecture<T> architecture, IActivationFunction<T> scalarActivation, ILossFunction<T> lossFunction, SpikingNeuralNetworkOptions options) Initializes a new instance of the SpikingNeuralNetwork class with the specified architecture and a scalar activation function.
SpikingNeuralNetwork(NeuralNetworkArchitecture<T> architecture, IVectorActivationFunction<T> vectorActivation, ILossFunction<T> lossFunction, SpikingNeuralNetworkOptions options) Initializes a new instance of the SpikingNeuralNetwork class with the specified architecture and a scalar activation function.

Properties

Property Summary
bool SupportsTraining { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata() Gets metadata about the spiking neural network.
void ResetState() Resets the internal state of the network.
void SetLayerThresholds(int layerIndex, Vector<T> thresholds) Sets custom firing thresholds for neurons in a specific layer.
void SetNeuronModelParameters(T membraneDecay, int refractoryPeriod) Serializes SNN-specific data to a binary writer.
void SetSimulationParameters(double timeStep, int simulationSteps) Sets the simulation parameters for the network.