Enhancing the Performance of Transformer-based Spiking Neural Networks
  by SNN-optimized Downsampling with Precise Gradient Backpropagation
Deep spiking neural networks (SNNs) have drawn much attention in recent years
because of their low power consumption, biological rationality and event-driven
property. However, state-of-the-art deep SNNs (including Spikformer and
Spikingformer) suffer from a critical challenge related to the imprecise
gradient backpropagation. This problem arises from the improper design of
downsampling modules in these networks, and greatly hampering the overall model
performance. In this paper, we propose ConvBN-MaxPooling-LIF (CML), an
SNN-optimized downsampling with precise gradient backpropagation. We prove that
CML can effectively overcome the imprecision of gradient backpropagation from a
theoretical perspective. In addition, we evaluate CML on ImageNet, CIFAR10,
CIFAR100, CIFAR10-DVS, DVS128-Gesture datasets, and show state-of-the-art
performance on all these datasets with significantly enhanced performances
compared with Spikingformer. For instance, our model achieves 77.64 $\%$ on
ImageNet, 96.04 $\%$ on CIFAR10, 81.4$\%$ on CIFAR10-DVS, with + 1.79$\%$ on
ImageNet, +1.16$\%$ on CIFAR100 compared with Spikingformer.
Chenlin Zhou, Han Zhang, Zhaokun Zhou, Liutao Yu, Zhengyu Ma, Huihui Zhou, Xiaopeng Fan, Yonghong Tian
Enhancing the Performance of Transformer-based Spiking Neural Networks by SNN-optimized Downsampling with Precise Gradient Backpropagation

###### Abstract

Deep spiking neural networks (SNNs) have drawn much attention in recent years because of their low power consumption, biological rationality and event-driven property. However, state-of-the-art deep SNNs (including Spikformer and Spiking-former) suffer from a critical challenge related to the imprecise gradient backpropagation. This problem arises from the improper design of downsampling modules in these networks, and greatly hampering the overall model performance. In this paper, we propose ConvBN-MaxPooling-LIF (CML), an SNN-optimized downsampling with precise gradient backpropagation. We prove that CML can effectively overcome the imprecision of gradient backpropagation from a theoretical perspective. In addition, we evaluate CML on ImageNet, CIFAR10, CIFAR100, CIFAR10-DVS, DVS128-Gesture datasets. CML shows state-of-the-art performance on all these datasets in directly trained SNN models and significantly enhanced performances of transformer-based SNN models. For instance, our model achieves 77.64 \(\%\) on ImageNet, 96.04 \(\%\) on CIFAR10, 81.4\(\%\) on CIFAR10-DVS, with + 1.79\(\%\) on ImageNet, +1.16\(\%\) on CIFAR100 compared with Spikingformer. Codes will be available at Spikingformer-CML.

## 1 Introduction

Artificial neural networks (ANNs) have demonstrated remarkable success in various artificial intelligence fields, including image classification [1][2][3], object detection[4][5], and semantic segmentation[6]. Unlike ANNs, which rely on continuous high-precision floating-point data to process and transmit information, spiking neural networks (SNNs) use discrete temporal spike sequences. SNNs, as the third-generation neural network inspired by brain science[7], have attracted the attention of many researchers in recent years due to their low power consumption, biological rationality, and event-driven characteristics.

SNNs can be classified into two types: convolution-based SNNs and transformer-based SNNs, borrowing architectures from convolution neural network and vision transformer in ANNs, respectively. Convolution architectures exhibit translation invariance and local dependence, but their receptive fields are typically small and limit their ability to capture global dependencies. In contrast, Vision
transformer is based on self-attention mechanisms that can capture long-distance dependencies and has enhanced the performance of artificial intelligence on many computer vision tasks, including image classification [8; 9], object detection [10; 11] and semantic segmentation [12; 13]. Transformer-based SNNs represent a novel form of SNN that combines transformer architecture with SNN, providing great potential to break through the performance bottleneck of SNNs. So far, transformer-based SNNs mainly contain Spikformer[14] and Spikingformer[15]. Spikformer introduces spike-based self-attention mechanism for the first time through spike self attention (SSA) block and shows powerful performance. However, its energy efficiency is not optimal due to its integer-float multiplications. Spikingformer, a pure event-driven transformer-based SNN, could effectively avoid non-spike computations in Spikformer through spike-driven residual learning [15]. Spikingformer significantly reduces energy consumption compared with Spikformer while even improving network performance. However, both Spikformer and Spikingformer suffer from imprecise gradient backpropagation since they inherit the traditional downsampling modules without adaption for the backpropagation of spikes. The backpropagation imprecision problem greatly limits the performance of spiking transformers.

In this paper, we propose a downsampling module adapted to SNNs, named ConvBN-MaxPooling-LIF (CML), and prove CML can effectively overcome the imprecision of gradient backpropagation from a theoretical perspective. In addition, we evaluate CML on both static image datasets ImageNet, CIFAR10, CIFAR100 and neuromorphic datasets CIFAR10-DVS, DVS128-Gesture. The experimental results show our proposed CML can improve the performance of transformer-based SNNs by a large margin (e.g. + 1.79\(\%\) on ImageNet, +1.16\(\%\) on CIFAR100 compared with Spikingformer), and Spikingformer/Spikformer + CML achieve the state-of-the-art on all above datasets (e.g. 77.64 \(\%\) on ImageNet, 96.04 \(\%\) on CIFAR10, 81.4\(\%\) on CIFAR10-DVS) in directly trained SNN models.

## 2 Related Work

**Convolution-based Spiking Neural Networks.** One fundamental distinction between SNNs and traditional ANNs lies in the transmission mode of information within the networks. ANNs use continuous floating point numbers with high precision, while SNNs with spike neurons transmit information in the form of discrete temporal spike sequences. A spike neuron, the basic unit in SNNs, receives floats or spikes as inputs and accumulates membrane potential across time until it reaches a threshold to generate spikes. Typical spike neurons include Leaky Integrate-and-Fire (LIF) neuron[16], PLIF[17] and KLIF[18] etc. At present, there are two ways to obtain SNNs. One involves converting a pre-trained ANN to SNN[19][20][21], replacing the ReLU activation function in ANN with spike neurons, resulting in comparable performance to ANNs but high latency. Another method is to directly train SNNs[16], using surrogate gradient[22][23] to solve the problem of non-differentiable spikes, which results in low latency but relatively poor performance. Zheng et al. propose a threshold-dependent batch normalization (tdBN) method for direct training deep SNNs[24], which is the first time to explore the directly-trained deep SNNs with high performance on ImageNet. Fang et al. proposed the spike-element-wise block, which overcomes problems such as gradient explosion and gradient vanishing and extended the directly trained SNNs to more than 100 layers [25].

**Transformer-based Spiking Neural Networks.** Vision Transformer (ViT)[8] has become a mainstream visual network model with its superior performance in computer vision tasks. Spikeformer[26] has been proposed to combine the architecture of transformer to SNNs, but this algorithm still belongs to vanilla self-attention due to the existence of numerous floating-point multiplication, division, and exponential operations. Spikformer model [14], incorporating the innovative Spiking self attention (SSA) module that effectively eliminates the complex Softmax operation in self-attention, achieves low computation, energy consumption and high performance. However, both Spikeformer and Spikformer suffer from non-spike computations (integer-float multiplications) in the convolution layer caused by the design of their residual connection. Spikingformer [15] proposes spike-driven residual learning, which could effectively avoid non-spike computations in Spikformer and Spikeformer and significantly reduce energy consumption. Spikingformer is the first pure event-driven transformer-based SNN.

**Downsamplings in SNNs.** Downsampling is a common technique used in both both SNNs and ANNs to reduce the size of feature maps, which in turn reduces the number of network parameters, accelerates the calculation speed and prevents network overfitting. Mainstream downsampling units
include Maxpooling [14; 15], Avgpooling (Average pooling), and convolution with stride greater than 1[25]. Among them, Maxpooling and convolution downsampling are more commonly applied in directly trained SNNs. In this paper, we mainly choose Maxpooling as the key downsampling unit of the proposed CML.

## 3 Method

We examine the limitation of the current downsampling technique in SNNs, which hampers the performance improvement of SNNs. We then overcome this limitation by adapting the downsampling to make it compatible with SNNs.

### Defect of Downsampling in Spikformer and Spkingformer

SNNs typically employ the network module shown in Figure 1(a), which gives rise to the problem of imprecise gradient backpropagation. ConvBN represents the combined operation of convolution and batch normalization. Following ConvBN are the spike neurons, which receive the resultant current and accumulate the membrane potential across time, generate a spike when the membrane potential exceeds the threshold, and finally perform maxpooling for downsampling. The output of ConvBN is the feature map \(x\in R^{m\times n}\), the output of spike neuron is the feature map \(h\in R^{m\times n}\), and the output of maximum pooling is the feature map \(y\in R^{\frac{m}{\times}\frac{n}{\epsilon}}\), where \(m\times n\) is the feature map size, and \(s\) is the pooling stride.

Given the global loss function \(L\) and the backpropagation gradient \(\frac{\partial L}{\partial y_{ij}}\) after downsampling, the gradient at the feature map \(x\) is as follows:

\[\frac{\partial L}{\partial x_{uv}}=\sum_{i=0}^{\frac{m}{\epsilon}}\sum_{j=0} ^{\frac{n}{\epsilon}}\frac{\partial L}{\partial y_{ij}}\frac{\partial y_{ij} }{\partial h_{uv}}\frac{\partial h_{uv}}{\partial x_{uv}} \tag{1}\]

Figure 1: The downsampling module in Spikformer, Spkingformer and our proposed SNN-optimized downsampling. (a) shows the downsampling module in Spikformer and Spkingformer which have imprecise gradient backpropagation issue. (b) shows our proposed SNN-optimized downsampling (ConvBN-MaxPooling-LIF, CML) with precise gradient backpropagation. Note that Multistep LIF is LIF spike neuron with time steps \(T>1\). Same as Spikformer, \(T\) is an independent dimension for spike neuron layer. In other layers, it is merged with the batch size.
The backpropagation gradient of Maxpooling is:

\[\frac{\partial y_{ij}}{\partial h_{uv}}=\left\{\begin{array}{ll}1,&h_{uv}=\max \left(h_{i\times s+t,j\times s+r}\right)\\ 0,&others\end{array}\right. \tag{2}\]

where \(t,r\in[0,s)\). Suppose that the spike neuron used in our work is LIF, and the dynamic model of LIF is described as:

\[H[t] =V[t-1]+\frac{1}{\tau}\left(X[t]-\left(V[t-1]-V_{\text{reset}} \right)\right) \tag{3}\] \[S[t] =\Theta(H[t]-V_{th})\] (4) \[V[t] =H[t](1-S[t])+V_{\text{reset}}S[t] \tag{5}\]

where \(X[t]\) is the input current at time step \(t\), and \(\tau\) is the membrane time constant. \(V_{reset}\) represents the reset potential, \(V_{th}\) represents the spike firing threshold, \(H[t]\) and \(V[t]\) represent the membrane potential before and after spike firing at time step \(t\), respectively. \(\Theta(v)\) is the Heaviside step function, if \(v\geq 0\) then \(\Theta(v)=1\), otherwise \(\Theta(v)=0\). \(S[t]\) represents the output spike at time step \(t\).

The backpropagation gradient of LIF neuron is:

\[\frac{\partial h_{uv}}{\partial x_{uv}}=\frac{\partial S[t]}{\partial X[t]}= \frac{1}{\tau}\times\Theta^{\prime}\left(H[t]-V[t]\right) \tag{6}\]

As a result, the backpropagation gradient on feature map \(x\) is:

\[\frac{\partial L}{\partial x_{uv}}=\begin{cases}\frac{1}{\tau}\frac{\partial L }{\partial y_{ij}}*\Theta^{{}^{\prime}}(H[t]-V[t]),&h_{uv}=\max(h_{i\times s+ t,j\times s+r})\\ 0,&others\end{cases} \tag{7}\]

According to Eq. (7), the gradient exists in the position of the maximal element in feature map h. However, since the output of LIF neuron are spikes, that is, the corresponding position value with spike is 1, otherwise it is 0. Therefore, the element with the first value of 1 in feature map h is chosen as the maximum value, and there is a gradient in this position, which causes imprecise gradient backpropagation. To sum up, after downsampling, when conducting backpropagation in the network structure shown in Figure 1(a), the element with gradient in the feature map \(x\) is not necessarily the element with the most feature information, which is the imprecision problem of gradient backpropagation.

### SNN-optimized Downsampling: CML

Here we improve the network structure of downsampling, as shown in Figure 1(b), which overcomes the imprecision problem of gradient backpropagation. The output of ConvBN is the feature map \(x\in R^{m\times n}\), the output of spike neuron is the feature map \(h\in R^{\frac{m}{2}\times\frac{n}{2}}\), and the output of maximum pooling is the feature map \(y\in R^{\frac{m}{2}\times\frac{n}{2}}\), where \(m\times n\) is the feature map size, and \(s\) is the pooling stride. The backpropagation gradient \(\frac{\partial L}{\partial y_{ij}}\) after LIF neuron is known, then the gradient at the feature map \(x\) is as follows:

\[\frac{\partial L}{\partial x_{uv}}=\sum_{i=0}^{\frac{m}{4}}\sum_{j=0}^{\frac{ n}{2}}\frac{\partial L}{\partial y_{ij}}\frac{\partial y_{ij}}{\partial h_{ij}} \frac{\partial h_{ij}}{\partial x_{uv}} \tag{8}\]

The backpropagation gradient of Maxpooling is:

\[\frac{\partial h_{ij}}{\partial x_{uv}}=\begin{cases}1,&x_{uv}=\max(x_{i\times s +t,j\times s+r})\\ 0,&others\end{cases} \tag{9}\]

where \(t,r\in[0,s)\). The backpropagation gradient of LIF neuron is:

\[\frac{\partial y_{ij}}{\partial h_{ij}}=\frac{\partial S[t]}{\partial X[t]}= \frac{1}{\tau}\times\Theta^{\prime}\left(H[t]-V[t]\right) \tag{10}\]

As a result, the backpropagation gradient on feature map \(x\) is as follows:

\[\frac{\partial L}{\partial x_{uv}}=\begin{cases}\frac{1}{\tau}\frac{\partial L }{\partial y_{ij}}\times\Theta^{{}^{\prime}}(H[t]-V[t])&,x_{uv}=\max(x_{i\times s +t,j\times s+r})\\ 0&,others\end{cases} \tag{11}\]
According to Eq. (11), the maximum element in feature map h corresponds to the maximum element in feature map x, that is, after downsampling, when conducting backpropagation in the network structure shown in Figure 1(b), the element with gradient in feature map x is the element with the most feature information, thus overcoming the imprecision problem of gradient backpropagation. In addition, the computational cost of CML on LIF neurons is only one quarter of that downsampling in Figure 1(a).

### Application and Comparative Analysis of SNN-optimized Downsampling CML

Our proposed SNN-optimized downsampling structure (CML) has universality in spiking neural networks. From theoretical perspectives, the downsampling structure in Figure 1(a) can be easily replaced by our CML structure in Figure 1(b) to overcome the imprecision problem of gradient backpropagation in all kinds of spiking neural networks, which improves the network performance while reduces the computational cost at the same time.

In addition to the CML downsampling we proposed and ConvBN-LIF-MaxPool used in spikformer [14], we summarized another two potential downsampling way: ConvBN-AvgPool-LIF, ConvBN(stride=2)-LIF [25] through investigation and analysis. Therefore, we compared these four downsampling modules by the experiment on CIFAR 10/100, which is shown in Tab. 1. The experimental results show our proposed ConvBN-MaxPool-LIF achieves the best performance among them, outperforming others by a large margin. In Sec.4, we carry out extensive experiments to further verify the effectiveness of our SNN-optimized downsampling module.

## 4 Experiments

In this section, we evaluate the CML downsampling module on static datasets(ImageNet[27], CIFAR10, and CIFAR100[28]) and neuromorphic datasets (CIFAR10-DVS and DVS128 Gesture [29]), using Spikformer and Spikingformer as baselines. Spikformer and Spikingformer are representative transformer-based spiking neural networks. Specifically, we replace SPS with CML in spikformer and replace SPED with CML in spikingformer, while keeping the remaining settings unchanged.

### ImageNet Classification

**ImageNet-1K** contains around \(1.3\) million \(1000\)-class images for training and \(50,000\) images for validation. We conduct experiments on ImageNet-1K to evaluate our CML module, with an input size of \(224\times 224\) by default both during training and inference. The training details of our proposed Spikformer + CML and Spikingformer + CML remain consistent with the original Spikformer and Spikingformer, respectively.

The experimental results shown in Tab. 2 indicate that CML significantly enhances the performance of Spikformer and Spikingformer with various network sizes. Specifically, Spikformer-8-768 + CML achieves 76.55\(\%\) Top-1 classification accuracy, which outperforms Spikformer-8-768 by

\begin{table}
\begin{tabular}{l l c c c} \hline \hline Method & Backbone & Time Step & CIFAR10 & CIFAR100 \\ \hline ConvBN-LIF-MaxPool & Spikingformer-4-384-400E & 4 & 95.81 & 79.21 \\
**ConvBN-MaxPool-LIF** & Spikingformer-4-384-400E & 4 & **95.95** & **80.37** \\ ConvBN-AvgPool-LIF & Spikingformer-4-384-400E & 4 & 95.23 & 78.52 \\ ConvBN(stride=2)-LIF & Spikingformer-4-384-400E & 4 & 94.94 & 78.65 \\ \hline ConvBN-LIF-MaxPool & Spikformer-4-384-400E & 4 & 95.51 & 78.21 \\
**ConvBN-MaxPool-LIF** & Spikformer-4-384-400E & 4 & **96.04** & **80.02** \\ ConvBN-AvgPool-LIF & Spikformer-4-384-400E & 4 & 95.13 & 78.53 \\ ConvBN(stride=2)-LIF & Spikformer-4-384-400E & 4 & 94.93 & 78.02 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Experimental results of our proposed ConvBN-MaxPool-LIF Downsampling in CIFAR10/100, comparing with potential or mainstream downsampling way in SNN. In detail, we keep the retaining network structure of Spikformer and Spikingformer unchanged. Note that ConvBN-LIF-MaxPool, which is used in Spikformer and Spikingformer, is the baseline for comparation.
1.74\(\%\). In addition, Spikingformer-8-768 + CML achieves 77.64\(\%\) Top-1 classification accuracy, which outperforms Spikingformer-8-768 by 1.79\(\%\) and achieves the state-of-the-art performance on ImageNet in directly trained spiking neural network models. These results strongly validate the effectiveness of CML.

### CIFAR Classification

**CIFAR10/CIFAR100** both contain 50,000 train and 10,000 test images with 32 x 32 resolution. CIFAR10 and CIFAR100 contain 10 categories and 100 categories for classification, respectively. We evaluate our CML module on CIFAR10 and CIFAR100. The training details of our proposed Spikformer + CML and Spikingformer + CML are consistent with the original Spikformer and Spikingformer, respectively.

The experimental results are shown in Tab. 3. CML enhances the performance of all Spikformer and Spikingformer models in both CIFAR10 and CIFAR100 by a large margin. For CIFAR10, Spikformer-4-384-400E + CML achieves 96.04\(\%\) Top-1 classification accuracy, which outperforms Spikformer-4-384-400E by 0.53\(\%\) and realizes the state-of-the-art performance of CIFAR10 in directly trained spiking neural network model. Spikingformer-4-384-400E + CML achieves 95.95\(\%\) Top-1 classification accuracy, which outperforms Spikingformer-4-384-400E by 0.14\(\%\). For CIFAR100, Spikformer-4-384-400E + CML achieves 80.02\(\%\) Top-1 classification accuracy, which outperforms Spikingformer-4-384-400E by 1.81\(\%\). Spikingformer-4-384-400E + CML achieves 80.37\(\%\) Top-1 classification accuracy, which outperforms Spikingformer-4-384-400E by 1.16\(\%\) and realizes the state-of-the-art performance of CIFAR100 in directly trained spiking neural network model. The experimental results strongly further verify the effectiveness of our method.

\begin{table}
\begin{tabular}{l l c c c} \hline \hline Methods & Architecture & Param & Time & Top-1 Acc \\  & & (M) & Step & \\ \hline Hybrid training[30] & ResNet-34 & 21.79 & 250 & 61.48 \\ TET[31] & Spiking-ResNet-34 & 21.79 & 6 & 64.79 \\  & SEW-ResNet-34 & 21.79 & 4 & 68.00 \\ Spiking ResNet[32] & ResNet-34 & 21.79 & 350 & 71.61 \\  & ResNet-50 & 25.56 & 350 & 72.75 \\ STBP-tdBN[24] & Spiking-ResNet-34 & 21.79 & 6 & 63.72 \\  & SEW-ResNet-34 & 21.79 & 4 & 67.04 \\ SEW ResNet[25] & SEW-ResNet-50 & 25.56 & 4 & 67.78 \\  & SEW-ResNet-101 & 44.55 & 4 & 68.76 \\  & SEW-ResNet-152 & 60.19 & 4 & 69.26 \\ MS-ResNet[33] & ResNet-104 & 44.55+ & 5 & 74.21 \\ Transformer (ANN)[14] & Transformer-8-512 & 29.68 & 1 & 80.80 \\ \hline Spikformer[14] & Spikformer-8-384 & 16.81 & 4 & 70.24 \\ Spikformer-8-512 & 29.68 & 4 & 73.38 \\  & Spikformer-8-768 & 66.34 & 4 & 74.81 \\ \hline Spikformer-8-384 & 16.81 & 4 & **72.73(+2.49)** \\
**Spikformer + CML** & Spikformer-8-512 & 29.68 & 4 & **75.61(+2.23)** \\  & Spikformer-8-768 & 66.34 & 4 & **77.34(+2.53)** \\ \hline Spikingformer[15] & Spikingformer-8-384 & 16.81 & 4 & 72.45 \\ Spikingformer-8-512 & 29.68 & 4 & 74.79 \\  & Spikingformer-8-768 & 66.34 & 4 & 75.85 \\ \hline
**Spikingformer + CML** & Spikingformer-8-384 & 16.81 & 4 & **74.35(+1.90)** \\  & Spikingformer-8-512 & 29.68 & 4 & **76.54(+1.75)** \\  & Spikingformer-8-768 & 66.34 & 4 & **77.64(+1.79)** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Evaluation on ImageNet. The default input resolution of all the models in inference is 224 \(\times\) 224. CML module enhances the network performance of all models of Spikformer and Spikingformer by a large margin. Note that 77.64 \(\%\) of Spikingformer-8-768 + CML achieves the state-of-the-art performance on ImageNet in directly trained SNN models.
### DVS Classification

**CIFAR10-DVS Classification.** CIFAR10-DVS is a neuromorphic dataset derived from the CIFAR10 dataset, where the visual input is captured by a Dynamic Vision Sensor (DVS) that represents changes in pixel intensity as asynchronous events rather than static frames. It includes 9,000 training samples and 1,000 test samples. We carry out experiments on CIFAR10-DVS to evaluate our CML module. The training details of our proposed Spikformer + CML and Spikingformer + CML are consistent with the original Spikformer and Spikingformer, which all contain 2 spiking transformer blocks with 256 patch embedding dimensions.

We compare our method with SOTA methods on CIFAR10-DVS in Tab.4. Spikingformer + CML achieves 81.4\(\%\) top-1 accuracy with 16 time steps and 80.5\(\%\) accuracy with 10 time steps, outperforming Spikingformer by 0.1\(\%\) and 0.6\(\%\) respectively. Spikformer + CML achieves 80.9\(\%\) top-1 accuracy with 16 time steps and 79.2\(\%\) accuracy with 10 time steps, outperforms Spikformer by 0.3\(\%\) and 0.6\(\%\) respectively. Among them, 81.4\(\%\) of Spikingformer + CML is the state-of-the-art performance of CIFAR10-DVS in directly trained spiking neural network.

**DVS128 Gesture Classification.** DVS128 Gesture is a gesture recognition dataset that contains 11 hand gesture categories from 29 individuals under 3 illumination conditions. The training details of our proposed Spikformer + CML and Spikingformer + CML are consistent with the original

\begin{table}
\begin{tabular}{l c c c c c} \hline \hline Methods & Architecture & Param & Time & CIFAR10 & CIFAR100 \\  & & (M) & Step & Acc & Acc \\ \hline Hybrid training[30] & VGG-11 & 9.27 & 125 & 92.22 & 67.87 \\ Diet-SNN[34] & ResNet-20 & 0.27 & 10/5 & 92.54 & 64.07 \\ STBP[16] & CIFARNet & 17.54 & 12 & 89.83 & - \\ STBP NeuNorm[35] & CIFARNet & 17.54 & 12 & 90.53 & - \\ TSSL-BP[36] & CIFARNet & 17.54 & 5 & 91.41 & - \\ STBP-tdBN[24] & ResNet-19 & 12.63 & 4 & 92.92 & 70.86 \\ TET[31] & ResNet-19 & 12.63 & 4 & 94.44 & 74.47 \\ MS-ResNet[33] & ResNet-110 & - & - & 91.72 & 66.83 \\  & ResNet-482 & - & - & 91.90 & - \\ \hline ANN[14] & ResNet-19* & 12.63 & 1 & 94.97 & 75.35 \\  & Transformer-4-384 & 9.32 & 1 & 96.73 & 81.02 \\ \hline  & Spikformer-4-256 & 4.15 & 4 & 93.94 & 75.96 \\ Spikformer[14] & Spikformer-2-384 & 5.76 & 4 & 94.80 & 76.95 \\  & Spikformer-4-384 & 9.32 & 4 & 95.19 & 77.86 \\  & Spikformer-4-384-400E & 9.32 & 4 & 95.51 & 78.21 \\ \hline  & Spikformer-4-256 & 4.15 & 4 & **94.82(+0.88)** & **77.64(+1.68)** \\  & Spikformer-2-384 & 5.76 & 4 & **95.63(+0.83)** & **78.75(+1.80)** \\
**Spikformer+CML** & Spikformer-4-384 & 9.32 & 4 & **95.93(+0.74)** & **79.65(+1.79)** \\  & Spikformer-4-384-400E & 9.32 & 4 & **96.04(+0.53)** & **80.02(+1.81)** \\ \hline  & Spikingformer-4-256 & 4.15 & 4 & 94.77 & 77.43 \\ Spikingformer[15] & Spikingformer-2-384 & 5.76 & 4 & 95.22 & 78.34 \\  & Spikingformer-4-384 & 9.32 & 4 & 95.61 & 79.09 \\  & Spikingformer-4-384-400E & 9.32 & 4 & 95.81 & 79.21 \\ \hline  & Spikingformer-4-256 & 4.15 & 4 & **94.94(+0.17)** & **78.19(+0.76)** \\
**Spikingformer+CML** & Spikingformer-2-384 & 5.76 & 4 & **95.54(+0.32)** & **78.87(+0.53)** \\  & Spikingformer-4-384 & 9.32 & 4 & **95.81(+0.20)** & **79.98(+0.89)** \\  & Spikingformer-4-384-400E & 9.32 & 4 & **95.95(+0.14)** & **80.37(+1.16)** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Performance comparison of our method on CIFAR10/100. CML module enhances the network performance of all models of Spikformer and Spikingformer in both CIFAR10 and CIFAR100 by a large margin. Note that 96.04 \(\%\) of Spikformer-4-384-400E + CML and 80.37 \(\%\) of Spikingformer-4-384-400E + CML are the state-of-the-art performance of CIFAR10 and CIFAR100 in directly trained spiking neural networks, respectively.
Spikformer and Spikingformer on DVS128 Gesture, which all contain 2 spiking transformer blocks with 256 patch embedding dimensions.

We compare our method with SOTA methods on DVS128 Gesture in Tab.4. Spikingformer + CML achieves 98.6\(\%\) top-1 accuracy with 16 time steps and 97.2\(\%\) accuracy with 10 time steps, outperforms Spikingformer by 0.3\(\%\) and 1.0\(\%\) respectively. Spikformer + CML achieves 98.6\(\%\) top-1 accuracy with 16 time steps and 97.6\(\%\) accuracy with 10 time steps, outperforms Spikformer by 0.7\(\%\) and 1.8\(\%\) respectively. Among them, 98.6\(\%\) of Spikingformer + CML and Spikformer + CML is the state-of-the-art performance of DVS128 Gesture in directly trained spiking neural network.

## 5 Conclusion

In this paper, we investigate the imprecision problem of gradient backpropagation caused by downsampling in Spikformer and Spikingformer. Subsequently, we propose an SNN-optimized downsampling module with precise gradient backpropagation, named ConvBN-MaxPooling-LIF (CML), and prove our proposed CML can effectively overcome the imprecision of gradient backpropagation from theoretical perspectives. In addition, we evaluate CML on the static datasets ImageNet, CIFAR10, CIFAR100 and neuromorphic datasets CIFAR10-DVS, DVS128-Gesture. The experimental results show our proposed CML can improve the performance of SNNs by a large margin (e.g. + 1.79\(\%\) on ImageNet, +1.16\(\%\) on CIFAR100 comparing with Spikingformer), and our models achieve the state-of-the-art on all above datasets (e.g. 77.64 \(\%\) on ImageNet, 96.04 \(\%\) on CIFAR10, 81.4\(\%\) on CIFAR10-DVS) in directly trained SNNs.

## 6 Acknowledgment

This work is supported by grants from National Natural Science Foundation of China 62236009 and 62206141.

\begin{table}
\begin{tabular}{l c c c c} \hline \hline  & \multicolumn{2}{c}{CIFAR10-DVS} & \multicolumn{2}{c}{DVS128} \\ \cline{2-5} Method & Time Step & Acc & Time Step & Acc \\ \hline LIAF-Net [37] & 10 & 70.4 & 60 & 97.6 \\ TA-SNN [38] & 10 & 72.0 & 60 & 98.6 \\ Rollout [39] & 48 & 66.8 & 240 & 97.2 \\ DECOLLE [40] & - & - & 500 & 95.5 \\ tdBN [24] & 10 & 67.8 & 40 & 96.9 \\ PLIF [17] & 20 & 74.8 & 20 & 97.6 \\ SEW-ResNet [25] & 16 & 74.4 & 16 & 97.9 \\ Dspike [41] & 10 & 75.4 & - & - \\ SALT [42] & 20 & 67.1 & - & - \\ DSR [43] & 10 & 77.3 & - & - \\ MS-ResNet [33] & - & 75.6 & - & - \\ \hline Spikformer[14] (Our Implement) & 10 & 78.6 & 10 & 95.8 \\
16 & 80.6 & 16 & 97.9 \\ \hline
**Spikformer + CML** & 10 & **79.2(+0.6)** & 10 & **97.6(+1.8)** \\
16 & **80.9(+0.3)** & 16 & **98.6(+0.7)** \\ \hline Spikingformer[15] & 10 & 79.9 & 10 & 96.2 \\
16 & 81.3 & 16 & 98.3 \\ \hline
**Spikingformer + CML** & 10 & **80.5(+0.6)** & 10 & **97.2(+1.0)** \\
16 & **81.4(+0.1)** & 16 & **98.6(+0.3)** \\ \hline \hline \end{tabular}
\end{table}
Table 4: Results on two neuromorphic datasets, CIFAR10-DVS and DVS128 Gesture. The result of Spikformer is our implementation according to its open source code. Note that 81.4 \(\%\) and 98.6 \(\%\) of Spikingformer + CML achieve the state-of-the-art performance of CIFAR10-DVS and DVS128 Gesture in directly trained spiking neural networks, respectively.