Training Robust Spiking Neural Networks with ViewPoint Transform and
  SpatioTemporal Stretching
Neuromorphic vision sensors (event cameras) simulate biological visual
perception systems and have the advantages of high temporal resolution, less
data redundancy, low power consumption, and large dynamic range. Since both
events and spikes are modeled from neural signals, event cameras are inherently
suitable for spiking neural networks (SNNs), which are considered promising
models for artificial intelligence (AI) and theoretical neuroscience. However,
the unconventional visual signals of these cameras pose a great challenge to
the robustness of spiking neural networks. In this paper, we propose a novel
data augmentation method, ViewPoint Transform and SpatioTemporal Stretching
(VPT-STS). It improves the robustness of SNNs by transforming the rotation
centers and angles in the spatiotemporal domain to generate samples from
different viewpoints. Furthermore, we introduce the spatiotemporal stretching
to avoid potential information loss in viewpoint transformation. Extensive
experiments on prevailing neuromorphic datasets demonstrate that VPT-STS is
broadly effective on multi-event representations and significantly outperforms
pure spatial geometric transformations. Notably, the SNNs model with VPT-STS
achieves a state-of-the-art accuracy of 84.4\% on the DVS-CIFAR10 dataset.
Haibo Shen, Juyu Xiao, Yihao Luo, Xiang Cao, Liangqi Zhang, Tianjiang Wang
# Training Robust Spiking Neural Networks with Viewpoint Transform and Spatiotemporal Stretching

###### Abstract

Neuromorphic vision sensors (event cameras) simulate biological visual perception systems and have the advantages of high temporal resolution, less data redundancy, low power consumption, and large dynamic range. Since both events and spikes are modeled from neural signals, event cameras are inherently suitable for spiking neural networks (SNNs), which are considered promising models for artificial intelligence (AI) and theoretical neuroscience. However, the unconventional visual signals of these cameras pose a great challenge to the robustness of spiking neural networks. In this paper, we propose a novel data augmentation method, ViewPoint Transform and SpatioTemporal Stretching (VPT-STS). It improves the robustness of SNNs by transforming the rotation centers and angles in the spatiotemporal domain to generate samples from different viewpoints. Furthermore, we introduce the spatiotemporal stretching to avoid potential information loss in viewpoint transformation. Extensive experiments on prevailing neuromorphic datasets demonstrate that VPT-STS is broadly effective on multi-event representations and significantly outperforms pure spatial geometric transformations. Notably, the SNNs model with VPT-STS achieves a state-of-the-art accuracy of 84.4% on the DVS-CIFAR10 dataset.

Haibo Shen\({}^{1}\), Juyu Xiao\({}^{1}\), Yihao Luo\({}^{2,1}\), Xiang Cao\({}^{3,1}\), Liangqi Zhang\({}^{1}\), Tianjiang Wang\({}^{1}\)+School of Huazhong University of Science and Technology\({}^{1}\)

Yichang Testing Technique Research Institute\({}^{2}\)

Changsha University\({}^{3}\)

Spiking Neural Networks, Neuromorphic Data, Data Augmentation, ViewPoint Transform and SpatioTemporal Stretching

Footnote †: This work was supported in part by the National Natural Science Foundation of China under Grant 61572214 and Seed Foundation of Huazhong University of Science and Technology (2020kfyXGYJ114). (Corresponding author: Tianjiang Wang.)

## 1 Introduction

Inspired by the primate visual system, neuromorphic vision cameras generate events by sampling the brightness of objects. For example, the Dynamic Vision Sensor (DVS) [1] camera and the Vidar [2] camera are inspired by the outer three-layer structure of the retina and the foveal three-layer structure, respectively. Both of them have the advantages of high temporal resolution, less data redundancy, low power consumption, and large dynamic range [3]. In addition, spiking neural networks (SNNs) are similarly inspired by the learning mechanisms of the mammalian brain and are considered a promising model for artificial intelligence (AI) and theoretical neuroscience [4]. In theory, as the third generation of neural networks, SNNs are computationally more powerful than traditional convolutional neural networks (CNNs) [4]. Therefore, event cameras are inherently suitable for SNNs.

However, the unconventional visual signals of these cameras also pose a great challenge to the robustness of SNNs. Most existing data augmentations are fundamentally designed for RGB data and lack exploration of neuromorphic events. For example, Cutout [5] artificially impedes a rectangular block in the image to simulate the impact of occlusion on the image. Random erasing [6] further optimizes the erased pixel value by adding noise. Mixup [7] uses the weighted sum of two images as training samples to smooth the transition line between classes. Since neuromorphic data have an additional temporal dimension and differ widely in imaging principles, novel data augmentations are required to process the spatiotemporal visual signals of these cameras.

In this paper, we propose a novel data augmentation method suitable for events, ViewPoint Transformation and SpatioTemporal Stretching (VPT-STS). Viewpoint transformation solves the spatiotemporal scale mismatch of samples by introducing a balance coefficient, and generates samples from different viewpoints by transforming the rotation centers and angles in the spatiotemporal domain. Furthermore, we introduce spatiotemporal stretching to avoid potential information loss in viewpoint transformation. Extensive experiments are performed on prevailing neuromorphic datasets. It turns out that VPT-STS is broadly effective on multiple event representations and significantly outperforms pure spatial geometric transformations. Insightful analysis shows that VPT-STS improves the robustness of SNNs against different spatial locations. In particular, the SNNs model with VPT-STS achieves a state-of-the-art accuracy of 84.4% on the DVS-CIFAR10 dataset.

Furthermore, while this work is related to EventDrop [8],
NDA [9], there are some notable differences. For example, NDA is a pure global geometric transformation, while VPT-STS changes the viewpoint of samples in the spatiotemporal domain. EventDrop is only experimented on CNNs, it introduces noise by dropping events, but may cause problems with dead neurons on SNNs. VPT-STS is applicable to both CNNs and SNNs, maintaining the continuity of samples. In addition, EventDrop transforms both temporal and spatial domains, but as two independent strategies, it does not combine the spatiotemporal information of the samples. To our knowledge, VPT-STS is the first event data augmentation that simultaneously incorporates spatiotemporal transformations.

## 2 Method

### Event Generation Model

The event generation model [3, 4] is abstracted from dynamic vision sensors [1]. Each pixel of the event camera responds to changes in its logarithmic photocurrent \(L=\log(I)\). Specifically, in a noise-free scenario, an event \(e_{k}=(x_{k},y_{k},t_{k},p_{k})\) is triggered at pixel \(X_{k}=(y_{k},x_{k})\) and at time \(t_{k}\) as soon as the brightness variation \(|\Delta L|\) reaches a temporal contrast threshold \(C\) since the last event at the pixel. The event generation model can be expressed by the following formula:

\[\Delta L(X_{k},t_{k})=L(X_{k},t_{k})-L(X_{k},t_{k}-\Delta t_{k})=p_{k}C \tag{1}\]

where \(C>0\), \(\Delta t_{k}\) is the time elapsed since the last event at the same pixel, and the polarity \(p_{k}\in\{+1,-1\}\) is the sign of the brightness change. During a period, the event camera triggers event stream \(\mathcal{E}\):

\[\mathcal{E}=\{e_{k}\}_{k=1}^{N}=\{(X_{k},t_{k},p_{k})\}_{k=1}^{N} \tag{2}\]

where \(N\) represents the number of events in the set \(\mathcal{E}\).

As shown in Figure 1, an event is generated each time the brightness variances reach the threshold, and then \(|\Delta L|\) is cleared. The event stream can be represented as a matrix:

\[M_{\varepsilon}=\begin{pmatrix}y_{1}&x_{1}&t_{1}&1\\ \vdots&\vdots&\vdots&\vdots\\ y_{N}&x_{N}&t_{N}&1\end{pmatrix}_{4\times N} \tag{3}\]

For convenience, we omit the unconverted polarity \(p\).

### Motivation

This work stems from the observation that it is difficult to maintain absolute frontal view between the sample and cameras, which easily leads to a slight shift of the viewpoint. Considering this small offset distance, we use viewpoint rotation to approximate the deformation of samples in space and time. In addition, since events record the brightness change of samples, especially changes of the edge, variations of the illumination angle will also cause the effect of viewpoint transformation, which suggests that we can enhance the robustness of SNNs by generating viewpoint-transformed samples.

### The Proposed Method.

To generate viewpoint-transformed samples, we draw on the idea of spatio-temporal rotation. For viewpoint transformation (**VPT**), we introduce translation matrices \(T_{b}\), \(T_{a}\), which represent the translation to the rotation center \((x_{c},y_{c},t_{c})\) and the translation back to the original position, respectively.

\[T_{b}=\begin{pmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ -y_{c}&-x_{c}&-t_{c}&1\end{pmatrix},T_{a}=\begin{pmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ y_{c}&x_{c}&t_{c}&1\end{pmatrix} \tag{4}\]

Suppose that rotate along the \(y\) and \(t\) planes with \(x\) as the axis, we can easily derive the rotation matrix \(R_{r}^{YT}\):

\[R_{r}^{YT}=\begin{pmatrix}cos\theta&0&sin\theta&0\\ 0&1&0&0\\ -sin\theta&0&cos\theta&0\\ 0&0&0&1\end{pmatrix} \tag{5}\]

where \(\theta\) is the rotation angle. In practice, Eq 5 is an unbalanced matrix due to the mismatch between the time and space dimensions in the \(M_{\varepsilon}\) matrix. Therefore, we introduce a balance coefficient \(\tau\) to scale the space and time dimension, which results in a better visual effects. The balanced matrix \(R_{br}^{YT}\) can be formulated as:

\[R_{br}^{YT}=\begin{pmatrix}cos\theta&0&\tau sin\theta&0\\ 0&1&0&0\\ -\frac{1}{\tau}sin\theta&0&cos\theta&0\\ 0&0&0&1\end{pmatrix} \tag{6}\]

Set \(x_{c}=0\), the viewpoint transformation matrix \(M_{br}^{YT}\) can be formulated by calculating \(T_{b}R_{br}^{YT}T_{a}\):

\[\begin{pmatrix}cos\theta&0&\tau sin\theta&0\\ 0&1&0&0\\ -\frac{1}{\tau}sin\theta&0&cos\theta&0\\ -x_{c}cos\theta+\frac{1}{\tau}csin\theta+x_{c}&0&-\tau x_{c}sin\theta-t_{c}cos \theta+t_{c}&1\end{pmatrix} \tag{7}\]

Similarly, the viewpoint transformation matrix \(M_{br}^{XT}\) in

Figure 1: Event generation model.
the \(x\) and \(t\) dimensions can be formulated as:

\[\left.\begin{pmatrix}1&0&0&0\\ 0&cos\theta&\tau sin\theta&0\\ 0&-\frac{1}{\tau}sin\theta&cos\theta&0\\ 0&-x_{c}cos\theta+\frac{1}{\tau}t_{c}sin\theta+x_{c}&-\tau x_{c}sin\theta-t_{c} cos\theta+t_{c}&1\end{pmatrix}\right\} \tag{8}\]

Therefore, the viewpoint-transformed matrix \(M_{VPT}^{YT}\) and \(M_{VPT}^{XT}\) can be formulated as:

\[M_{VPT}^{YT}=M_{e}M_{br}^{YT} \tag{9}\] \[M_{VPT}^{XT}=M_{e}M_{br}^{XT}\]

Furthermore, since events beyond the resolution will be discarded during the viewpoint transformation, we introduce spatiotemporal stretching (**STS**) to avoid potential information loss. STS stretches the temporal mapping in the VPT by a coefficient \(\frac{1}{cos\theta}\) while maintaining the spatial coordinates unchanged. Therefore, by setting \(t_{c}=0\), we get the transformed \((t)_{STS}^{YT}\) and \((t)_{STS}^{XT}\) from Eq. 7 and Eq. 8:

\[(t_{k})_{VPT}^{YT}=(t_{k})-\tau tan\theta\cdot((y_{k})-y_{c}) \tag{10}\] \[(t_{k})_{VPT}^{XT}=(t_{k})-\tau tan\theta\cdot((x_{k})-x_{c})\]

The time of STS is advanced or delayed according to the distance from the center \(|x-x_{c}|\) (\(|y-y_{c}|\)), causing event stream to be stretched long the time axis according to the spatial coordinates.

## 3 Experiments

### Implementation

Extensive experiments are performed to demonstrate the superiority of the VPT-STS method on prevailing neuromorphic datasets, including CIFAR10-DVS(CIF-DVS) [10], N-Caltech101(N-Cal) [11], N-CARS [12] datasets. N-Caltech101 and CIFAR10-DVS datasets are generated by neuromorphic vision sensors on the basis of traditional datasets, while N-CARS is collected in the real world. For the convenience of comparison, the model without VPT-STS with the same parameters is used as the baseline. STBP [13] methods are used to train SNN-VGG9 network, other parameters mainly refer to NDA [14]. For example, the Adam optimizer is used with an initial learning rate of \(1e-3\). The neuron threshold and leakage coefficient are \(1\) and \(0.5\), respectively. In addition, we also evaluate the performance of VPT-STS on various event representations with the Resnet9 network, including EST [15], VoxelGrid [16], EventFrame [17] and EventCount [18] representations.

### Performance on various representations

Extensive experiments are conducted to evaluate the performance of VPT-STS method on different event representations, covering SNNs and CNNs. As shown in Tab. 1, SNNs with VPT-STS methods achieve significant improvements on three prevailing datasets. And VPT-STS also performs well on four representations commonly used by CNNs. It is worth noting that EST maintains the most spatiotemporal information from neuromorphic data and thus performs best overall. Furthermore, since the samples of N-CARS are collected in the real world, its initial viewpoint diversity is already enriched compared to the other two datasets. Considering the high baseline on N-CARS, VPT-STS still further imporves the robustness of SNNs.

\begin{table}
\begin{tabular}{c c c c c c c} \hline \multirow{2}{*}{Datasets} & \multirow{2}{*}{Method} & \multicolumn{5}{c}{Accuracy (\%)} \\ \cline{3-6}  & & SNNs & EventFrame & EventCount & VoxelGrid & EST \\ \hline \multirow{2}{*}{CIFAR10-DVS} & Baseline & 83.20 & 78.71 & 78.85 & 77.47 & 78.81 \\  & VPT-STS & 84.40 & 79.58 & 79.12 & 79.62 & 79.37 \\ \hline \multirow{2}{*}{N-Caltech101} & Baseline & 78.98 & 73.08 & 73.66 & 77.08 & 78.41 \\  & VPT-STS & 81.05 & 76.96 & 76.38 & 79.13 & 78.88 \\ \hline \multirow{2}{*}{N-CARS} & Baseline & 95.40 & 94.44 & 94.76 & 93.86 & 94.97 \\  & VPT-STS & 95.85 & 94.60 & 94.81 & 94.30 & 94.99 \\ \hline \end{tabular}
\end{table}
Table 1: Performance of VPT-STS on SNNs and CNNs with various representations.

\begin{table}
\begin{tabular}{c c c c} \hline \multirow{2}{*}{Methods} & \multirow{2}{*}{References} & \multicolumn{2}{c}{Accuracy (\%)} \\ \cline{3-4}  & & CIF-DVS & N-CARS \\ \hline HATS[12] & CVPR 2018 & 52.40 & 81.0 \\ Dart[19] & TPAMI 2020 & 65.80 & - \\ Dspike [20] & NeurIPS 2021 & 75.40 & - \\ STBP [13] & AAAI 2021 & 67.80 & - \\ AutoSNN [21] & ICML 2022 & 72.50 & - \\ RecDis [22] & CVPR 2022 & 72.42 & - \\ DSR [23] & CVPR 2022 & 77.27 & - \\ NDA [9] & ECCV 2022 & 81.70 & 90.1 \\ \hline
**VPT-STS** & - & **84.40** & **95.85** \\ \hline \end{tabular}
\end{table}
Table 2: Performance of VPT-STS and previous SOTAs on CIFAR10-DVS and N-CARS datasets.
### Compared with SOTAs

As shown in Tab. 2, we compare VPT-STS with recent state-of-the-art results on neuromorphic datasets. The results show that VPT-STS achieves substantial improvements over previous SOTAs. It is worth noting that VPT-STS significantly outperforms NDA, which is an ensemble of six geometric transformations. The experimental results demonstrate the superiority of combining spatiotemporal information for data augmentation. Since VPT-STS is orthogonal to most training algorithms, it can provide a better baseline and improve the performance of existing models.

### Ablation Studies on VPT-STS

As shown in Fig. 3, the performance of VPT-STS with different rotation angles is evaluated on the N-Caltech101 dataset. It turns out that a suitable rotation angle is important for the performance of data augmentation, which can increase data diversity without losing features.

### Analysis of VPT-STS

To gain further insight into the workings of VPT-STS, we add different strategies on the baseline to analyze the effective components of VPT-STS. As shown in Table 3, spatial rotation (Rotation) is performed as a comparative experiment for VPT-STS. It turns out that both VPT and STS including spatiotemporal transformations are significantly better than pure spatial geometric transformations on all three datasets, which illustrate the importance of spatiotemporal transformations.

While VPT and STS are implemented with operations similar to rotation, it actually improves the robustness of SNNs to different viewpoints. Furthermore, we evaluate the robustness of SNNs to viewpoint fluctuations by adding different degrees of spatiotemporal rotation to the test data. Figures 2(a) and 2(b) show the performance of the baseline model and the model trained by VPT-STS under different disturbances, respectively. The results show that the general trend of the accuracy change is to decrease with the increase of the perturbation amplitude. In addition, Fig. 2(c) shows the difference in the accuracy reduction of the VPT-STS compared to baseline. As the perturbation amplitude increases, the difference in the accuracy reduction of the two models is less than zero, and the absolute value grows, which illustrate that the accuracy reduction of baseline is larger than that of VPT-STS. Experimental results show that the model trained with VPT-STS generalize better and improves the robustness of SNNs against spatial location variances.

## 4 Conclusion

We propose a novel data augmentation method suitable for events, viewpoint transformation and spatiotemporal stretching (VPT-STS). Extensive experiments on prevailing neuromorphic datasets show that VPT-STS is broadly effective on multiple event representations and significantly outperforms pure spatial geometric transformations. It achieves substan

\begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{Methods} & \multicolumn{3}{c}{Accuracy (\%)} \\ \cline{2-4}  & CIF-DVS & N-Cal & N-CARS \\ \hline Baseline & 83.20 & 78.98 & 95.40 \\ Rotation & 83.90 & 80.19 & 95.46 \\ VPT & **84.40** & **81.05** & 95.56 \\ STS & 84.30 & 80.56 & **95.85** \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of Different Strategies.

Figure 2: Performance of VPT-STS and Baseline under different perturbations.
tial improvements over previous SOTAs by improving the robustness of SNNs to different viewpoints.
