Paper Analysis: Training Spiking Neural Networks with Forward Propagation Through Time

Ibrahim Mizi

Exploring Forward Propagation Through Time (FPTT) and Liquid Spiking Neurons for efficient and accurate online training of Spiking Neural Networks.

Paper Analysis: Training Spiking Neural Networks with Forward Propagation Through Time | OpenKit

Foundations and Challenges in Spiking Neural Networks

Spiking Neural Networks (SNNs), inspired by the biological brain, offer the potential for energy-efficient AI due to their event-driven and sparse communication. However, training these networks effectively, especially for tasks involving temporal sequences, presents challenges. Traditionally, SNNs have been trained using backpropagation through time (BPTT). While effective, BPTT suffers from high memory requirements, slow training speeds, and incompatibility with online learning. This post explores the paper “Accurate online training of dynamical spiking neural networks through Forward Propagation Through Time”, which introduces a novel approach to address these limitations.

Understanding Spiking Neural Networks

SNNs represent a fundamental shift in how we approach artificial neural computation. Unlike traditional artificial neural networks that use continuous activation functions, SNNs communicate through discrete spikes, mimicking the behaviour of biological neurons. This event-driven nature offers potential advantages in energy efficiency and temporal information processing.

Key Characteristics of SNNs:

# Basic SNN neuron dynamics
u_t = f(u_(t-1), x_t, s_(t-1)||Φ, τ)  # Membrane potential update
s_t = f_s(u_t, θ) = {            # Spike generation
    1, if u_t ≥ θ
    0, otherwise
}

The BPTT Challenge

BPTT has been the standard training method for recurrent neural networks, including SNNs. However, its implementation for SNNs presents unique challenges.

Mathematical Formulation of BPTT

The gradient computation in BPTT follows:

∂L/∂w = Σ_(t=1)^T ∂l_t/∂w = Σ_(t=1)^T Σ_(i=1)^t ∂l_t/∂h_i * ∂h_i/∂w

Where:

  • L is the total loss
  • l_t is the loss at time t
  • h_i represents hidden states
  • w represents network parameters

Memory Complexity Analysis

BPTT’s memory requirements can be expressed as:

Memory = O(T) * (State_Size + Gradient_Size)

For a sequence length T, this leads to:

  1. Linear memory growth with sequence length.
  2. Storage requirements for all intermediate states.
  3. Accumulation of gradients across time steps.

Limitations of Traditional Training

1. Memory Requirements

  • Storage of complete state history.
  • Gradient accumulation across time steps.
  • Scaling issues with sequence length.

2. Computational Bottlenecks

# BPTT computational complexity
Time_Complexity = O(T) * O(N)  # where N is network size
Memory_Complexity = O(T)       # linear growth with sequence length

3. Online Learning Incompatibility

Traditional BPTT requires:

  • Complete sequences before updates.
  • Batch processing of data.
  • Offline training paradigm.

Existing Solutions and Their Limitations

e-prop Approximation

# e-prop update rule
∂L/∂w ≈ Σ_t e_t * ε_t
# where:
# e_t: eligibility trace
# ε_t: learning signal

Limitations:

  • Reduced accuracy compared to full BPTT.
  • Still requires significant memory.
  • Limited temporal dependency learning.

OSTL (Online Spatio-Temporal Learning)

Attempts to separate:

  • Spatial gradient calculations.
  • Temporal gradient computations.

However:

  • High computational costs.
  • Memory limitations remain.
  • Reduced accuracy compared to BPTT.

The Need for a New Approach

The limitations of BPTT and its approximations highlight the need for a fundamentally different approach to training SNNs. Key requirements include:

  1. Fixed Memory Complexity
# Ideal memory usage
Memory_Usage = O(1)  # constant with sequence length
  1. Online Learning Capability
# Desired update mechanism
for t in sequence:
    loss = compute_loss(current_input)
    update_weights(loss)  # immediate updates
  1. Efficient Computation
  • Reduced dependency chains.
  • Parallel processing capability.
  • Scalable with sequence length.

BPTT, a standard algorithm for training recurrent neural networks (RNNs), involves unfolding the network in time and calculating gradients across all time steps. This process has several drawbacks:

  • Memory Intensive: The memory required by BPTT grows linearly with the length of the input sequence, making training on long sequences computationally expensive and sometimes infeasible.
  • Slow Training: The sequential nature of BPTT requires processing each time step before moving to the next, resulting in slow training, especially for long sequences.
  • Offline Learning: BPTT requires the entire input sequence to be available before calculating updates, making it unsuitable for online learning scenarios where data arrives continuously.

While approximations to online BPTT, such as e-prop and OSTL, exist, they still suffer from memory constraints and generally don’t surpass the performance of offline BPTT. This sets the stage for Forward Propagation Through Time (FPTT), which we’ll explore next. FPTT addresses these fundamental limitations while maintaining or exceeding the performance of traditional approaches.

Biological Inspiration and Future Directions

The challenges in training SNNs reflect a broader question in computational neuroscience: how do biological neural networks learn efficiently with limited resources? Understanding these mechanisms has led to innovations like:

  • Event-driven processing.
  • Sparse communication.
  • Local learning rules.

These principles inform the development of more efficient training methods, which we’ll explore in subsequent sections.

FPTT and Liquid Spiking Neurons: The Technical Innovation

FPTT represents a fundamental shift in training SNNs. It differs fundamentally from BPTT in its approach:

  • Dynamically Regularised Risk: Instead of minimising the total loss across the entire sequence, FPTT minimises an instantaneous risk function. This risk function incorporates a dynamic regularisation term based on past losses.
  • Online Learning: This instantaneous risk calculation allows for parameter updates at each time step, enabling online learning.
  • Fixed Complexity: The complexity of FPTT remains constant regardless of the sequence length, making it memory-efficient and suitable for long sequences.

The Mathematics Behind FPTT

FPTT introduces a novel objective function that combines instantaneous loss with dynamic regularisation:

# FPTT objective function
ℓ_dyn(W) = ℓ_t(W) + α/2||W - W̄_(t - 1/2α∇ℓ_(t-1)(W̄_t))||²

Where:

  • ℓ_t(W) is the current loss.
  • W̄_t is the running average of parameters.
  • α controls the regularisation strength.
  • ∇ℓ_(t-1) represents previous gradient information.

Dynamic Regularisation Mechanism

The regularisation term serves multiple purposes:

  1. Maintains parameter stability.
  2. Incorporates historical information.
  3. Enables online learning.
# Update rules
Φ_(t+1) = Φ_t - η∇_Φℓ(Φ)|_=Φ_t)           # Parameter update
Φ̄_(t+1) = 1/2(Φ̄_t + Φ_(t+1)) - 1/2α∇ℓ_t(Φ_(t+1))  # Running average update

The Liquid Spiking Neuron Architecture

The key contribution of the paper is the introduction of the Liquid Spiking Neuron (LSN). This novel neuron model incorporates dynamic time constants that adapt based on the input and the neuron’s current state. This dynamic behaviour is inspired by the gating mechanisms found in Long Short-Term Memory (LSTM) networks and allows the SNN to selectively retain or forget information over time, crucial for effective FPTT training.

Specifically, the LSN’s time constants are calculated using learned functions of the input and hidden states, enabling the network to adapt its temporal dynamics to the specific task. The LSN introduces dynamic time constants through learned functions:

# LSN dynamics
class LiquidSpikingNeuron:
    def forward(self, x_t, u_prev):
        # Adaptive time constant computation
        τ_m = σ(Dense([x_t, u_prev]))
        
        # Membrane potential update
        du = (-u_prev + x_t)/τ_m
        u_t = u_prev + du
        
        # Spike generation
        spike = u_t >= self.threshold
        
        # Reset mechanism
        u_t = u_t * (1 - spike) + self.u_rest * spike
        
        return spike, u_t

Memory-Efficient Gradient Computation

FPTT’s gradient computation differs fundamentally from BPTT:

# FPTT gradient computation
∂ℓ_dyn(t+1)/∂Φ = ∂ℓ_(t+1)/y_(t+1) *s_(t+1)/u_(t+1) *u_(t+1)/∂Φ

Key advantages:

  1. No temporal dependency chain.
  2. Constant memory complexity.
  3. Immediate parameter updates.

Implementation Details

The complete training algorithm:

def train_fptt(network, data_stream):
    W = initialize_weights()
    W_bar = W.copy()
    
    for t, (x_t, y_t) in enumerate(data_stream):
        # Forward pass
        output = network.forward(x_t)
        loss = compute_loss(output, y_t)
        
        # Compute dynamic loss
        reg_term = compute_regularization(W, W_bar)
        dynamic_loss = loss + reg_term
        
        # Update parameters
        grads = compute_gradients(dynamic_loss)
        W = update_parameters(W, grads)
        
        # Update running average
        W_bar = update_running_average(W_bar, W, grads)

Surrogate Gradient Function

To handle the non-differentiable nature of spikes, FPTT uses a surrogate gradient:

def surrogate_gradient(u, threshold):
    # Multi-Gaussian surrogate
    return sum([
        gaussian(u - threshold, μ_i, σ_i)
        for μ_i, σ_i in gaussian_parameters
    ])

Temporal Processing Mechanisms

The LSN’s temporal processing capabilities are enhanced through:

  1. Adaptive Time Constants:
τ_adp = σ(Dense([x_t, b_(t-1)]))  # Adaptive threshold
τ_m = σ(Dense([x_t, u_(t-1)]))    # Membrane time constant
  1. Dynamic Threshold Adjustment:
θ_t = 0.1 + 1.8 * b_t  # Adaptive threshold
  1. State Updates:
u_t = u_(t-1) + (-u_(t-1) + x_t)/τ_m  # Membrane potential

How FPTT and LSNs Work Together

Combining FPTT with LSNs enables efficient and accurate online training of SNNs. The dynamic time constants of the LSNs provide the flexibility for FPTT to effectively minimise the instantaneous risk. This synergy addresses the limitations of BPTT while maintaining strong performance.

The paper demonstrates the effectiveness of this approach on various temporal classification tasks, showing that FPTT-trained SNNs with LSNs:

  • Outperform online BPTT approximations: Achieve higher accuracy than SNNs trained with e-prop and OSTL.
  • Match or exceed offline BPTT accuracy: Demonstrate comparable or even superior performance to SNNs trained with traditional BPTT.
  • Enable online learning on long sequences: Successfully learn from continuous data streams without memory constraints.

Implementation Results and Real-World Applications of FPTT in SNNs

Comprehensive Performance Analysis

Implementing FPTT with Liquid Spiking Neurons demonstrates remarkable improvements across multiple benchmark datasets. On the DVS Gesture dataset, FPTT-trained networks achieved accuracy rates of 90.64% ± 1.56 for sequences of 500 frames, significantly outperforming traditional BPTT implementations (82.52% ± 1.82). This improvement becomes even more pronounced as sequence lengths increase, demonstrating FPTT’s superior ability to handle long temporal dependencies.

Memory Efficiency Breakthroughs

Memory consumption patterns reveal a stark contrast between FPTT and traditional methods. BPTT’s memory requirements grow linearly with sequence length (requiring up to 15.72GB for the DVS-Gesture dataset), but FPTT maintains a constant memory footprint of approximately 3.75GB regardless of sequence length. This represents a paradigm shift in how SNNs can be deployed in resource-constrained environments.

Temporal Processing Capabilities

Introducing Liquid Time-Constants proves transformative in handling temporal information. Tested on the Sequential MNIST dataset, networks with LTC neurons demonstrated remarkable temporal adaptation capabilities. The dynamic time constants automatically adjust based on input relevance, effectively creating a temporal attention mechanism. This results in more efficient information processing and better performance on tasks requiring precise temporal discrimination.

Scaling to Complex Architectures

The paper demonstrates FPTT’s effectiveness in training deep convolutional SNNs, achieving state-of-the-art results on multiple benchmarks. On the DVS-CIFAR10 dataset, the approach achieved 72.3% accuracy, surpassing previous online learning methods while maintaining significantly lower memory requirements. This breakthrough enables the practical implementation of deep spiking neural architectures previously computationally infeasible.

Real-Time Processing Implications

FPTT’s online learning capability opens new possibilities for real-time applications. In neuromorphic computing systems, where power efficiency and real-time processing are crucial, FPTT’s constant memory complexity and immediate weight updates are a significant advantage. The approach enables continuous learning from streaming data, making it ideal for robotics, autonomous systems, and adaptive control systems.

Computational Efficiency Analysis

Training time comparisons reveal FPTT processes sequences approximately 3-4 times faster than BPTT. For the S-MNIST dataset, FPTT completed training in 737s compared to BPTT’s 2400s. This efficiency gain becomes more pronounced with longer sequences, demonstrating the approach’s scalability.

Conclusion and Future Outlook

FPTT represents a fundamental advancement in training SNNs, addressing core limitations of traditional approaches while opening new possibilities for neural network applications. The combination of reduced memory requirements, improved training efficiency, and superior temporal processing capabilities positions this approach as a cornerstone for future developments in neuromorphic computing and artificial intelligence. The success of this approach suggests promising directions for future research, including developing specialised hardware architectures, exploring hybrid learning algorithms, and investigating more complex temporal processing mechanisms. As our understanding of biological neural systems evolves, the principles underlying FPTT may provide insights into how biological systems achieve efficient temporal learning with limited resources.

Advanced Applications and Future Directions

FPTT’s success in training SNNs opens numerous possibilities for advanced applications. In computer vision, the approach enables real-time processing of event-based camera data with unprecedented efficiency. The temporal processing capabilities make it particularly suitable for applications requiring precise timing, such as speech recognition and motor control.

Theoretical Implications

FPTT’s success challenges traditional assumptions about neural network training. Achieving competitive performance without maintaining full sequence history suggests new perspectives on efficient temporal information processing. This has implications for our understanding of biological learning systems and could influence future neural network architectures.

Limitations and Future Research

While FPTT represents a significant advancement, certain areas warrant further investigation. The relationship between the regularisation parameter α and network performance needs deeper theoretical analysis. Additionally, the interaction between liquid time-constants and different network architectures could be explored further to optimise performance for specific applications.

Industry Impact

FPTT’s practical implications extend beyond academic research. The reduced memory requirements and improved training efficiency make it feasible to deploy sophisticated SNN models in industrial applications. This could revolutionise industrial automation, quality control systems, and smart sensors, where real-time processing and energy efficiency are crucial.


You can read the complete paper “Accurate online training of dynamical spiking neural networks through Forward Propagation Through Time” on arXiv: arXiv:2112.11231. The authors have provided detailed mathematical derivations, experimental setups, and comprehensive results in the supplementary materials.

Join us to get our news in your inbox.