Do Not Let Spikes Flip: Margin-Resculpted Learning for Robust Spiking Neural Networks

Desong Zhang, Jia Hu, Geyong MinNeurIPS 2026

TL;DR

Conventional neural networks speak in continuous numbers, while brain-inspired Spiking Neural Networks (SNNs) communicate in binary flashes—either a neuron fires a spike, or it stays silent. Because SNNs only care when an internal voltage crosses a firing threshold, defending them against adversarial attacks shouldn't mean policing every tiny numerical ripple, as traditional defenses do. Instead, this paper makes SNNs dramatically more robust by gently nudging internal voltages away from the "cliff's edge" of the firing threshold, preventing attackers from easily flipping spikes on or off.

What Problem Does This Paper Address?

Spiking Neural Networks (SNNs) are the darlings of low-power edge computing and neuromorphic hardware because they process information via sparse, discrete events rather than dense matrix multiplications. Each neuron acts like a leaky bucket (specifically, a Leaky Integrate-and-Fire model): incoming signals build up an internal "membrane potential," and if it hits a threshold, the neuron emits a binary spike (1) and resets; otherwise, it outputs 0.

Like standard Artificial Neural Networks (ANNs), SNNs are vulnerable to adversarial attacks—imperceptible noise crafted to fool the model. Historically, researchers tried to toughen up SNNs by borrowing ANN defenses that force internal continuous numbers to stay utterly still under attack.

Here is the catch: in an SNN, if a neuron's voltage wiggles from 0.2 to 0.4 (when the threshold is 1.0), downstream layers never even know it happened. The neuron still outputs 0. Enforcing strict numerical stability everywhere wastes optimization effort on harmless fluctuations while ignoring the real danger: neurons sitting at 0.99, right on the razor's edge of misfiring.

Methods

The authors reframe SNN robustness around discrete events rather than continuous values, introducing two diagnostic metrics and a new training regularizer:

  • Spike Flips & Flip Rate: A "spike flip" occurs when an adversarial input causes a neuron at a specific timestep to change its binary decision (0 to 1, or 1 to 0). Averaging this across the network gives the flip rate, a clean, training-agnostic metric for instability.
  • Margin Occupancy (MO): How do we measure how many neurons are loitering dangerously close to the firing threshold? Instead of inventing an arbitrary distance window, the authors cleverly repurpose the surrogate gradient—the smooth mathematical curve already used during backpropagation to approximate the non-differentiable spike step-function. MO uses this curve to score how densely a layer's voltages crowd the threshold.
  • Margin-Resculpted Learning (MRL): You cannot just banish all neurons from the threshold region; if no voltages live near the boundary, surrogate gradients vanish and the network stops learning entirely! MRL solves this by adding a penalty to the training loss only when a layer's Margin Occupancy exceeds an activity-adaptive budget, defined as $[r_\ell(1 - r_\ell)]^2$, where $r_\ell$ is the layer's average firing rate. In addition, gradient-norm matching automatically balances this regularizer against standard cross-entropy loss without manual hyperparameter tuning.

Datasets

The authors evaluate MRL across both standard static image benchmarks and neuromorphic, event-based vision datasets (captured by Dynamic Vision Sensors that natively output asynchronous pixel-change events):

  • Static Images: CIFAR-10, CIFAR-100, and large-scale ImageNet.
  • Event-based (DVS): DVS-CIFAR10 and DVS-Gesture.

No new datasets were introduced; these are standard benchmarks used to test scalability and cross-domain SNN performance.

Key Insights and Ideas

  • Vulnerability lives at the cliff's edge: As attack strength grows, classification error tracks monotonically with the global spike flip rate. Digging deeper, layers with high flip rates show sharp spikes of membrane potentials clustered right on the firing threshold, whereas stable layers have dispersed distributions.
Figure 2: Relationship between flip rate and membrane-potential distributions. 8 representative layers, namely the layers with the highest and lowest flip rates, are selected to be shown, as shown in subplots (b)-(i),where uth is indicated by a red dashed line.
  • Clean-data geometry predicts adversarial failure: Layer-wise Margin Occupancy—measured purely on clean, unattacked inputs—correlates remarkably well with how badly that layer's spikes will flip under attack (Spearman rank correlation $\rho > 0.7$ across all tested settings, and often $\rho > 0.9$).
Figure 3: Relationship between flip rates and MOs. Horizontal axes represent the network layer index, while vertical axes jointly denote flip rates and MOs, as they are on the same scale.
  • The Goldilocks zone of threshold crowding: Ablating the adaptive budget (forcing MO all the way to zero) causes training to completely collapse to random guessing (e.g., 10.28% clean accuracy on CIFAR-10 with a Rectangle surrogate). Neurons need some threshold occupancy to learn, and tying that allowance to Bernoulli firing uncertainty $r_\ell(1 - r_\ell)$ hits the sweet spot between trainability and robustness.

Key Results

MRL consistently outperforms state-of-the-art SNN defenses across architectures (VGG11, ResNet18, NF-ResNets), surrogate gradient shapes, and white-box/black-box attacks (FGSM, PGD, APGD):

  • CIFAR-100 (VGG11): Under white-box PGD attacks, baseline SNNs drop to nearly 0% accuracy. MRL reaches up to 14.25% accuracy, substantially beating recent defenses like DSD (8.09%) and FEEL (2.04%).
  • CIFAR-10 (VGG11): MRL boosts white-box PGD accuracy from 0.03% (vanilla SNN) to 32.89%, while maintaining 92.57% clean accuracy.
  • Scaling to ImageNet: On NF-ResNet50, MRL lifts white-box FGSM accuracy from 7.02% to 22.72% and PGD accuracy from 0.02% to 9.33%.
  • Neuromorphic Data: On DVS-CIFAR10, MRL achieves 69.10% (FGSM) and 63.40% (PGD) accuracy, outperforming prior defenses. Furthermore, rigorous diagnostic checks confirm these gains come from genuine spike stability rather than "gradient obfuscation" (tricking the attacker's optimizer with broken gradients).

Limitations and Future Work

  • The Clean-Robustness Trade-off: Because MRL actively pushes membrane potentials out of the prime operating zone of surrogate gradients, models experience a slight dip in clean accuracy (typically 1%–5% depending on the architecture and dataset). Resolving this fundamental trade-off remains an open challenge for the field.
  • Training Overhead: Computing layer-wise margin occupancy and gradient-norm balancing introduces a modest increase in training cost (though inference remains completely untouched).

Summary updated

Abstract

Spiking Neural Networks (SNNs) transmit information through energy-efficient discrete spike events, unlike the continuous activations used in conventional Artificial Neural Networks (ANNs). Existing SNN robustness methods often inherit ANN-oriented objectives that suppress continuous perturbations or stabilize membrane-potential dynamics. In this paper, we argue that SNN robustness should be analyzed through the stability of spike patterns under perturbations. We formalize perturbation-induced spike flips and introduce the flip rate as a training-agnostic metric for quantifying spike-pattern instability. We further show that spike flips are closely associated with membrane potentials near the firing threshold, and introduce margin occupancy to quantify this threshold-margin vulnerability. Based on these findings, we propose Margin-Resculpted Learning (MRL), which regularizes excessive threshold-margin occupancy with an activity-adaptive bound. MRL reduces vulnerable spike flips while preserving the threshold region needed for surrogate-gradient learning. Experiments across static and event-based datasets, architectures, surrogate functions, and attack settings demonstrate consistent robustness improvements.
BibTeX
@inproceedings{zhang2026do,
  author = {Desong Zhang and Jia Hu and Geyong Min},
  title = {{Do Not Let Spikes Flip: Margin-Resculpted Learning for Robust Spiking Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=R7E5DE5F3A},
}
Figure