Temporal Contrastive Learning for Spiking Neural Networks
Biologically inspired spiking neural networks (SNNs) have garnered
considerable attention due to their low-energy consumption and spatio-temporal
information processing capabilities. Most existing SNNs training methods first
integrate output information across time steps, then adopt the cross-entropy
(CE) loss to supervise the prediction of the average representations. However,
in this work, we find the method above is not ideal for the SNNs training as it
omits the temporal dynamics of SNNs and degrades the performance quickly with
the decrease of inference time steps. One tempting method to model temporal
correlations is to apply the same label supervision at each time step and treat
them identically. Although it can acquire relatively consistent performance
across various time steps, it still faces challenges in obtaining SNNs with
high performance. Inspired by these observations, we propose Temporal-domain
supervised Contrastive Learning (TCL) framework, a novel method to obtain SNNs
with low latency and high performance by incorporating contrastive supervision
with temporal domain information. Contrastive learning (CL) prompts the network
to discern both consistency and variability in the representation space,
enabling it to better learn discriminative and generalizable features. We
extend this concept to the temporal domain of SNNs, allowing us to flexibly and
fully leverage the correlation between representations at different time steps.
Furthermore, we propose a Siamese Temporal-domain supervised Contrastive
Learning (STCL) framework to enhance the SNNs via augmentation, temporal and
class constraints simultaneously. Extensive experimental results demonstrate
that SNNs trained by our TCL and STCL can achieve both high performance and low
latency, achieving state-of-the-art performance on a variety of datasets (e.g.,
CIFAR-10, CIFAR-100, and DVS-CIFAR10).
Haonan Qiu, Zeyin Song, Yanqi Chen, Munan Ning, Wei Fang, Tao Sun, Zhengyu Ma, Li Yuan, Yonghong Tian
# Temporal Contrastive Learning for Spiking Neural Networks

###### Abstract

Biologically inspired spiking neural networks (SNNs) have garnered considerable attention due to their low-energy consumption and spatio-temporal information processing capabilities. Most existing SNNs training methods first integrate output information across time steps, then adopt the cross-entropy (CE) loss to supervise the prediction of the average representations. However, in this work, we find the method above is not ideal for the SNNs training as it omits the temporal dynamics of SNNs and degrades the performance quickly with the decrease of inference time steps. One tempting method to model temporal correlations is to apply the same label supervision at each time step and treat them identically. Although it can acquire relatively consistent performance across various time steps, it still faces challenges in obtaining SNNs with high performance. Inspired by these observations, we propose **T**emporal-domain supervised **C**ontrastive **L**earning (TCL) framework, a novel method to obtain SNNs with low latency and high performance by incorporating contrastive supervision with temporal domain information. Contrastive learning (CL) prompts the network to discern both consistency and variability in the representation space, enabling it to better learn discriminative and generalizable features. We extend this concept to the temporal domain of SNNs, allowing us to flexibly and fully leverage the correlation between representations at different time steps. Furthermore, we propose a **S**iamese **T**emporal-domain supervised **C**ontrastive **L**earning (STCL) framework to enhance the SNNs via augmentation, temporal and class constraints simultaneously. Extensive experimental results demonstrate that SNNs trained by our TCL and STCL can achieve both high performance and low latency, achieving state-of-the-art performance on a variety of datasets (_e.g._, CIFAR-10, CIFAR-100, and DVS-CIFAR10).

## 1 Introduction

Over the past decade, artificial neural networks (ANNs) have achieved remarkable success in various computation vision tasks. However, with the rapid development of ANNs, the computational power they demand has increased significantly. Inspired by the brain's low energy and efficient computing capabilities, researchers have developed spiking neural networks (SNNs) with computational mechanisms inspired by the brain to emulate these properties [1; 2; 3]. The brain-like properties of SNNs such as low energy consumption, event-driven nature, spatio-temporal information processing abilities, and inherent compatibility with neuromorphic hardware have drawn widespread attention.

Although SNNs have demonstrated notable potential, directly training high performance and low latency SNNs by backpropagation remains a challenge [4; 5; 6; 7; 8; 9]. The mainstream approach
involves using labeled information to supervise the average representations integrated over all time steps, defined as \(\mathcal{L}=\mathcal{L}_{ce}(\frac{1}{T}\sum_{t=1}^{T}O^{t},Y)\) (see Fig. 1(a)). However, this method neglects the temporal dynamics of SNNs and only optimizes the average prediction distributions. As shown in Fig. 2, this strategy leads to a significant performance degradation when inference is conducted under ultra-low latency (\(T=1\)), indicating its inadequacy for scenarios with limited computing resources (_i.e._, 76.98% -> 44.19% for SEW [7] and 76.85% -> 48.93% for Spiking-ResNet [10] in Fig. 2).

A straightforward solution to make full use of all temporal information is to optimize each time step respectively, typically by assigning the same label supervision at each time step and treating them identically (_i.e._, TET [11]), defined as \(\mathcal{L}=\frac{1}{T}\sum_{t=1}^{T}\mathcal{L}_{ce}(O^{t},Y)\) (see Fig. 1(b)). Although it acquires relatively steady performance across various time steps (_i.e._, 76.98% -> 68.72% and 77.13% -> 67.07% in Fig. 2), this simplistic temporal supervision only takes temporal identity into account and overlooks coherent correlations. In addition, the self-accumulation intrinsic dynamics of spiking neurons and binary representation forms tend not to results in identical neural activities across time. All these factors limit the representational capability of SNNs and lead to minimal performance gains. The unsatisfactory performance of both the mainstream method and TET implies that the full power of temporal information remains to be harnessed through extra guidance remedy.

To this end, we propose the temporal-domain supervised contrastive learning (TCL) framework to obtain SNNs with high performance and low latency by incorporating contrastive supervision signal with temporal domain information (see the left columns of Fig. 1(c)). Contrastive learning (CL) is designed to learn both generalizable representations and discriminative representations [12, 13, 14]. CL accomplishes this by attracting similar (positive) samples while dispelling different (negative) samples. In unsupervised contrastive learning, the positive samples could be another view of the anchor sample [15, 16, 17], whereas in supervised contrastive learning, the positive samples are the samples sharing the same label with the anchor sample [18]. We extend this concept to the temporal domain of SNNs, constructing positives from features of 1) every single time step and 2) the sample within the same class. The SNNs trained by TCL flexibly and fully leverage the correlation between representations at different time steps, which maintains high performance even under extremely low inference time steps (_i.e._, 77.96% -> 69.65% and 77.83% -> 70.09% in Fig. 2).

Furthermore, we propose a siamese temporal-domain supervised contrastive learning (STCL) framework (see the right columns of Fig. 1(c)), to get more meaningful positive samples and facilitate

Figure 1: An illustration of different methods for directly training SNNs. (a) Baseline framework: This method directly optimizes the aggregated representations under the label supervision. (b) TET framework: This approach optimizes the representations at each time step respectively, using identical label information. (c) Our proposed **T**emporal-domain supervised **C**ontrastive **L**earning (TCL) framework (left) and **S**iamese **T**emporal-domain supervised **C**ontrastive **L**earning (STCL) framework (right): We inject contrastive supervision into temporal domain to model the correlation between representations at different time-steps.
the learning of extra data augmentation invariance. This extension encourages the SNNs to simultaneously learn data augmentation invariance, temporal correlation, and in-class correlation. Consequently, STCL effectively captures the spatio-temporal information of the SNNs, leading to superior and robust performance across different inference time steps (see Fig. 2).

Our experiments demonstrate the effectiveness of the proposed TCL and STCL frameworks, which achieve state-of-the-art performance on eight static and neuromorphic datasets. The main contributions of this work are as follows:

1) We first introduce contrastive learning to the representations in every single time step of SNNs and propose a temporal-domain supervised contrastive learning (TCL) framework to effectively supervise the temporal information of SNNs, enhancing their ability to model temporal correlation, overcoming the challenge of significant performance degradation during inference under ultra-low latency.

2) We further extend a siamese temporal-domain supervised contrastive learning (STCL) framework, which enhances the SNNs by learning invariance to data augmentation, the temporal and in-class correlation simultaneously. This significantly improves the performance of SNNs at low latency.

3) Extensive experiments on eight classification datasets, including CIFAR-10 [19], CIFAR-100, DVS-CIFAR10 [20], CUB-200-2011 [21], Stanford-Cars [22], FGVC-Aircraft [23], Oxford Flowers [24], and Stanford Dogs [25], demonstrate our proposed TCL and STCL outperform other approaches by a large margin and achieves the state-of-the-art (SOTA) performance.

## 2 Related Work

### Learning Methods of Spiking Neural Networks.

The two primary training paradigms for SNNs are ANN-to-SNN conversion [26; 27; 28; 29; 30] and Directly-train-SNN [4; 7; 31; 32; 33]. The conversion method transforms the pre-trained ANNs into the SNNs by replacing the ANN's activation function with spiking neurons and sharing weights. However, numerous time steps are required to match the spike firing frequency with the ANNs' activation values. Significant discrepancies can arise when the time step becomes exceedingly small, resulting in significant performance decline. Alternatively, the Directly-train-SNN strategy uses gradient backpropagation to train SNNs, creating a balance between performance and latency. This method supervises the temporal and spatial information of SNNs with backpropagation through time (BPTT) [4; 11; 34], enabling the creation of low latency SNNs. Nonetheless, when compared with ANNs, there is still substantial potential for performance enhancement. This motivates us to propose more efficient methods for training low latency and high performance SNNs.

### Contrastive Learning.

Contrastive learning has emerged as a compelling unsupervised paradigm, demonstrating its sophistication in representation learning [16; 35; 14; 36; 37; 38]. It designates positive and negative sample pairs in advance, narrows the distance between the representations of positive sample pairs using a contrastive loss function, and expands the distance between the representations of positive and

Figure 2: Performance of SNNs at various time steps during the inference phase, with pre-training at time steps \(T=8\) under CIFAR-100 dataset.
negative sample pairs. Recently, researchers have incorporated label information into contrastive learning. This enhancement refines the definition of positive and negative samples, allowing contrastive learning to function within a supervised paradigm [18; 17], which further strengthens the model's capacity for representation. This study introduces this robust learning approach to effectively model the temporal correlations of SNNs, thereby elevating the representational capability of SNNs.

## 3 Preliminary

### Neuron Model

In this work, we utilize Leaky Integrate-and-Fire (LIF) neuron as the foundational computational unit of the SNNs. The dynamic behavior of the neuron is described by the following equations:

\[u^{t+1,pre}=\alpha*u^{t}+x^{t+1}, \tag{1}\]

\[y^{t+1}=\Theta(u^{t+1,pre}-V_{th}), \tag{2}\]

\[u^{t+1}=U^{t+1,pre}*(1-y^{t+1}), \tag{3}\]

where \(\alpha\) represents the delay factor (typically set to \(0.5\) in our study), \(u^{t+1,pre}\) signifies the membrane potential prior to the neuron's spike firing mechanism at time step \(t+1\), and \(u^{t}\) denotes the final membrane potential of the neuron at time step \(t\). \(x^{t+1}\) represents the input at time step \(t+1\), while \(\Theta\) denotes the step function, determining whether the neuron fires a spike based on whether the preliminary membrane potential surpasses the firing threshold \(V_{th}\). If a spike is fired, the output \(y^{t+1}\) is 1, otherwise, it is 0. Eq. 3 illustrates the reset mechanism. Following a spike, the neuron's membrane potential is reset. In our model, we employ a 'hard reset' approach [39], resetting the membrane potential to a predetermined value, typically zero. This approach typically results in superior performance in the context of LIF neurons, compared to the'soft reset' approach where a predetermined value (typically the firing threshold \(V_{th}\)) is subtracted from the membrane potential.

## 4 Method

In this section, we start by revisiting the loss function typically employed in the direct training of SNNs. Subsequently, we introduce our Temporal Contrastive Learning (TCL) framework, a novel approach aimed at effectively supervising the temporal information inherent in SNNs, thereby facilitating the network in modeling temporal correlation. Furthermore, we present our Siamese Temporal Contrastive Learning (STCL) framework, a siamese network paradigm to enhance SNNs to concurrently learn augmentation invariance, temporal and in-class correlation. We conclude this section by providing additional insights and strategies associated with our proposed frameworks.

### Direct Training of SNNs

Direct training of SNNs predominantly uses the standard cross-entropy (CE) loss. A typical baseline method is first integrate output information across time steps, then adopt CE to supervise the prediction of the average representation (see Fig. 1(a)):

\[\mathcal{L}_{BL}=\mathcal{L}_{CE}\left(\frac{1}{T}\sum_{t=1}^{T}O^{t},Y\right), \tag{4}\]

where \(O^{t}\) denotes the predicted probability output of the SNNs at time step \(t\), \(Y\) represents the target label, and \(T\) is the total number of time steps. However, Eq. 4 neglects the temporal dynamics of SNNs and only optimizes the temporal average prediction distributions. We demonstrate that SNNs trained by Eq. 4 fails to maintain performance as time step decreasing during inference (see Fig. 2).

Conversely, TET [11] makes full use of all temporal information by assigning the same label supervision at each time steps and optimizing them respectively (see Fig. 1(b)):

\[\mathcal{L}_{TET}=\frac{1}{T}\sum_{t=1}^{T}\mathcal{L}_{CE}(O^{t},Y). \tag{5}\]
Although Eq. 5 acquires relatively steady performance across various time steps (see Fig. 2), it indeed only takes temporal identity into account and overlooks coherent correlation, which leads to minimal performance gains and is also far from our objective, _i.e._, obtaining SNNs with both low latency and high performance.

### Temporal Contrastive Learning

Contrastive learning is a powerful and flexible approach to representation learning. It learns to be discriminative and generalizable by maximizing the similarity of representations between positive samples and minimizing the similarity between positive and negative samples. By carefully defining positive and negative samples, and shaping the form of the contrastive loss function, we can equip the network with various capabilities. The common form of contrastive loss, such as SimCLR [16], can be expressed as follows:

\[\mathcal{L}_{CL}=-\sum_{i\in I}\log\frac{\exp(z_{i}\cdot z_{i}^{+}/\tau)}{\sum _{k\neq i}\exp(z_{i}\cdot z_{k}/\tau)}, \tag{6}\]

where \(I\) indexes all samples in a batch. The terms \(z_{i}\), \(z_{i}^{+}\), and \(z_{k}\) all denote L2-normalized features that have been passed through a projection module. Similarly, all subsequent references to \(z\) denote such features. Specifically, \(z_{i}\) and \(z_{i}^{+}\) represent the positive sample pairs, while \(z_{k}\) represents the features of all other samples in the mini-batch that are not the \(i\)-th sample. \(\tau\) is a temperature parameter that controls the concentration of the distribution.

In our work, we incorporate contrastive supervision with temporal domain information and extend it to effectively capture the temporal correlations inherent in temporal information. We achieve this by redefining positive samples as representations of the same image at different time steps (see the left column of Fig. 1(c)). This can be formalized as:

\[\mathcal{L}_{CL}=-\frac{1}{T}\sum_{i\in I}\sum_{t=1}^{T}\sum_{ \begin{subarray}{c}t=1\\ t^{\prime}\neq t\end{subarray}}\log\frac{\exp(z_{i}^{t}\cdot z_{i}^{t^{\prime }}/\tau)}{\sum_{(k,t^{\prime\prime})\neq(i,t)}\exp(z_{i}^{t}\cdot z_{k}^{t^{ \prime\prime}}/\tau)}, \tag{7}\]

where \(z_{i}^{t}\) denotes the representation of image \(i\) at time step \(t\), \(T\) is the total number of time steps, and \(t^{\prime}\) denotes all other time steps for the same image \(i\). The overall loss can be formulated as follow:

\[\mathcal{L}_{TCL}=\mathcal{L}_{BL}+\lambda\mathcal{L}_{CL}, \tag{8}\]

where the hyperparameter \(\lambda\) balances the cross-entropy loss and the temporal contrastive loss.

### Siamese Network Paradigm

In our previous discussions, we construct positive samples from features of every single time step. However, it has been established in prior research that the network can learn invariance to various forms of data augmentation, such as Color Jitter and Random Gray Scale [40; 16; 41], thereby gaining a more generalized representational capacity. With this in mind, as shown in the right column of Fig. 1(c), we adopt the siamese network paradigm [16; 42] and simultaneously introduce data augmentation to further enhance the representational capacity of SNNs. We now define positive sample pairs to include different augmented versions of the same sample at various time steps. This updated approach guides the network to simultaneously capture temporal correlations across different time steps and maintain invariance to various data augmentations. This enhancement boosts its ability to seize and represent intricate temporal dynamics and transformations. The overall loss of the STCL framework can be formulated as follows:

\[\mathcal{L}_{STCL}=\mathcal{L}_{BLaug1}+\mathcal{L}_{BLaug2}+ \lambda\mathcal{L}_{CL}, \tag{9}\]

where \(\mathcal{L}_{BLaug1}\) and \(\mathcal{L}_{BLaug2}\) represent the cross-entropy losses corresponding to the two different augmented versions of the same sample.
### Extra Details and Strategies

**Supervised Contrastive Loss.** In our supervised paradigm, we incorporate label information into the contrastive loss function, modifying it to include the similarity between samples of the same class, while still minimizing the similarity between positive and negative samples. Following the approach in [18], the updated loss function can be formulated as:

\[\mathcal{L}_{\;\;CL}^{\;\;sup}=-\frac{1}{T}\sum_{i\in I}\frac{1}{|P(i)|}\sum_{t =1}^{T}\sum_{t^{\prime}=1}^{T}\sum_{p\in P(i)}\not\vdash i\neq p\text{ or }t\neq t^{\prime}\log\frac{\exp(z_{i}^{t}\cdot z_{p}^{t^{\prime}}/\tau)}{ \sum_{(k,t^{\prime\prime})\neq(i,t)}\exp(z_{i}^{t}\cdot z_{k}^{t^{\prime\prime }}/\tau)}, \tag{10}\]

where \(P(i)\) denotes the set of positive sample pairs with the same label as sample \(i\), and \(|P(i)|\) represents the cardinality of the set \(P(i)\). In this formulation, we extend the original contrastive loss function to include the similarity between samples of the same class at different time steps, while still minimizing the similarity between positive and negative samples. This adaptation allows the network to learn representations that more effectively capture the underlying structure of the temporal data, thereby leading to improved performance in classification tasks.

**Projection Module.** In our framework, before calculating the temporal contrastive loss on the temporal features of SNNs, we introduce a projection module, which comprises two non-linear layers. This module maps the features of the SNNs into a normalized embedding space. This pivotal component significantly enhances the model's performance, corroborating findings in contrastive learning [16] and knowledge distillation [43]. Throughout the training process, we incorporate the projection module, but it is omitted during inference, thereby adding no additional parameters.

**Deep Contrastive Supervision.** Additionally, inspired by the work presented in [17], beyond supervising the temporal information in the last layer of the SNNs, we also apply contrastive loss calculations to the intermediate layers of the SNNs by default. This strategy provides effective supervisory signals in the intermediate layers for training the SNNs.

## 5 Experiments

In this section, we present a variety of experiments to validate the effectiveness of our proposed method. The experiments are designed to cover multiple datasets, including three static and neuromorphic datasets (_e.g._, CIFAR-10, CIFAR-100, and DVS-CIFAR10) and five fine-grained datasets (_e.g._, CUB-200-2011(CUB), Stanford-Cars(Car), FGVC-Aircraft(Aircraft), Oxford Flowers(Flowers), and Stanford Dogs(Dogs)), and leverage widely used base models, Spiking-ResNet [44], SEW-ResNet[7] and Spiking-VGG [11]. We first describe the dataset preprocessing methods and implementation details to provide a clear understanding of the experimental setup. We then delve into the application of our proposed method on mainstream static and neuromorphic image classification tasks to demonstrate its performance in the SNNs standard tasks scenario. Following this, we explore the fine-grained image classification capabilities of our proposed method. Further, we compare our method with the other SOTA training methods. Finally, we conduct a series of ablation studies to gain deeper insights into the contributions of various components of our proposed method.

### Dataset Preprocessing and Implementation Details

In line with previous setups, we directly feed the original images into the SNN for \(T\) times on static and fine-grained datasets, while on DVS datasets, we directly input the original spike data. By default, we set the time step \(T\) for SNN training and inference to 4.

**Data Augmentation**. Regarding the static and fine-grained datasets, we employ standard data augmentation techniques for the input images, including random cropping, flipping, and normalization in the TCL framework. To enhance our STCL framework, we introduce more complex data augmentation techniques such as Cutout [45]_(only for CIFAR-10/100)_, Color Jitter, and Random Gray Scale. For neuromorphic datasets DVS-CIFAR10, we reduce the resolution of the input image from 128 \(\times\) 128 to 48 \(\times\) 48 and apply random cropping as the augmentation strategy in our frameworks.

**Training**. We train our models for 200 epochs using SGD optimizer with a learning rate of 0.1, a weight decay of 0.0005, and the momentum of 0.9, using a batch size of 64 or 128, on all datasets.
### Mainstream Static and Neuromorphic Image Classification

In this subsection, we evaluate the effectiveness of our proposed method, including both the TCL and STCL frameworks, on mainstream static image classification tasks (CIFAR-100 and CIFAR-10) and a neuromorphic dataset (DVS-CIFAR10). The results are shown in Tab. 1, where we compare the performance of our method using SEW-ResNet18 (SEW-18) and SEW-ResNet34 (SEW-34) architectures against the baseline performance. The results indicate that our proposed TCL and STCL methods consistently improve classification accuracy across all datasets and architectures. Specifically, for the CIFAR-100 dataset, the STCL achieves the highest accuracy of 79.51% and 80.30% for SEW-18 and SEW-34, respectively, marking an improvement of 3.44% and 3.16% over the baseline. Moreover, on the CIFAR-10 dataset, the STCL significant outperforms the baseline by achieving 95.97% and 96.39% accuracy for SEW-18 and SEW-34, respectively. Looking at the DVS-CIFAR10 dataset, the TCL lifts the classification accuracy from 75.60% to 77.20% for SEW-18. For the SEW-34, the TCL increases the accuracy from 74.70% to 76.60%, and the STCL achieves an even higher accuracy of 78.30%.

Absolutely, the STCL without the contrastive loss (\(\mathcal{L}_{\text{CL}}\) in Eq. 10), denoted as STCL w/o \(\mathcal{L}_{\text{CL}}\), achieves 78.60% and 79.63% accuracy for SEW-18 and SEW-34 on CIFAR-100, and 95.44% and 96.07% on CIFAR-10, respectively. This implies that, even in the absence of the contrastive loss, the network can benefit from learning to be invariant to data augmentations such as Random Gray Scale. However, by employing the contrastive loss, our full STCL can bring about further improvements by learning both augmentation invariance and temporal correlation. These results demonstrate that our framework, through effectively learning augmentation invariance and temporal correlation, consistently brings about stable performance improvements across various datasets.

### Fine-Grained Image Classification

In this section, we assess the performance of our proposed frameworks on five fine-grained image classification tasks, utilizing SEW-ResNet18 as our base model. Tab. 2 showcases the classification accuracy for each method. The STCL framework consistently surpasses the baseline across all datasets. Specifically, it shows improvements of 6.98% on CUB (57.46% vs. 50.48%), 5.42% on Car (83.37% vs. 77.95%), and 5.85% on Aircraft (70.15% vs. 64.30%). Meanwhile, the TCL framework also demonstrates robust performance enhancements on four datasets. The outcomes affirm the effectiveness of our methods in leveraging augmentation invariance and temporal correlation under fine-grained datasets, thereby enhancing the representational capacity of SNNs.

### Comparison with state-of-the-art SNN Training Methods

In this section, we compare our proposed methods with current state-of-the-art SNN training methods on CIFAR-10, CIFAR-100, and DVS-CIFAR10 datasets. The results are presented in Tab. 3.

**CIFAR-10**. Our STCL method achieves an accuracy of 96.35%, which is the highest among all the compared methods. It outperforms the second-best method, Rec-Dis [46], by 0.8%. Furthermore, our

\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline Dataset & \multicolumn{2}{c}{CIFAR-100} & \multicolumn{2}{c}{CIFAR-10} & \multicolumn{2}{c}{DVS-CIFAR10} \\ \hline Model & SEW-18 & SEW-34 & SEW-18 & SEW-34 & SEW-18 & SEW-34 \\ \hline Baseline & 76.07 & 77.14 & 94.47 & 94.48 & 75.60 & 74.70 \\ \hline TCL & 77.38(+1.31) & 77.84(+0.70) & 94.92(+0.45) & 94.95(+0.47) & **77.20**(+1.60) & 76.60(+1.90) \\ \hline STCL w/o \(\mathcal{L}_{\text{CL}}\) & 78.60(+2.53) & 79.63(+2.49) & 95.44(+0.97) & 96.07(+1.59) & _74.70_(-0.90) & 75.50(+0.80) \\ \hline STCL & **79.51**(+3.44) & **80.30**(+3.16) & **95.97**(+1.5) & **96.39**(+1.91) & 76.60(+1.00) & **78.30**(+3.60) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Effectiveness of our proposed TCL and STCL framework on CIFAR and DVS-CIFAR.

\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Dataset & CUB\({}_{200}\) & Car\({}_{196}\) & Aircraft\({}_{102}\) & Flowers\({}_{102}\) & Dogs\({}_{120}\) \\ \hline BaseLine & 50.48 & 77.95 & 64.30 & 89.90 & 58.79 \\ \hline TCL & _50.29_(-0.19) & 78.73(+0.78) & 66.37(+2.07) & 90.00(+0.10) & 59.16(+0.37) \\ \hline STCL & **57.46**(+6.98) & **83.37**(+5.42) & **70.15**(+5.85) & **94.90**(+5.00) & **61.24**(+2.45) \\ \hline \hline \end{tabular}
\end{table}
Table 2: Fine-Grained Image Classfication. Numbers following datasets indicate category count.
TCL method also achieves competitive performance with an accuracy of 95.03%, which is on par with GLIF [48] and ESG [49]. Notably, our methods utilize only 4 time steps, which is lower than most of the other methods that use 6 time steps. This reduction in time steps indicates the efficiency of our proposed methods.

**CIFAR-100.** Our STCL and TCL method ranks higher than all of the compared methods and STCL achieves the best accuracy of 81.84%, outperforming the second-best method, TEBN [47], by 3.08%. Again, our methods require only 4 time steps, highlighting their efficiency in SNN training.

**DVS-CIFAR10**. On the DVS-CIFAR10 dataset, our TCL method achieves an accuracy of 79.10%, while our STCL method reaches an accuracy of 79.80%. Compared to the other methods, our methods perform competitively. Our STCL method surpasses the performance of DSR, but falls short of TEBN. However, it is worth noting that our methods only require 4 time steps, which is significantly fewer than most of the other methods that use 10 or more time steps. Our TCL method outperforms Dspike [50], Rec-Dis, and DSR, which highlights the effectiveness of our proposed framework.

### Ablation Studies

**Influence of hyperparameter \(\tau\) and \(\lambda\).** The performance of our proposed frameworks are influenced by hyperparameters \(\tau\) and \(\lambda\) in the contrastive loss function. Fig. 3 highlights the importance of tuning these hyperparameters while showcasing the robustness of our proposed frameworks to variations within a reasonable range (_i.e._, SEW-18). Fig. 3 (left) shows the effect of varying \(\tau\). As \(\tau\) increases, both TCL and STCL display robust performance. Specifically, performance peaks at \(\tau=0.07\) for TCL (77.38%) and at \(\tau=0.06\) for STCL (79.74%). Fig. 3 (right) examines the influence of the \(\lambda\) parameter. For TCL, lower \(\lambda\) values yield better results, with optimal performance at \(\lambda=0.5\) (77.38%). In contrast, STCL is more resilient to changes in \(\lambda\), with the highest accuracy at \(\lambda=2\) (79.57%). This suggests that while the choice of \(\lambda\) is critical, STCL's performance is less sensitive to this parameter, indicating good generalization ability. Based on these findings, we set \(\tau\) to 0.07 and \(\lambda\) to 0.5 for TCL, and 5 for STCL by default.

\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Dataset & Method & Training-SNN & Model & Time step & Accuracy \\ \hline \multirow{8}{*}{_CIFAR-10_} & TET[11]\({}^{\text{ICLR2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 94.50 \\  & Rec-Dis[46]\({}^{\text{CVPR2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 95.55 \\  & TEBN[47]\({}^{\text{NeurIPS2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 95.60 \\  & GLIF[48]\({}^{\text{NeurIPS2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 95.03 \\  & ESG[49]\({}^{\text{NeurIPS2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 95.49 \\ \cline{2-6}  & TCL & \(\checkmark\) & ResNet-19 & **4** & **95.03** \\  & STCL & \(\checkmark\) & ResNet-19 & **4** & **96.35** \\ \hline \multirow{8}{*}{_CIFAR-100_} & TET[11]\({}^{\text{ICLR2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 74.72 \\  & Rec-Dis [46]\({}^{\text{CVPR2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 74.10 \\ \cline{1-1}  & TEBN[47]\({}^{\text{NeurIPS2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 78.76 \\  & GLIF[48]\({}^{\text{NeurIPS2022}}\) & \(\checkmark\) & ResNet-19 & 6 & 77.35 \\ \cline{2-6}  & TCL & \(\checkmark\) & ResNet-19 & **4** & **79.73** \\  & STCL & \(\checkmark\) & ResNet-19 & **4** & **81.84** \\ \hline \multirow{8}{*}{_DVS-CIFAR10_} & Dspike[50]\({}^{\text{NeurIPS2021}}\) & \(\checkmark\) & ResNet18 & 10 & 75.40 \\  & TET[11]\({}^{\text{ICLR2022}}\) & \(\checkmark\) & VGG & 10 & 83.17 \\ \cline{1-1}  & Rec-Dis [46]\({}^{\text{CVPR2022}}\) & \(\checkmark\) & ResNet-19 & 10 & 72.42 \\ \cline{1-1}  & DSR[32]\({}^{\text{CVPR2022}}\) & \(\checkmark\) & VGG & 20 & 77.27 \\ \cline{1-1}  & TEBN[47]\({}^{\text{NeurIPS2022}}\) & \(\checkmark\) & VGG & 10 & 84.90 \\ \cline{1-1} \cline{2-6}  & TCL & \(\checkmark\) & VGG & **4** & **79.10** \\ \cline{1-1}  & STCL & \(\checkmark\) & VGG & **4** & **79.80** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparisons with current state-of-the-art methods on CIFAR and DVS-CIFAR.
**Influence of time steps \(T\).** The effect of varying time steps (\(T\)) on the performance of our proposed methods, TCL and STCL, is examined on CIFAR-100 and CIFAR-10 datasets in this section. As depicted in Fig. 4, both TCL and STCL consistently exceed the baseline across different time steps for both datasets (_i.e._, SEW-18). This underlines the ability of our frameworks to enhance performance by effectively modeling the temporal correlations in the SNNs. Our STCL method, exploiting both data augmentation invariance and temporal correlation, achieves the highest accuracy on both datasets. Specifically, it reaches 80.07% on CIFAR-100 and 95.97% on CIFAR-10, with time steps of 8 and 4, respectively. However, the performance tends to plateau or slightly decrease with an increase in time steps beyond these optimal points, indicating a balance between the number of time steps and model performance. This suggests that while increasing time steps initially enhances the model's generalizability, excessive time steps could risk overfitting or computational inefficiencies.

**Influence on spike firing rate.** Tab. 4 displays the spike firing rate across SEW-18 blocks for our methods. TCL reveals a slight increase in fire rates, contributing to notable performance enhancements. Meanwhile, STCL shows varied trends across blocks, implying intricate feature extraction. Despite a slight rise in computation, the significant performance gain affirms the viability of our method.

## 6 Conclusion

To summarize, this study proposes innovative solutions to the inherent performance-latency trade-off problem in SNNs through the introduction of the TCL and STCL frameworks. It is demonstrated that these frameworks considerably enhance the ability of SNNs to make fully use of temporal correlations and learn invariance to data augmentation, thereby improving performance under extremely low latency conditions. Experimental results, drawn from eight datasets, validate the proposed methods, with performance significantly outperforming established SOTA approaches. Prospective research will concentrate on refining these frameworks and examining their applicability across different domains. Ultimately, the aim is to realize the vision of efficient, low energy computation of SNNs.

\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline Block Index & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & Acc(\%) \\ \hline Baseline & 30.18 & 38.51 & 18.25 & 25.83 & 8.52 & 13.9 & 6.89 & 13.81 & 76.07 \\ TCL & 32.98 & 43.98 & 22.23 & 32.83 & 11.52 & 18.84 & 10.33 & 22.68 & 77.38 \\ STCL & 28.95 (\(\downarrow\)) & 34.28 (\(\downarrow\)) & 20.75 (\(\uparrow\)) & 28.11 (\(\uparrow\)) & 13.85 (\(\uparrow\)) & 20.46 (\(\uparrow\)) & 7.97 (\(\uparrow\)) & 22.20 (\(\uparrow\)) & 79.51 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Spike Firing rate across different SNN blocks

Figure 4: Influence of time step \(T\) on performance (**left**: CIFAR-10, **right**: CIFAR-100).

Figure 3: The effect of hyperparameters in contrastive loss on performance (**left**: \(\tau\), **right**: \(\lambda\)).