SpikingNetworkCore<T>

Layers · AiDotNet.NeuralNetworks.Layers

A surrogate-gradient spiking-neural-network core: a stack of Leaky Integrate-and-Fire (LIF) hidden layers feeding a non-spiking leaky-integrator readout, unrolled over timeSteps and trained end-to-end by backpropagation-through-time with a straight-through surrogate gradient on the spike threshold (Neftci, Mostafa & Zenke, “Surrogate Gradient Learning in Spiking Neural Networks”, IEEE SPM 2019, arXiv:1901.09948).

Inheritance: LayerBase<T> → SpikingNetworkCore<T>

Implements: IShapeContract

How It Works

Dynamics. For each hidden layer l with synaptic weights W_l, membrane potential U_l[t] and output spikes S_l[t]:

The readout is a leaky integrator with no threshold/reset (Neftci §III-C):

The output activation (sigmoid / softmax / identity) is applied by the following layer, not here, so this core emits the raw readout.

Surrogate gradient. The spike Θ(·) is non-differentiable, so we use a straight-through estimator: forward value is the hard Heaviside, but the backward gradient is that of a fast sigmoid σ(slope·z):

Forward: soft + (hard − soft) = hard; backward: ∂S/∂U = slope·σ'. Because every operation here is an Engine op or a sub-layer Forward, TrainWithTape records the full unrolled graph and backpropagates through time automatically — every synaptic weight receives a loss-directed gradient, unlike the unsupervised STDP this replaces.

Constructors

Constructor Summary
SpikingNetworkCore(int inputSize, int hiddenSize, int outputSize) Scalar-hidden-size convenience constructor (single LIF hidden layer).
SpikingNetworkCore(int inputSize, int[] hiddenSizes, int outputSize, int timeSteps, double beta, double threshold, double surrogateSlope) Builds a surrogate-gradient SNN core.

Properties

Property Summary
bool SupportsTraining { get; }
int HiddenLayerCount { get; } Number of LIF hidden layers.
int TimeSteps { get; } Number of unrolled simulation time steps.

Methods

Method Summary
IReadOnlyList<ILayer<T>> GetSubLayers()
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank)
void ResetState()
void UpdateParameters(T learningRate)