Skip Connections in Spiking Neural Networks: An Analysis of Their Effect
  on Network Training
Spiking neural networks (SNNs) have gained attention as a promising
alternative to traditional artificial neural networks (ANNs) due to their
potential for energy efficiency and their ability to model spiking behavior in
biological systems. However, the training of SNNs is still a challenging
problem, and new techniques are needed to improve their performance. In this
paper, we study the impact of skip connections on SNNs and propose a
hyperparameter optimization technique that adapts models from ANN to SNN. We
demonstrate that optimizing the position, type, and number of skip connections
can significantly improve the accuracy and efficiency of SNNs by enabling
faster convergence and increasing information flow through the network. Our
results show an average +8% accuracy increase on CIFAR-10-DVS and DVS128
Gesture datasets adaptation of multiple state-of-the-art models.
Hadjer Benmeziane, Amine Ziad Ounnoughene, Imane Hamzaoui, Younes Bouhadjar
# Skip Connections in Spiking Neural Networks: An Analysis of Their Effect on Network Training

###### Abstract

Spiking neural networks (SNNs) have gained attention as a promising alternative to traditional artificial neural networks (ANNs) due to their potential for energy efficiency and their ability to model spiking behavior in biological systems. However, the training of SNNs is still a challenging problem, and new techniques are needed to improve their performance. In this paper, we study the impact of skip connections on SNNs and propose a hyperparameter optimization technique that adapts models from ANN to SNN. We demonstrate that optimizing the position, type, and number of skip connections can significantly improve the accuracy and efficiency of SNNs by enabling faster convergence and increasing information flow through the network. Our results show an average +8% accuracy increase on CIFAR-10-DVS and DVS128 Gesture datasets adaptation of multiple state-of-the-art models.

 Spiking Neural Network, efficient deep learning, neural architecture search

## I Introduction

While Deep Learning (DL) has become a foundational technology to many applications, including autonomous driving, and medical imagining segmentation. Its inference is still energy-, resource- and time-expensive.

An ongoing challenge in DL research is to devise energy-efficient inference algorithms and hardware platforms. Taking inspiration from the brain, two intertwined solutions are investigated: (1) designing neuromorphic hardware, in which memory and computations reside within the same node and (2) building bio-inspired networks such as Spiking Neural Network (SNN), which can be more energy efficient than nonspiking neural networks. In this paper, we refer to this latter as Artificial Neural Network (ANN).

Although ANN are brain-inspired, there are fundamental differences in their computations and learning mechanism compared to the brain. In the brain, neurons communicate with each other via sequences of an action potential, also known as _spikes_. An action potential travels along the axon in a neuron and activates synapses. The synapses release neurotransmitters that arrive at the postsynaptic neuron. Here, the action potential rises with each incoming pulse of neurotransmitters. If the action potential reaches a certain threshold the postsynaptic neuron fires a spike itself. These individual spikes are sparse in time and space, which is the main reason behind the energy efficiency of biological neuronal networks, i.e., SNNs. In addition, the information in SNN is conveyed by spike times and thus can have a large capacity for encoding and representing the input data at the edge.

However, SNN architecture design and training are still in their early phases. An important scientific question is to what extent architecture characteristics (e.g., operations, skip connections) are compliant with the spatial and temporal constraints in SNN. To answer this question, this paper presents the following contribution:

* We investigate the relationship between the number of skip connections and accuracy drop that comes from standard architectures, including denseNet121 [1], resnet18 [2], and mobilenetv2 [3] converted to SNN. To the best of our knowledge, this is the first work introducing a dense spiking neural network.
* We propose an adaptation hyperparameter tuning algorithm that selects the best number of skip connections to optimize the trade-off between accuracy drop and energy efficiency.

## II Related Works

ANNs use gradient descent to optimize the weights during training, but this has proven challenging in SNN due to their non-differentiable nonlinear spikes [4]. A solution to this problem was to introduce surrogate derivatives during the backpropagation (BP) operation, which replaces the spiking activations with a smooth function [5]. While this has been successful at improving the accuracy of SNNs in solving
certain problems, their performance often falls short compared to that of ANNs. The reason for this discrepancy is twofold: 1) the surrogate gradient approaches only provide an approximation of the gradients and 2) the unfolding of SNNs in time to perform the backpropagation BP leads to the vanishing gradient problem, similar to the problem faced in vanilla Recurrent Neural Networks (RNNs). A study such as in [6] provides a method that computes exact gradients for arbitrary SNN architecture, but their applications were limited to relatively simple datasets, e.g., MNIST. The incorporation of local losses in space [7] and time [8] has shown promising results in circumventing the vanishing gradient problem, but as these methods only roughly approximate the gradients, they lead to less competitive performance. To further improve the learning in SNNs, other studies took a different approach by introducing novel architectures and ingredients. For example, the work in [9] showed that batch normalization through time could effectively train deep SNN. Another example is presented in [10], where the authors implemented a dedicated neural architecture search (NAS) to find the best architecture within common NAS benchmarks, such as NAS-Bench-201. While their methodology is promising, we found that adapting ANN standard architectures such as resnet18, or densenet, yields better accuracies in less search time. In our study, we adapt standard architectures and explore the effect of skip connections on learning in SNNs.

## III Proposed Methodology

In this section, we first describe the skip connection investigation. The investigation aims at understanding the importance of skip connections in SNN and motivating the use of hyperparameter optimization on the number of skip connections. We then present the general steps of our hyperparameters optimization strategy.

### _Skip connections in SNN_

Common state-of-the-art topologies comprise a small repeated set of layers, called _blocks_. The blocks are connected with a single sequential connection. The block's topology is described as a directed acyclic graph (DAG). Each vertex corresponds to a layer such as convolution, attention, or fully connected. The number of vertices in the graph is referred to as the depth of the block, \(d_{b}\). An adjacency matrix represents the connections between vertices.

Skip connections are commonly used inside the blocks to increase overall accuracy. Their main goal is to overcome the vanishing gradient problem that may prevent layers from training. There are two types of skip connections in the literature, as shown in figure 1 (a) and (b).

* Densenet-like Skip Connections (DSC) [1] concatenates previous layers' outputs, \(l_{i-n}\) where \(0<n<i\), as the input to the next layer. A direct mathematical relation is then created between the weights of layer \(l_{i-n}\) and the output of layer \(l_{i}\), which enhances backward gradient computation. However, adding these connections enlarges the input tensor which augments the number of multiply-accumulates operations (MAC).
* Addition-type Skip Connections (ASC) [2] perform element-wise summation of the outputs of previous layers, \(l_{i-n}\) where \(0<n<i\). The result is the input to the current layer \(l_{i}\). This type is usually used in resnet-like architectures.

To study the topological properties, we do not use the original architectures, such as DenseNets which contains all-to-all connections. Instead, we consider a generalized version where we vary the number of skip connections by randomly selecting only some channels for concatenation.

We define \(n_{\text{skip},i}\) as the number of skip connections coming to layer \(i\). To analyze the skip connection effect, we first build a single-block architecture, with 4 convolution layers inside the block. Figure 1 (right) shows the results of varying the \(n_{\text{skip}}\) and using both DSC and ASC types of skip connections. If \(n_{\text{skip}}\) is greater than the number of previous layers, we use the number of previous layers instead. For example, the second layer can only have \(n_{\text{skip}}=1\), and the fourth layer can have

Fig. 1: Left: Commonly used skip connections in neural networks. Right: Skip connections investigation results.
up to \(n_{\text{skip}}=3\). The hyperparameters and setup are described in section IV. We show the test accuracy on CIFAR-DVS [11] as well as the average firing rate for the SNN models. The firing rate refers to the rate at which a block generates output signals, which are typically referred to as spikes.

From figure 1 (right), we draw the following conclusions:

* Overall, increasing the number of skip connections, regardless of their type, enhances the model's accuracy and decreases the drop from the corresponding ANN version.
* Adding DSC slightly increases the average firing rate compared to ASC. The firing rate of the original architecture, i.e., \(n_{\text{skip}}=0\), is low (11%). The summation operation adds up the spikes of multiple inputs, which increases the overall firing rate of the network, while the concatenation operation combines the input signals into a single signal, which results in a lower overall firing rate but yields an increasing number of MACs. The choice of connection type between layers is critical. A lower firing rate and fewer operations can lead to energy efficiency and reduced computational requirements while offering a decent increase in accuracy.

### _Skip Connections Optimization_

We define the skip connections in the adjacency matrix of each block \(A_{b}\), where \(b\) is the index of the block in the overall topology. Each element of the adjacency matrix is defined in equation 1. Note that the adjacency matrix does not include any backward connections.

\[a_{ij}=\left\{\begin{array}{ll}0&\text{if no connection between i and j}\\ 1&\text{DSC connection between i and j}\\ 2&\text{ASC connection between i and j}\end{array}\right. \tag{1}\]

Figure 2 shows the overall hyperparameter optimization strategy used to adapt a given ANN such as densenet [1], resnet [2], or mobilenetv2 [3] to SNN. Given an initial ANN topology, denoted as \(\alpha\), the optimization aims at finding the right number, position, and type of skip connections that minimize the drop between ANN accuracy and its SNN counterpart. The overall optimization process comprises two steps: (1) we begin by constructing the search space of all possible adjacency matrices. Each block is extracted from the given topology and the number of layers in each block as well as the initial adjacency matrices are defined. (2) We use bayesian optimization (BO) to optimize the accuracy drop.

Formally, BO seeks to compute \(A^{*}=argmin_{A\in\Lambda}(A)\), where \(\Lambda\) is the set of all possible adjacency matrices and \(f(A)\) denotes the accuracy drop between the topology obtained with the adjacency matrix \(A\) and accuracy of \(\alpha\). Over a sequence of iterations, the results from all previous iterations are used to model the topology of \(\{f(A)\}_{A\in\Lambda}\) using the posterior distribution of the model. The next architecture is then chosen by optimizing an acquisition function. Two design decisions need to be taken in the case of BO: (1) The prior model, and (2) The acquisition function.

* **The Prior:** defines the probability distribution over the objective function. We use a gaussian process [12] (GP) to model this distribution. GP is a valuable surrogate model for such an expensive training objective. We do not use a predictor as it would require creating a dataset for each given topology.
* **The acquisition function:** defines how we select the next point to sample, given a conditional distribution over the values of the objective given by the prior. The most common acquisition functions used in literature are expected improvement (EI), probability of improvement (PI), and upper confidence bound (UCB) [13]. The latter is used in our search strategy. The UCB algorithm enables us to balance exploration and exploitation. It shifts from concentrating on exploration, choosing the least preferred actions, to focusing on exploitation.

These functions balance exploration with exploitation during the search. The chosen architecture is then trained and used to update GP. Evaluating \(f(A)\) in each iteration is the bottleneck of BO since we need to train the model. Because we optimize the skip connections, we can use previously trained weights and share them among all possible topologies \(\{f(A)\}_{A\in\Lambda}\). We only fine-tune the networks for \(n\) epochs to account for the removal or addition of skip connections. Besides, we use parallel BO, i.e., our strategy outputs \(k\) architectures to train in each iteration, so that the \(k\) architectures can be trained in parallel.

## IV Experiments

In this section, we present the results of the effects of skip connections on the performance of SNN. The experiments were conducted using the snnTorch library [14]. We evaluated the optimization on three datasets: CIFAR-10 [15], CIFAR-10-DVS [11], and DVS128 Gesture [16].

For CIFAR-10, we trained the model on 50k images split into 10 classes, with 5k each for validation and testing. We

Fig. 2: Overview of the hyperparameters optimization process.
used an SGD optimizer with a learning rate of 0.01 and a momentum of 0.9. The employed number of steps is equal to 25 and the maximum number of epochs is equal to 200. For CIFAR-10-DVS, the dataset contains 10k images recorded by a DVS128 sensor, split into 90% training and 10% test, with the training further divided into 80% new training and 20% validation. We train the models for 100 epochs with a learning rate set to 0.025, SGD optimizer, and momentum to 0.9. For DVS128 Gesture, event data was recorded from 29 subjects performing 11 hand gestures and preprocessed into 4k sequences for training, 500 for validation, and 500 for testing. The training was performed for 200 epochs with a learning rate of 0.01 and Adam optimizer.

### _Overall results_

Table I shows the overall results of optimizing the skip connections on three state-of-the-art architectures resnet18 [2], densenet121 [1], and mobilenetv2 [3]. Our optimized architectures consistently perform better than the original SNN version. On average, we achieve +11.3%, +9.3%, and +10.2% accuracy on CIFAR-10, CIFAR-10-DVS, and DVS128 Gesture respectively. Note that given the non-static images in CIFAR-10-DVS and DVS128 Gesture, conventional ANN is omitted for such type of data.

### _Comparison with random Search_

The efficacy of our hyperparameter optimization is compared to random search in figure 3. We implement a random search (RS) over the constructed search space of adjacency matrices. The search builds the architecture based on a randomly sampled adjacency matrix without replacement. Then RS trains the architecture from scratch which requires a massive computing budget. With fewer iterations, our method achieves better performance for optimizing multiple models with fewer iterations. Besides, our hyperparameter optimization is more stable and consistently provides closer solutions, which ensures finding the right architectures within a single run of search.

## V Conclusion and Future directions

This paper presents novel insights into the design and training of spiking neural networks (SNNs) and highlights the potential of skip connections as a promising tool for advancing SNN research. Our study evaluated both densenet-like and addition-type skip connections and found that both improved accuracy, with densenet-like connections being more energy-efficient by slightly increasing the firing rate. Our comprehensive hyperparameter optimization process led to the discovery of the optimal ANN to SNN adaptation, resulting in an average accuracy improvement of 8% within approximately 5 minutes. These results demonstrate the significance of skip connections in designing and training SNNs and pave the way for further research in this field. In future work, we plan to further improve the performance of SNNs by incorporating backward connections into our hyperparameter optimization. Additionally, exploring the split and connectivity between ANN/SNN processing on edge devices and the cloud is another promising avenue for future research. The integration of these innovations could lead to more practical applications of SNNs in real-world scenarios.
