Abstract
In the recent quest for trustworthy neural networks, we present Spiking Neural Networks (SNNs) as a potential candidate for inherent robustness against adversarial attacks. In this work, we demonstrate that the adversarial accuracy of SNNs under gradient-based attacks is higher than their non-spiking counterparts for CIFAR datasets on deep VGG and ResNet architectures, particularly in blackbox attack scenarios. We attribute this robustness to two fundamental characteristics of SNNs and analyze their effects. First, we exhibit that input discretization introduced by the Poisson encoder improves adversarial robustness with a reduced number of timesteps. Second, we quantify the amount of adversarial accuracy with increased leak rate in Leaky-Integrate-Fire (LIF) neurons. Our results suggest that SNNs trained with LIF neurons and a smaller number of timesteps are more robust than those with Integrate-Fire (IF) neurons and larger number of timesteps. Additionally, we overcome the bottleneck of creating gradient-based adversarial inputs in the temporal domain by proposing a technique for crafting attacks directly from SNNs.
Introduction
Deep learning models are notoriously fragile. By adding a tiny, often imperceptible amount of adversarial noise to an image, a researcher can trick a state-of-the-art model into misclassifying a subject—for instance, identifying a cat as a toaster. While various defense mechanisms like adversarial training or input quantization have been proposed, they often come with high computational costs or are eventually bypassed by more sophisticated attacks.
This research investigates whether Spiking Neural Networks (SNNs)—which mimic biological information processing using discrete "spikes" over time—possess an inherent defense mechanism. We explore whether the unique way SNNs encode inputs and their non-linear temporal dynamics make them naturally more resilient to adversarial perturbations than traditional Artificial Neural Networks (ANNs).
Methodology
To evaluate the robustness of SNNs, we compared three distinct network paradigms:
- Standard ANNs: Baseline non-spiking models.
- Converted SNNs (SNN-conv): SNNs created by training a standard ANN and then converting its weights for a spiking architecture.
- Directly Trained SNNs (SNN-BP): SNNs trained from scratch using backpropagation with surrogate gradients. Since the spike function is discontinuous and non-differentiable, surrogate gradients provide a smooth mathematical approximation that allows the network to learn in the temporal domain.
One significant challenge in this field is that standard gradient-based attacks (such as FGSM and PGD) do not translate directly to the temporal, spike-based domain of an SNN. To address this, we developed a novel SNN-crafted attack methodology. This technique generates adversarial inputs by utilizing the same surrogate gradients used during the training phase, allowing for a rigorous test of SNN defenses.
Mechanisms of Robustness
Our analysis identifies two primary drivers of SNN robustness:
1. The Discretization Defense
SNNs typically use a Poisson encoder to transform analog pixel values into binary spike trains. This process acts as a natural stochastic filter. When the number of timesteps is low, the level of discretization is high. This makes it significantly harder for subtle adversarial perturbations to "survive" the conversion into spikes; the noise is often lost in the discretization process before it can influence the network's deeper layers.
2. Non-Linear Temporal Dynamics
Unlike the piecewise-linear ReLU activations common in ANNs, SNNs utilize Leaky-Integrate-Fire (LIF) neurons. These neurons possess a "leak" factor that causes the membrane potential to decay over time. We found that this leak acts as a temporal dampener, diminishing the impact of adversarial perturbations at every layer and preventing the "noise" from propagating effectively through the network. Our findings indicate that LIF neurons are inherently more robust than simple Integrate-Fire (IF) neurons, which lack this decay mechanism.
Experimental Results
We tested these models on standard computer vision benchmarks, including CIFAR-10 (using VGG5 and ResNet20) and CIFAR-100 (using VGG11).
- Blackbox Superiority: In blackbox scenarios—where the attacker has no knowledge of the model's internal parameters—SNN-BP models significantly outperformed ANNs. On CIFAR-10 with a VGG5 architecture, SNN-BP achieved 21.5% accuracy under an FGSM attack, compared to just 18.9% for the ANN.
- PGD Resilience: Under the more rigorous Projected Gradient Descent (PGD) attack, SNN-BP maintained 16.0% accuracy, while the ANN's performance dropped to 9.3%.
- The Timestep Trade-off: We observed that reducing the number of timesteps in SNN-BP from 150 to 50 increased adversarial accuracy by approximately 5%, with only a negligible (1.4%) decrease in clean (non-attacked) accuracy. This confirms that higher discretization (fewer timesteps) enhances robustness.
- Leak Rate Impact: Increasing the leak rate in LIF neurons provided an additional 3–6% boost in adversarial accuracy, highlighting the importance of non-linear temporal decay.
Conclusion
Our research demonstrates that SNNs offer a promising path toward inherently robust AI. The combination of discrete input encoding and non-linear temporal dynamics provides a natural defense against gradient-based adversarial attacks that traditional ANNs lack. While SNNs are not invincible—particularly in whitebox scenarios where an adversary has full model access—their performance in blackbox settings suggests a significant biological advantage. Future work will focus on scaling these findings to deeper architectures and exploring a broader range of adversarial attack vectors.
Summary updated