LIF Spiking Networks with Temporal Self-Attention and a Spiking Convolutional Stem for Image Classification
Abstract
We propose a simple and fully reproducible framework that integrates Spiking Neural Networks (SNNs) with self-attention for image classification on MNIST and Fashion-MNIST. Static images are converted into spike trains using Bernoulli/Poisson rate coding over time steps and processed by Leaky Integrate-and-Fire (LIF) dynamics with a numerically stable exact-decay discretization and soft reset. To enable end-to-end optimization with standard backpropagation, we employ a fast-sigmoid surrogate gradient that preserves hard spiking behavior in the forward pass while providing nonzero gradients near the threshold in the backward pass. The resulting membrane-potential sequence is aggregated using multi-head self-attention and mean pooling before classification. We benchmark against minimal Convolutional Neural Network (CNN) and Gated Recurrent Unit (GRU) baselines. The proposed SNN+Attention model trains stably and achieves 96.85% test accuracy on MNIST (5 epochs) and 86.82% on Fashion-MNIST (10 epochs), while remaining below CNN/GRU performance due to its limited spatial inductive bias and stochastic encoding noise. We further incorporate a spiking convolutional stem that improves spatial inductive bias while keeping the attention head unchanged; this raises accuracy to 97.47% on MNIST and 88.10% on Fashion-MNIST under the same benchmark protocol. Relative to the dense SNN+Attention model, the convolutional stem reduces classification error by 19.7% on MNIST and 9.7% on Fashion-MNIST, demonstrating that the principal contribution is a controlled hybridization of spatially local spiking feature extraction with temporal attention aggregation.