Abstract
Recent Spiking Neural Networks (SNNs) works focus on an image classification task, therefore various coding techniques have been proposed to convert an image into temporal binary spikes. Among them, rate coding and direct coding are regarded as prospective candidates for building a practical SNN system as they show state-of-the-art performance on large-scale datasets. Despite their usage, there is little attention to comparing these two coding schemes in a fair manner. In this paper, we conduct a comprehensive analysis of the two codings from three perspectives: accuracy, adversarial robustness, and energy-efficiency. Our results show that direct coding can achieve better accuracy especially for a small number of timesteps. In contrast, rate coding shows better robustness to adversarial attacks owing to the non-differentiable spike generation process. Rate coding also yields higher energy-efficiency than direct coding which requires multi-bit precision for the first layer. Our study explores the characteristics of two codings, which is an important design consideration for building SNNs.
Introduction
Spiking Neural Networks (SNNs) represent a paradigm shift in neural computing, utilizing discrete binary spikes to process information in a manner inspired by biological brains. While this temporal sparsity offers significant energy advantages on neuromorphic hardware, it introduces a fundamental challenge: how to encode continuous real-world data, such as image pixels, into the spike domain.
Two primary methodologies have emerged as frontrunners: Rate Coding and Direct Coding. Rate coding represents information through the frequency of spikes over time, typically using a Poisson process. Direct coding, conversely, often employs a learnable neural layer to transform input pixels into values that are then treated as spikes or used to drive subsequent spiking layers. Despite their widespread use, a systematic comparison of these methods across performance, security, and efficiency metrics has been lacking.
Input Coding Methodologies
To provide a fair comparison, the researchers evaluated both schemes using the standard Leaky Integrate-and-Fire (LIF) neuron model and trained them using Spatio-Temporal Backpropagation (STBP) with surrogate gradients. This allowed the SNNs to be trained similarly to standard deep learning models despite the non-differentiable nature of spikes.
As shown in the figure above, rate coding (a) maps pixel intensities to spike probabilities via a Poisson generator. High-intensity pixels result in a higher firing rate. Direct coding (b) passes the image through a learnable layer, producing floating-point values that are repeated across timesteps to drive the first layer of spiking neurons.
Experimental Results
Accuracy and Latency
Direct coding demonstrates a clear advantage in scenarios requiring low latency. By utilizing a learnable layer to extract features immediately, it achieves high classification accuracy with significantly fewer timesteps (T) compared to rate coding. Rate coding requires a longer accumulation period to accurately reflect the underlying pixel distribution through spike frequency. On benchmark datasets like CIFAR-100, direct coding consistently outperformed rate coding, particularly at low T values.
Adversarial Robustness
A critical finding of this study is the inherent robustness of rate coding against adversarial attacks. The models were tested against Fast Gradient Sign Method (FGSM) and Projected Gradient Descent (PGD) attacks.
Rate-coded SNNs maintained approximately 20% higher accuracy under adversarial pressure compared to direct-coded versions. This resilience stems from the non-differentiable nature of the Poisson spike generation process, which makes it difficult for gradient-based attackers to compute the precise perturbations needed to deceive the network.
Energy Efficiency
While direct coding is often favored for its accuracy, it carries a "hidden" hardware cost. The first layer in a direct-coded SNN must perform multi-bit (e.g., 16-bit) floating-point multiplications. In contrast, rate coding utilizes binary spikes from the very first layer, allowing hardware to replace expensive multiplications with simple additions. Simulations on the Eyeriss hardware platform indicate that rate coding is roughly 50% more energy-efficient for architectures like VGG5 on CIFAR-10.
Conclusion
The choice between rate and direct coding involves a fundamental trade-off. Direct coding is superior for high-accuracy, low-latency applications. However, for systems where energy efficiency and security against adversarial threats are paramount, rate coding remains the more compelling choice. This study provides a roadmap for designers to select the appropriate encoding scheme based on the specific constraints of their SNN deployment.
Summary updated