Adaptive Reorganization of Neural Pathways for Continual Learning with
  Spiking Neural Networks
The human brain can self-organize rich and diverse sparse neural pathways to
incrementally master hundreds of cognitive tasks. However, most existing
continual learning algorithms for deep artificial and spiking neural networks
are unable to adequately auto-regulate the limited resources in the network,
which leads to performance drop along with energy consumption rise as the
increase of tasks. In this paper, we propose a brain-inspired continual
learning algorithm with adaptive reorganization of neural pathways, which
employs Self-Organizing Regulation networks to reorganize the single and
limited Spiking Neural Network (SOR-SNN) into rich sparse neural pathways to
efficiently cope with incremental tasks. The proposed model demonstrates
consistent superiority in performance, energy consumption, and memory capacity
on diverse continual learning tasks ranging from child-like simple to complex
tasks, as well as on generalized CIFAR100 and ImageNet datasets. In particular,
the SOR-SNN model excels at learning more complex tasks as well as more tasks,
and is able to integrate the past learned knowledge with the information from
the current task, showing the backward transfer ability to facilitate the old
tasks. Meanwhile, the proposed model exhibits self-repairing ability to
irreversible damage and for pruned networks, could automatically allocate new
pathway from the retained network to recover memory for forgotten knowledge.
Bing Han, Feifei Zhao, Wenxuan Pan, Zhaoya Zhao, Xianqi Li, Qingqun Kong, Yi Zeng
# Adaptive Reorganization of Neural Pathways for Continual Learning with Spiking Neural Networks

###### Abstract

The human brain can self-organize rich and diverse sparse neural pathways to incrementally master hundreds of cognitive tasks. However, most existing continual learning algorithms for deep artificial and spiking neural networks are unable to adequately auto-regulate the limited resources in the network, which leads to performance drop along with energy consumption rise as the increase of tasks. In this paper, we propose a brain-inspired continual learning algorithm with adaptive reorganization of neural pathways, which employs Self-Organizing Regulation networks to reorganize the single and limited Spiking Neural Network (SOR-SNN) into rich sparse neural pathways to efficiently cope with incremental tasks. The proposed model demonstrates consistent superiority in performance, energy consumption, and memory capacity on diverse continual learning tasks ranging from child-like simple to complex tasks, as well as on generalized CIFAR100 and ImageNet datasets. In particular, the SOR-SNN model excels at learning more complex tasks as well as more tasks, and is able to integrate the past learned knowledge with the information from the current task, showing the backward transfer ability to facilitate the old tasks. Meanwhile, the proposed model exhibits self-repairing ability to irreversible damage and for pruned networks, could automatically allocate new pathway from the retained network to recover memory for forgotten knowledge.
## Keywords

Self-organized Regulation, Continual Learning, Reorganize Sparse Neural Pathways, Spiking Neural Networks, Child-like Simple-to-complex Cognitive Tasks

## 1 Introduction

Human brain is the ultimate self-organizing system [1, 2]. The brain has the remarkable ability to coordinate 86 billion neurons with over 100 trillion synaptic connections self-organizing into dynamic neural circuits for different cognitive functions [3]. Throughout the human lifetime, neural connections continue to adaptively reorganize [4], driven by the genes and the external environment [5]. Under the central regulation of multiple communication modes such as feedback mechanisms [6], synchronous oscillations [7] and the third regulation factor [8], large neural connections are temporarily disconnected, leading to self-organized convergence forming task-specific sparse neural circuits [9, 10]. Even though the number of neurons no longer increases in adulthood [11], humans still possess the capacity for lifelong learning from simple movement and perception to complex reasoning, decision making and social cognition.

Although existing artificial neural network continual learning algorithms have proposed some solutions inspired by brain mechanisms, they are different from the lifelong learning process of the brain. Most of them are based on fixed dense network structure or mask-preserving subnetworks and lack the capacity to self-organize for discovering adaptive connections and selecting efficient neural pathways. In addition, the vast majority of existing continual learning algorithms are based on Deep Neural Networks (DNNs), with little exploration on Spiking Neural Networks (SNNs). The DNNs-based Continual Learning has been proposed mainly inspired by two categories of brain mechanisms: synaptic plasticity and structural plasticity.

Synapses are carriers of memory [12], and synapse-based continuous learning algorithms can be divided into synaptic importance measure and knowledge distillation. The former restricts the plasticity of important synapses [13, 14, 15], and the latter uses "soft-supervised" information from old tasks to overcome catastrophic forgetting [16, 17]. Some recently proposed dual-network continuous learning algorithms [18, 19, 20, 21] use the additional network to generate the main network weights or weight regulation coefficients. However, these algorithms use fixed dense networks in all tasks lacking sufficient memory capacity and brain-inspired sparsity to learn large-scale tasks.

Inspired by the dynamic structural plasticity mechanisms of the brain, additional algorithms extend new network structures for new tasks [22, 23], resulting in network consumption skyrocketing with the number of tasks, and being inconsistent with the energy efficiency of the brain. To solve this problem, the proposed subnetwork selection algorithms select a sparse subnetwork structure for each task by evolution [24], pruning [25, 26], or reinforcement learning [27, 28]. These algorithms reduce energy consumption, but need to store a subnetwork mask for each task. And the
subnetworks of all tasks are selected from the initial network, preventing knowledge migration between tasks.

Spiking neural networks (SNNs), as the third-generation artificial neural network [29], simulate the discrete spiking information transfer mechanism in the brain [30]. The basic unit spiking neuron integrates rich spatio-temporal information, which is more biologically plausible and energy efficient. As a brain-inspired cognitive computing platform, SNNs have achieved comparable performance to DNNs in classification [31; 32], reinforcement learning [33; 34] and social cognition [35] modelling. Among the few existing SNNs-related continuous learning algorithms, HMN [36] uses DNNs to regulate the spiking thresholds of the neurons in SNNs. ASPs [37] rely on spiking time-dependent synaptic plasticity (STDP) to overcome catastrophic forgetting. However, both of them are only suitable for shallow networks to accomplish simple tasks. DSD-SNN [38] introduces brain-inspired structural development and knowledge reuse mechanism that enable deep SNNs to accomplish continual learning and no longer need to save additional sub-network masks, but still suffers from the problem of ever-expanding network consumption. The contribution of SNNs in multi-task continual learning is still waiting to be further explored.

The human brain could dynamically reorganize neural circuits during continual development and learning processes. Especially, the adult brain possesses a nearly fixed number of neurons and connections [11], while it can incrementally learn and memorize new tasks by dynamically reorganizing the connections between neurons [39], as shown in Fig 1. Inspired by this, we design Self-Organized regulation (SOR) networks to adaptively activate sparse neural pathways from a fixed spiking neural network and endow them with synaptic strengths, enabling the single SNN to incrementally memorize multiple tasks. The main contributions of this paper can be summarized as follows:

* Our proposed SOR-SNN model can self-organize to activate task-related sparse neural pathways without human intervention, reducing per-task energy con

Figure 1: **Sparse neural pathways self-organized collaboration for continual learning.** Purple neurons and cyan neurons are individual neurons for task 1 and task 2, respectively, and blue neurons are shared for both tasks. In the blue box, the different synapses of neuron D are utilized for different tasks and form sparse connections.
sumption while enabling the limited SNNs to have a large number of sparse neural connectivity combinations, thus enhancing the memory capacity for more tasks.
* Extensive experiments demonstrate the superior performance of the proposed model on child-like simple-to-complex cognitive tasks and generalized datasets CIFAR100 and ImageNet. In addition, the proposed model reveals outstanding strengths on more complex tasks, and knowledge backward transfer capability in which learning new tasks improves the performance of old tasks without replaying old task samples.
* The SOR-SNN model also shows the self-repairing ability to irreversible damage, in that when the structure of the SNN is pruned resulting in forgetting of acquired knowledge, the retained neurons and synapses can be automatically assigned to repair memory for the forgotten task without affecting other acquired tasks.

## 2 Results

### Spiking Neural Networks with Self-organized regulation Networks Framework

The SNN invokes different sparse neural circuits sequentially to accomplish different tasks under the regulation of the self-organized regulation network. From Fig. 2, each region of the spiking neural network possesses a self-organizing regulation network, and the regions with multiple layers are divided according to the structure of the SNN (e.g. each block in a ResNet model represents a region).

The self-organizing regulation network can generate different sparse neural pathways \(P_{t}\) (Pathway Search Module) and the synaptic strength \(W_{t}\) (Fundamental Weighting Module) for different tasks \(t\). The inputs to the regulation network are learnable task-related vector \(x_{T}\) and layer-related vector \(x_{L}\), as well as the state of the regulation network in the previous layer. In the testing phase, SOR network generates the task-specific sparse structure and corresponding weights of the main SNN based on the inputs of the task \(x_{T}\) and the layer \(x_{L}\), which are combined with the sample inputs of the current task to realize the task output.

During the continual learning process, the self-organized regulation network directly designs the main SNN and will be optimized end-to-end to achieve high performance. In addition, to overcome catastrophic forgetting, the regulation network makes the neural pathways \(P_{t}\) activated for each task as orthogonal as possible to minimize inter-task interference. Orthogonal activation pathways allow finite SNNs with a large number of different connection combinations to accomplish more tasks and achieve higher memory capacity. At the same time, we make the synaptic weights \(W_{t}\) as equal as possible in each task to preserve the memory.

Based on the flexible regulation of the SOR network, the main SNN could generate diverse sub-neural pathways, showing the potential of expanding the memory
capacity. In this paper, we verify the performance, energy consumption, memory capacity, and backward transfer ability on child-like simple-to-complex multi-task learning, generalized continual learning datasets (CIFAR100 and ImageNet). More importantly, the separate SOR network shows high adaptability to structural mutations of the main SNN network.

### Continual learning child-like simple-to-complex tasks

During child growth and development, the brain gradually learns and memorizes hundreds of cognitive tasks. This process does not happen all at once, but starts with simple tasks and gradually progresses to more complex ones. In this paper, we simulate the developing process of child simple-to-complex cognition by sequentially learning sketches (3,929 images), cartoon drawings (3,929 images), and real photographs (1,670 images) [40], as shown in Fig. 3 A-C. Specifically, our SNN structure is ResNet18 and the regulation network employs the LSTM with 96 hidden layer neurons.

During the simple-to-complex experiment, samples of three cognitive tasks are sequentially fed into the SOR-SNN model to learn. We monitored the SNN weights

Figure 2: **The procedure of SOR-SNN model. Each spiking neural network block in the proposed SOR-SNN model involves a self-organizing regulation network which is responsible for selectively activating task-specific sparse pathways in the SNN. For example: the purple connections form the pathway for task 1. In particular, the self-organizing regulatory network contains the fundamental weighing module and the path searching module. The large number of different combinations of connections allows the limited SNN to have the capacity to incrementally learn more n tasks.**
and task-specific pathways under the guidance of the self-organizing regulation network during the learning process. We visualized the activation of partial weights in the fully connected output layer of the ResNet18 SNN for each of cognitive task, as shown in Fig. 3 E-G. In the whole network, the self-organizing regulation network activates different combinations of weights for different tasks, forming task-specific sparse neural pathways. This gives a single network the ability to accomplish multiple cognitive tasks while reducing mutual interference between tasks and saving the energy consumption required per task.

Meanwhile, each synapse in our SNN was involved in a different number of task-specific pathways as shown in Fig. 3 D,H,L. Some synapses were activated in all three task-specific pathways, some synapses were activated in only one task-specific pathway, while others constantly remained inactive. This suggests that in our SOR-SNN model, the pathways of different tasks share connections for processing common features as well as have their own unique connections for recognizing task-specific features. Moreover, there is a portion of connections in the network that remain inactive all the time, indicating that the memory space of the network still has the capacity to accomplish more tasks.

In addition, we statistically calculated the distribution of the real-valued weights of SNNs from the output of the fundamental weighting module in the SOR network

Figure 3: **Validation of child-like simple-to-complex continual learning. (A-C)** The simple to complex cognitive tasks include sketches, cartoons and photos. **(E-G)** Task-specific sparse pathways, for example, the blue, yellow and purple arrows represent the pathways for Task 1, Task 2 and Task 3 respectively in the fully connected output layer. **(D,H,L)** Visualization of synaptic activation counts in partial convolutional and fully connected layers. **(I-K)** Distribution of real-valued weights in the fully connected layer for three different tasks.
for each cognitive task as shown in Fig. 3 I-K. The results show that the distribution of the synaptic weights of the SNNs in different tasks has minor variations but generally stays the same. Unlike existing artificial neural networks in which past learned knowledge is lost due to large changes in weights, our SOR-SNN model applies similar weights in different tasks that can effectively avoid catastrophic forgetting.

### Superiority in performance, energy consumption, memory capacity and backward transfer

To verify the effectiveness of our SOR-SNN, we conduct experiments on child-like simple-to-complex continual learning tasks, and two generalized CIFAR100 and ImageNet datesets. For comparison, we replicate other continual learning algorithms to SNN, including: the EWC [13] and MAS [15], methods based on the modification of synaptic plasticity in a single network; HNET [18], LSTM_NET [19] and the DualNet [41] methods based on the dual-network generating weights or weight regulation coefficients. In addition, we compare the rare previous SNN-based Continual Learning method DSD-SNN [38], which belongs to the sparse structural extension methods. All of these methods were conducted in multiple times using the same LIF neurons and the same generational gradient training method in the SNN.

Figure 4: **The comparative performance of SOR-SNN on diverse continual learning tasks.** The average accuracy **(A-C)** and the number of inactive parameters **(D-F)** of the network for simple to complex cognitive tasks, the CIFAR100 and Mini-ImageNet datasets. The average accuracy on the large scale ImageNet dataset **(G)**.
#### 2.3.1 Continual learning accuracy

Fig. 4 A-C,G is the average accuracy of task t and its previous tasks. We can find that our SOR-SNN algorithm maintains superior accuracy in all multi-task sequential learning of the simple-to-complex cognitive task, the CIFAR100, mini-ImageNet, and ImageNet datasets. For simple-to-complex cognitive task, our SOR-SNN achieves an average accuracy of 62.72\(\pm\)1.25%, which is consistently higher than HNET SNN and LSTM_NET SNN continual learning algorithms. Although, the EWC SNN and MAS SNN achieved high accuracy in the first simplest task, their learning and memorization abilities significantly decreased in the more complex tasks. The DSD-SNN achieves higher accuracy in the first two tasks than our SOR-SNN, but after adding the most complex tasks, the average accuracy of our SOR-SNN is higher than the DSD-SNN. This suggests that our SOR-SNN is able to gradually enhance the learning ability in the process of knowledge accumulation and better accomplish more complex tasks compared to other algorithms.

For CIFAR100, we tested continual learning scenarios with 5steps (each task contains 20 classes), 10steps (each task contains 10 classes), and 20steps (each task contains 5 classes). The accuracy comparisons are depicted in Tab. 1. For 10steps, our SOR-SNN achieves an average accuracy of 80.12\(\pm\)0.25%, both consistently higher than other methods based on SNN or replicated in SNN. Compared to DSD-SNN, which has the second highest average accuracy and is the only known method implementing SNNs continual learning in CIFAR100, our SOR-SNN achieves a 2.20% accuracy improvement. Besides, our SOR-SNN has accuracy rates of 73.48%\(\pm\)0.46 and 86.65%\(\pm\)0.20 in 5steps and 20steps, with 9.04% and 5.48% improvement than the second highest accuracy, respectively. In particular, in 20steps learning, the performance of the proposed model not only does not degrade with the number of tasks, but also achieves a higher accuracy, demonstrating the strong memory capability of our model. Compared to DNN-based continual learning algorithms, our model achieves superior accuracy with low energy consumption as shown in Tab. 2.

In the ImageNet dataset, which has a larger sample scale and a larger number of sample classes, we first randomly selected 100 classes to form the Mini-ImageNet dataset and divided them into ten tasks. As shown in Fig. 4C, our SOR-SNN model achieves consistent superiority over HNET SNN and LSTM_NET SNN continual learning algorithms (EWC SNN and MAS SNN fail in the Mini-ImageNet).

\begin{table}
\begin{tabular}{l|c c c|c c|c} \hline \multirow{2}{*}{Method} & \multicolumn{2}{c|}{5steps} & \multicolumn{2}{c|}{10steps} & \multicolumn{2}{c}{20steps} \\ \cline{2-7}  & Acc (\%) & Std (\%) & Acc (\%) & Std (\%) & Acc (\%) & Std (\%) \\ \hline EWC [13] & 45.89 & 0.96 & 61.11 & 1.43 & 50.04 & 4.26 \\ SI [14] & 66.92 & 0.17 & 64.81 & 1.00 & 61.10 & 0.82 \\ MAS [15] & 61.88 & 0.27 & 64.77 & 0.78 & 60.40 & 1.74 \\ HNET [18] & 48.69 & 0.37 & 63.57 & 1.03 & 70.48 & 0.25 \\ LSTM\_NET [19] & 60.11 & 0.88 & 66.61 & 3.77 & 79.96 & 0.26 \\ DSD-SNN [38] & 64.44 & 0.24 & 77.92 & 0.29 & 81.17 & 0.73 \\
**Our SOR-SNN** & **73.48** & **0.46** & **80.12** & **0.25** & **86.65** & **0.20** \\ \hline \end{tabular}
\end{table}
Table 1: Accuracy comparisons on 5steps, 10steps and 20steps for CIFAR100.
Although the DSD-SNN outperforms our SOR-SNN in the earlier tasks, its accuracy gradually decreases during learning the subsequent tasks. Eventually, our SOR-SNN achieves a higher average accuracy than DSD-SNN in all tasks. This demonstrates that our model has more memory capacity and is able to learn and memorize more tasks. In contrast, DSD-SNN relies on energy-consuming structure growth, which is not competent for learning more tasks (although it brings improvement on the first few tasks).

In addition, we evaluated our SOR-SNN on the complete ImageNet dataset, which is the first time the SNN-based model achieves continual learning on the large-scale ImageNet dataset. Compared to the competitive DSD-SNN method, our model consistently achieves superior performance after learning 20 tasks. The accuracy rate of our SOR-SNN remains essentially stable over 100 tasks of the continual learning. This indicates that our SOR-SNN has a large memory capacity to constantly learn new tasks.

#### 2.3.2 Energy consumption

Under the effect of the self-organizing regulation network, our model activates a task-specific sparse pathway per task and uses only a portion of the network parameters, reducing the energy consumption of each task. Fig. 4 D-F depicts the number of synapses used for each task in the three datasets respectively. The activation rate of the main SNN is only between 40% and 50%. The average compression rate of our SOR-SNN is 52.37%,53.88% and 53.08% in the simple-to-complex cognitive task, CIFAR100 and Mini-ImageNet datasets, respectively.

Tab. 2 illustrates the comparison of the proposed method with other DNN-based methods in terms of the accuracy and the number of synaptic parameters utilized for SNN. The accuracy is represented by 10steps, and the number of parameters is averaged over all tasks. Compared to regularization algorithms using dense networks, our model uses the least number of parameters and achieves at least 15.31% improvement in accuracy. In comparison to the DSD-SNN, which is also based on sparse networks, such as MAS [15], HNET [18], LSTM_NET [19], etc, our SOR-SNN method achieves a 2.2% improvement in accuracy using only 9.35% of DSD-SNN parameters. The results show that our SOR-SNN achieves higher performance with fewer network parameters and lower energy consumption.

#### 2.3.3 Backward transfer capability

In the brain, not only has the forward transfer capacity that the past learned knowledge can assist the learning of new tasks, but also the learning of new tasks will improve the performance of the past tasks. In recent years, the forward transfer capability of continual learning algorithms has been proposed and validated in many models, but currently there are fewer models with backward transfer capability. This is due to the fact that many models freeze the connections related to previous tasks from being updated again or reduce their weight plasticity [45, 23, 38], hindering the backward transfer between tasks. As for our SOR-SNN model, it retains the ability of
past task-related synapses to be fine-tuned according to the new task while selecting new pathways for the new tasks. As shown in Fig. 5 A of the first box, in our SOR-SNN model, the accuracy of the second task after the third task is learned (darkblue line) is higher than when the second task was first learned (black line), and the similar phenomenon occurs in the learning of other tasks. In addition with the learning of subsequent tasks, the accuracy stability of the previous task also increases to some extent. This suggests that the knowledge learned from later tasks in our SOR-SNN model could contribute to a better completion of the previous task without retraining the previous task, realizing the backward transfer of knowledge.

#### 2.3.4 The balance of stability-plasticity

The challenge for neural networks to maintain a stable memory of acquired knowledge while possessing plasticity to learn new tasks is called the "stability-plasticity" dilemma, which is the core problem of Continual Learning. In our SOR-SNN model, we maintain stable memory by making the real weights of different tasks as equal as possible through memory loss, and enable the network to learn more new tasks by making the pathway connections of different tasks as different as possible through orthogonality loss. The \(\alpha\) and \(\beta\) respectively control the contribution of memory loss and orthogonality loss in network optimization. We analyze the effect of different \(\alpha\) and \(\beta\) parameters on the stability and plasticity of the proposed model. As shown in Fig. 5B, when \(\alpha\) is too large, the network forces the real weights of two different tasks to be too identical, resulting in a drop in the accuracy of both the old and new tasks. For example, during the learning process of task 2, when \(\alpha\) = 5, the accuracy rate of task 2 is inferior, while the accuracy for the previously learned task 1 is also the lowest. For CIFAR100, when \(\alpha\) is less than 0.5, the network maintains the memory of the old tasks without affecting the learning of the new tasks. Among them, when \(\alpha\) = 0.5, the highest average accuracy rate was consistently observed over the 10 tasks learning process.

\begin{table}
\begin{tabular}{c c c c} \hline \hline Method & Memory method & Accuracy (\%) & Parameters (\(10^{5}\)) \\ \hline EWC [13] & Synaptic Regularization & 61.11 \(\pm\) 1.43 & 6.9 \\ SI [14] & Synaptic Regularization & 64.81 \(\pm\) 1.00 & 6.9 \\ MAS [15] & Synaptic Regularization & 64.77 \(\pm\) 0.78 & 6.9 \\ IMM [42] & Synaptic Regularization & 63.13 & 65.5 \\ HAT [43] & Subnetwork Selection & 74.52 & 68.2 \\ PathNet [24] & Subnetwork Selection & 60.48 & 70.4 \\ DEN [23] & Subnetwork Selection & 58.10 & 3.6 \\ PGN [22] & Structural extensions & 68.32 & 68.0 \\ LG [44] & Structural extensions & 76.21 & 68.6 \\ HNET [18] & Hypernetwork & 63.57 \(\pm\) 1.03 & 4.6 \\ LSTM\_NET [19] & Hypernetwork & 66.61\(\pm\)3.77 & 4.6 \\ DSD-SNN [38] & Subnetwork Selection & 77.92 \(\pm\) 0.29 & 34.2 \\
**Our SOR-SNN** & **Self-organized Regulation** & **80.12 \(\pm\) 0.25** & **3.2** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Energy consumption and accuracy comparisons with DNNs-based algorithms for CIFAR100.
For the orthogonal loss coefficient \(\beta\), the SNN achieves the best performance of 80.12% when \(\beta=10^{-5}\) as shown in Fig. 5C. When \(\beta\) is minor, taking the learning process of task 7 as an example, the new task 7 has a higher accuracy, but the test accuracy of the old task 1 is lower. This is because if \(\beta\) is smaller, the orthogonal loss is smaller and the contribution of the classification loss is larger, so the new task performs better. However, this simultaneously results in a higher overlap between task-specific pathways, where the knowledge learned with the old task is easily interfered and disturbed. Conversely, when \(\beta\) is larger, the contribution of orthogonality loss is greater and the pathways of the old and new tasks are more orthogonal. As a result, there is stronger memorization and a higher test accuracy for the old task 1. Meanwhile, due to the overemphasis on pathways orthogonality, the accuracy on the new task 7 slightly drops. As shown in Fig. 5B-C, our SOR-SNN algorithm achieves an acceptable average accuracy for different loss parameters. This suggests that our model is robust and stable.

### The injury self-repair capability of SOR-SNN

Self-organization in the brain is also reflected in the self-repairing capability after injury [2]. Our brain is a robust system that can withstand various perturbations

Figure 5: **(A)** The current test accuracy of past learned tasks in our SOR-SNN model. **(B-C)** The effect of memory loss coefficient and orthogonal loss coefficient on performance. **(D)** Injury schematic, containing the initial network, the network with task-specific pathways assigned and the network after injury task 1 of SNNs. **(E)** Accuracy comparisons before and after injury of first four tasks on CIFAR100 10steps.
or even multiple micro-strokes without significant deleterious impact [46]. After the injury of one subsystem, the brain is able to self-organize to select new subsystems (synapses or networks) to perform functions previously handled by the injured subsystem, which is known as the functional plasticity [47, 48]. For example, in the visual system of cats, after parts of the retina are lesioned and injured, up to 98% of afferent neurons generate new receptive fields in the residual uninjured areas by optimizing neuronal connectivity when receiving previous inputs again [49]. Similarly, after partial peripheral nerve injury in the monkey brain, connections from the somatic surface to the primary sensory cortex undergo substantial reorganization. Electrophysiological recordings show that stimuli inputs that are previously responded to in the injured area now produce a reaction in the neighbouring uninjured area [50]. This self-organizing repair capacity is also found extensively in the medial prefrontal cortex, hippocampus, and amygdala [51].

To simulate this brain mechanism and verify the self-repairing ability of our model, we pruned part of the connections that are unique to task 1 after continuously learning the first 4 tasks as shown in Fig. 5D. The pruned connections are no longer used for all tasks. When our model received samples of task 1 again, the SOR-SNN was able to self-organize to select new neural pathways among the remaining available synapses without affecting the performance of the previously learned other tasks 2, 3 and 4. The experimental results show that the accuracy of our model in task 1 kept stable pre and post-injury, and under the condition of not replaying the other tasks, the tasks 2, 3 and 4 maintained their original performance and were not significantly affected (and even improved slightly), as shown in Fig. 5E. Before and after the injury, our model slightly decreased by 0.9% for task 2 and improved by 1.4% and 0.3% for tasks 3 and 4, respectively, whereas the DSD-SNN average accuracy of tasks 2, 3 and 4 dropped dramatically from 68.60% pre-injury to 16.12% experienced catastrophic forgetting. This is due to the fixed pathway of DSD-SNN for all tasks that lacked the ability of adaptive regulation. Overall, the experiments demonstrate that our self-organized regulation enables a brain-inspired injury self-repair capability.

## 3 Discussion

During human lifelong learning, the nerve centre of the brain is self-organized to flexibly modulate neural circuits according to the characteristics of different tasks [52, 53, 54], selectively activating some of appropriate neuronal connections to efficiently complete incremental tasks. Neuroscience studies have shown that the neural network scale of the adult brain hardly changes anymore [55], but it can form temporary task-specific neural pathways by dynamically reorganizing existing neurons and synapses [56, 57]. The neural pathway is activated when needed, and during the rest of the time its elements are involved in forming neural pathways for other tasks [39]. Inspired by this, we propose a brain-inspired continual learning algorithm with spiking neural networks based on self-organizing regulatory networks. Our model dynamically builds rich combinations of task-specific sparse neuronal connections for different tasks in limited SNNs, giving the SNNs the capacity to continually learn
more complex tasks and more tasks.

Different from other continual learning algorithms for DNNs and SNNs, the proposed algorithm constructs sparse pathways that are self-organizingly selected by the regulation network integrating the past learned knowledge and the current task features, rather than being artificially designed. Compared with existing synaptic regularization algorithms [16; 58; 17] and neuroregulation algorithms [20; 59; 18; 19], our SOR-SNN uses only a portion of the neural connections for each task, reducing task energy consumption while alleviating forgetting due to the interference between tasks. For example, EWC [13] and MAX [15] use all the synaptic connections of the 6.9\(\times\)10\({}^{5}\) parametric network, while our SOR-SNN uses an average of only 46.12% of the synaptic connections with 3.2\(\times\)10\({}^{5}\) parameters for each task, achieving 80.12% \(\pm\) 0.25% accuracy that is 19.01% and 15.35% higher than EWC and MAX, respectively. Meanwhile, compared with classical structure expansion algorithms [60; 61; 62], our SOR-SNN is able to fully utilize the limited network to form rich connection combinations without having to grow new neurons for the new task; and temporarily inhibit some neural connections for subsequent tasks instead of actually pruning irrelevant connections for the current task. In addition, unlike the common operation in structure expansion algorithms that freezes the neurons and synapses related to the old task [45; 23; 38], each of our neurons and synapses is continuously learned and optimized, and thus the proposed algorithm achieves the knowledge backward transfer capability that the learning of the new task improves the performance of the old task without replaying the old task samples.

To validate the effectiveness of the proposed SOR-SNN, we conducted extensive experiments on different tasks and datasets. The results in child-like simple-to-complex cognitive task indicate that our SOR-SNN achieves higher performance than other methods in more complex tasks and realizes the highest average accuracy. Due to its ability to flexibly select sparse neural connections, when an already learned neural pathway is damaged and no longer usable, our model is able to adaptively select suitable alternative pathways from the remained network to repair the structure and function like the biological brain, and does not affect other tasks already learned. Furthermore, our SOR-SNN belongs to the pioneering exploration of SNN-based Continual Learning algorithms in the large-scale dataset ImageNet. Experiments in the generalized datasets CIFAR100 and ImageNet demonstrate that our SOR-SNN achieves superior performance in SNN-based Continual Learning algorithms. In summary, our SOR-SNN model continuously learns more tasks using less energy by self-organizingly constructing task-specific sparse neural pathways, which opens the path for building brain-inspired flexible and adaptive efficient Continual Learning.
## Method

### Spiking Neural Networks

Motivated by the energy-efficient brain information transfer method, spiking neurons process binary information using discrete spike sequences as input and output. The spike sequence contains dynamic temporal information, thus different from traditional artificial neurons, spiking neurons have dual dimensions of temporal and spatial. In the spatial dimension, the spiking neuron \(i\) synthesizes the spike input \(S_{j}\) from the presynaptic neuron \(j\) to form the input current \(I_{i}\); in the temporal dimension, the membrane potential \(U_{i}\) of the spiking neuron accumulates the past spike information while receiving the current input current. In SOR-SNN, we used the common leaky integrate-and-fire (LIF) [63] spiking neuron with the following membrane potential \(U_{i}\) and spike \(S_{i}\) calculation formula:

\[I_{i}^{t}=\sum_{j=1}^{M}P_{t}^{ij}S_{j}^{t} \tag{1}\]

\[U_{i}^{t}=\tau U_{i}^{t-1}+I_{i}^{t} \tag{2}\]

\[S_{i}^{t}=\begin{cases}1,&U_{i}^{t}\geq V_{th}\\ 0,&U_{i}^{t}<V_{th}\end{cases} \tag{3}\]

where \(\tau=0.2\) is the time constant and \(t=4\) is the spiking time window. The spiking neuron receives the spike sequence input of length \(t\) and calculates the membrane potential at time \(t\) according to Eq. 2. When the membrane potential at time \(t\) exceeds the spike firing threshold \(V_{th}\), the neuron outputs \(1\) at time \(t\); conversely the neuron outputs \(0\). Discrete spikes result in spiking neurons being non-microscopic. To solve this problem, we used the Qgradgate [64] surrogate gradient method to approximate the gradient of the spike output as follows:

\[\frac{S_{i}^{t}}{U_{i}^{t}}=\begin{cases}0,&|U_{i}^{t}|>\frac{1}{\lambda}\\ -\lambda^{2}|U_{i}^{t}|+\lambda,&|U_{i}^{t}|\leq\frac{1}{\lambda}\end{cases} \tag{4}\]

where constant \(\lambda=2\). Above all, the discrete spatio-temporal spiking information transfer method reduces the energy consumption and enhances the knowledge representation capability of the spiking neural networks.

### Self-organizing regulation Network of our SOR-SNN

We use the same regulation network to generate different sparse pathways \(P_{t}\) and weight \(W_{t}\) for different tasks \(t\). An entire regulation network consists of multiple sub-regulation networks one-to-one responsible for each region of the main SNN. To output task-specific pathways for different tasks with a single regulation network, our regulation network receives learnable task-relevant inputs \(x_{T}\) and layer-relevant inputs
\(x_{L}\) as Eq. 5. During training, both of them adaptively learn representative information for different tasks and different layers, respectively; during testing, the learned \(x_{T}\) and \(x_{L}\) guide the regulation network to output different specific sparse pathways. Self-organizing regulation network includes a fundamental weighting module and a pathway search module.

\[x=\{x_{T},x_{L}\} \tag{5}\]

#### 3.2.1 Fundamental Weighting Module

To synergize the synaptic activities between different regions and different layers, the recurrent neural network acts as the fundamental weighting module to output the real-valued weights \(W_{t}\) prepared for the SNNs. In SNN, the weights of each layer are not independent, but work together to affect the overall performance. Thus we use the Long Short-Term Memory Network (LSTM) to synthesize information from previous layers and find the superior state of the current layer. Specifically, the hidden state of layer \(l\) is the output of the previous layer \(o_{l-1}\); in particular, the hidden state of the first layer of each region is the output of the last layer of the previous region. The fundamental weights \(W_{t}\) are calculated as follows:

\[c_{l}=c_{l-1}Forgate(x,o_{l-1})+Ingate(x,o_{l-1})Cell(x,o_{l-1}) \tag{6}\]

\[o_{l}=Outgate(x,o_{l-1})\tanh(c_{l}) \tag{7}\]

\[W_{t,l}=FC(o_{l}) \tag{8}\]

where \(Forgate,Ingate,Outgate\) and \(Cell\) are respectively the forget gate function, input gate function, output gate function and cell processing function of LSTM. The \(FC\) is the fully-connected output layer.

#### 3.2.2 Pathway Search Module

Based on the fundamental weights \(W_{t}\), the pathway search module is responsible for deciding whether the activation or inhibition of each weight to self-organize the task-specific sparse neural pathways. Inspired by the differentiable structure search algorithm [65, 66], each synapse \(s\) has two states, active and inactive, respectively corresponding to a learnable synaptic selection parameter \(A_{s}\) and \(\widetilde{A_{s}}\). When the learnable parameter \(A_{s}\) is greater than \(\widetilde{A_{s}}\), activating the synapses s is preferable for the performance of the current task compared to inhibiting it. That is, if \(A_{s}>\widetilde{A_{s}}\), the synapse \(s\) is activated. Otherwise, when the learnable parameter \(\widetilde{A_{s}}\) is greater than \(A_{s}\), the synapse s is supposed to be inhibited. Hence, the selection formula of sparse neural pathways \(P_{t}\) for task t is as follows:

\[P_{t}=\begin{cases}W_{t},&A_{s}\geq\widetilde{A_{s}}\\ 0,&A_{s}<\widetilde{A_{s}}\end{cases} \tag{9}\]
### The plasticity - stability in SOR-SNN

The loss function \(L\) is divided into three parts: classification loss \(L_{class}\), memory loss \(L_{mem}\) and orthogonal loss \(L_{orth}\). Firstly, the normal categorization loss \(L_{class}\) aims to improve the learning performance of the current task. Our SOR-SNN model uses the cross-entropy loss. Moreover, we attempt to make \(A_{s}\) and \(\widetilde{A_{s}}\) close to 0.5 to stabilize the selection of task-specific sparse pathways. Secondly, the memory loss \(L_{mem}\) aims to make the real-valued weights \(W_{t}\) as constant as possible in each task \(t\) as Eq. 10. Memory loss ensures that the fundamental weights \(W_{t}\) do not change significantly across tasks to maintain the stability of learned knowledge.

\[L_{mem}=\|W_{t}-W_{t-1}\|_{2} \tag{10}\]

And orthogonal loss \(L_{orth}\) expects the sparse pathways \(P_{t}\) selected for different tasks to be as different as possible to reduce interference between tasks, while making the SNN plastic to learn more new tasks through different connection combinations. The orthogonal loss is calculated as follows:

\[L_{orth}=\sum_{k=1}^{t}P_{t}P_{k} \tag{11}\]

The combination of the latter two not only saves energy, but also allows the limited network to learn more tasks achieving larger memory capacity. The loss function \(L\) is calculated as follows:

\[L=L_{class}+\alpha L_{mem}+\beta L_{orth} \tag{12}\]

where \(\alpha\) and \(\beta\) are the constant coefficient.

### The procedure of SOR-SNN

In the testing process of our model, the regulation network inputs task-relevant inputs \(x_{T}\) and layer-relevant inputs \(x_{L}\), self-organized outputs task-specific sparse pathways \(P_{t}\); the SNN receives picture samples \(D_{t}\) and task-specific pathways \(P_{t}\), outputs prediction class \(y\) as shown following:

\[y=SNN(P_{t},D_{t}) \tag{13}\]

During training, our SOR-SNN inputs training samples to compute the training loss \(L\). Then through backpropagation our model adaptively optimizes the parameters of the regulation network which contains learnable task-related inputs \(x_{T}\), layer-related inputs \(x_{L}\), synaptic selection parameter \(A_{s},\widetilde{A_{s}}\), and the LSTM weights.

We present the specific procedure of our SOR-SNN algorithm as follow Algorithm:

Input: Dataset \(D_{t}\) for each task \(t\).

Initialization: randomly initialize learnable input \(x_{T},x_{L}\) and learnable synaptic selection parameter \(A_{s},\widetilde{A_{s}}\).

Output: Prediction Class \(y\).
For \(D_{t}\) in sequential task \(T\):

For \(e\) in \(Epoch\):

Calculating \(W_{t}\) with learnable input \(x_{T},x_{L}\) as Eq. 5-8;

Selecting \(P_{t}\) with synaptic parameter \(A_{s},A_{s}\) as Eq. 9;

SNN forward prediction as Eq. 1-3;

Calculating the training loss as Eq. 10-12;

Backpropagation to update the regulation network;

end

## Data availability

The data used in this study are available in the following databases.

The simple-to-complex cognitive task data [40]:

[https://github.com/robertofranceschi/Domain-adaptation-on-PACS-dataset](https://github.com/robertofranceschi/Domain-adaptation-on-PACS-dataset).

The CIFAR100 data [67]:

[http://www.cs.toronto.edu/](http://www.cs.toronto.edu/) kriz/cifar.html.

The ImageNet data[68]:

[https://image-net.org/](https://image-net.org/).

## Acknowledgments

This work is supported by the National Key Research and Development Program (Grant No. 2020AAA0107800), the National Natural Science Foundation of China (Grant No. 62106261, No. 62372453).
