A training method for spiking neural networks

By converting the convolutional neural network into an initial pulse neural network and training on the time and space domains, the problem of too long time steps in the existing methods is solved, and more efficient information transmission is achieved.

CN114037047BActive Publication Date: 2025-08-12PENG CHENG LAB
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111177498.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-09
Publication Date
2025-08-12
Estimated Expiration
2041-10-09

AI Technical Summary

Technical Problem

The existing ANN-to-SNN training method results in a longer time step required for the converted SNN to complete a forward inference, resulting in additional delay and energy consumption.

Method used

Acquire the pre-trained convolutional neural network, convert it into an initial pulse neural network, and train it on the time and space domains to optimize information transmission capabilities.

Benefits of technology

It significantly reduces the time step required to complete one forward inference, improves the information transmission efficiency of the pulsed neural network, and reduces latency and energy consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114037047B_ABST
    Figure CN114037047B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for training a spiking neural network. The method comprises the following steps: obtaining a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network; converting the target convolutional neural network into an initial spiking neural network; and simultaneously training the initial spiking neural network in the time domain and the space domain, and using the trained initial spiking neural network as the target spiking neural network. Since the present invention further trains the spiking neural network in the time domain and the space domain after converting the convolutional neural network into a spiking neural network, the information transmission capability of the spiking neural network in the time domain and the space domain can be further optimized. This solves the problem of the long time step required to complete a forward inference in the SNN obtained by the existing ANN-to-SNN training method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning, and in particular to a training method for a spiking neural network. Background Art

[0002] There are various methods for training spiking neural networks. Among them, the ANN-to-SNN training method has attracted widespread attention due to its promising performance and network scale. Specifically, the ANN-to-SNN training method involves first training an artificial neural network and then converting it into an SNN version with the same network structure. This training approach not only avoids the difficulties faced by directly training an SNN, but also minimizes the performance gap between the converted SNN and the ANN, making it feasible for implementation on large-scale network structures and datasets. However, a problem with current ANN-to-SNN training methods is that the time step required for the converted SNN to complete a forward inference is very large, resulting in additional delays and energy consumption that defeats the original purpose.

[0003] Therefore, the existing technology still needs to be improved and developed. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a training method for a pulse neural network in response to the above-mentioned defects of the prior art, aiming to solve the problem that the SNN obtained by the existing ANN-to-SNN training method requires a long time step to complete a forward reasoning.

[0005] The technical solutions adopted by the present invention to solve the problem are as follows:

[0006] In a first aspect, an embodiment of the present invention provides a method for training a spiking neural network, wherein the method comprises:

[0007] Obtaining a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network;

[0008] Converting the target convolutional neural network into an initial spiking neural network;

[0009] The initial spiking neural network is trained in both the time domain and the space domain, and the trained initial spiking neural network is used as the target spiking neural network.

[0010] In one embodiment, obtaining a target convolutional neural network includes:

[0011] Get a convolutional neural network;

[0012] Obtaining original training data, inputting a training image in the original training data into the convolutional neural network, and generating a prediction vector corresponding to the training image through the convolutional neural network;

[0013] updating the parameters of the convolutional neural network according to the label vector corresponding to the training image and the prediction vector, and continuing to input the training image in the original training data into the convolutional neural network until the training is completed;

[0014] The trained convolutional neural network is used as the target convolutional neural network.

[0015] In one embodiment, obtaining a convolutional neural network includes:

[0016] Get a standard convolutional neural network;

[0017] Determine the structural information corresponding to the standard spiking neural network;

[0018] trimming the standard convolutional neural network according to the structural information to obtain a trimmed convolutional neural network;

[0019] The pruned convolutional neural network is used as the convolutional neural network.

[0020] In one embodiment, the pruning of the standard convolutional neural network according to the structural information includes:

[0021] According to the structural information, an abs function layer is added after the input end of the standard convolutional neural network, and the bias of each convolutional layer and fully connected layer of the standard convolutional neural network is set to zero, and each activation function in the standard convolutional neural network is adjusted to a ReLU activation function, and the maximum pooling layer in the standard convolutional neural network is adjusted to a spatial linear downsampling layer.

[0022] In one embodiment, converting the target convolutional neural network into an initial spiking neural network includes:

[0023] Adding a pulse generation layer after the input end of the target convolutional neural network, and adding a pulse counting layer before the output end of the target convolutional neural network;

[0024] The added target convolutional neural network is used as the initial pulse neural network.

[0025] In one embodiment, the step of adding the pulse generation layer and the pulse counting layer to the target convolutional neural network as the initial spiking neural network includes:

[0026] Using the added target convolutional neural network as a weight-initialized spiking neural network, and replacing each neuron in the weight-initialized spiking neural network with a leaky integral firing neuron;

[0027] The replaced weight-initialized spiking neural network is used as the initial spiking neural network.

[0028] In one embodiment, the simultaneously training the initial spiking neural network in the time domain and the space domain and using the trained initial spiking neural network as the target spiking neural network includes:

[0029] Inputting a training image in the original training data into the initial spiking neural network, and generating an output vector corresponding to the training image through the initial spiking neural network;

[0030] According to the label vector corresponding to the training image and the output vector, the parameters of the initial spiking neural network are updated based on the time domain and the space domain simultaneously, and the step of inputting the training image in the original training data into the initial spiking neural network is continued until the training is completed;

[0031] The initial spiking neural network after training is used as the target spiking neural network.

[0032] In one embodiment, the updating of parameters of the initial spiking neural network based on both the time domain and the spatial domain according to the label vector corresponding to the training image and the output vector includes:

[0033] Determining a loss function based on the label vector corresponding to the training image and the output vector;

[0034] According to the loss function, simultaneously performing backpropagation in the spatial domain and backpropagation in the temporal domain on the initial spiking neural network;

[0035] Parameters of the initial spiking neural network are updated through back propagation in the spatial domain and back propagation in the temporal domain.

[0036] In one embodiment, updating the parameters of the initial spiking neural network through back propagation in the spatial domain and back propagation in the time domain includes:

[0037] Determining a target gradient corresponding to each neuron in the initial spiking neural network through back propagation in the spatial domain and back propagation in the temporal domain;

[0038] Determining a target weight value corresponding to each neuron according to a target gradient corresponding to each neuron;

[0039] The weight of each neuron is updated according to the target weight value corresponding to each neuron.

[0040] In a second aspect, an embodiment of the present invention further provides a pulse neural network, wherein the pulse neural network is trained using any of the pulse neural network training methods described above.

[0041] In a third aspect, an embodiment of the present invention further provides a training device for a spiking neural network, wherein the device comprises:

[0042] A convolutional neural network determination module, configured to obtain a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network;

[0043] A neural network conversion module, configured to convert the target convolutional neural network into an initial spiking neural network;

[0044] The spiking neural network training module is used to train the initial spiking neural network in both the time domain and the space domain, and use the trained initial spiking neural network as the target spiking neural network.

[0045] In a fourth aspect, an embodiment of the present invention further provides a terminal, wherein the terminal includes a memory and one or more processors; the memory stores one or more programs; the program includes instructions for executing any of the pulse neural network training methods described above; and the processor is used to execute the program.

[0046] In a fifth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a plurality of instructions are stored, wherein the instructions are suitable for being loaded and executed by a processor to implement the steps of any of the above-mentioned pulse neural network training methods.

[0047] Beneficial effects of the present invention: The embodiment of the present invention obtains a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network; converts the target convolutional neural network into an initial pulse neural network; and simultaneously trains the initial pulse neural network in the time domain and the space domain, and uses the trained initial pulse neural network as the target pulse neural network. Since the present invention trains the pulse neural network in the time domain and the space domain after converting the convolutional neural network into the pulse neural network, the information transmission capability of the pulse neural network in the time domain and the space domain can be further optimized. This solves the problem that the SNN obtained by the existing ANN-to-SNN training method has a long time step required to complete a forward reasoning. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0049] Figure 1 It is a flowchart of the training method of the pulse neural network provided by an embodiment of the present invention.

[0050] Figure 2 This is a flowchart of information transmission and back propagation of a single neuron provided by an embodiment of the present invention.

[0051] Figure 3 This is a structural diagram of a classic three-layer convolutional neural network provided by an embodiment of the present invention.

[0052] Figure 4 This is a structural diagram of a pruned three-layer convolutional neural network provided by an embodiment of the present invention.

[0053] Figure 5 This is a diagram of the internal modules of the pulse neural network training device provided by an embodiment of the present invention.

[0054] Figure 6 This is a principle block diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solutions and advantages of the present invention more clear and distinct, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0056] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly.

[0057] Spiking Neural Networks (SNNs), hailed as a new generation of neural networks, have attracted widespread attention from scholars due to their rich spatiotemporal dynamics and event-driven features. Spiking neural networks originate from computational neuroscience, and their integration with computer science-based artificial neural networks, represented by deep convolutional neural networks, is considered a promising path for the development of artificial intelligence. Spiking neural networks fully mimic biological neural networks, making them more biologically interpretable. Furthermore, SNNs operate on asynchronous discrete events (or spikes), making their implementation on neuromorphic hardware more energy-efficient.

[0058] The training process of SNNs is significantly more complex than that of traditional convolutional neural networks (CNNs). One factor is their complex spatiotemporal dynamics. Spiking neurons not only receive information from spiking neurons in the previous layer but are also influenced by their own previous time step. Traditional CNNs only transmit information in the spatial dimension, so SNNs can transmit more information than traditional CNNs. Another factor is their event-driven nature, which means that spiking neurons will only fire after the accumulated membrane potential reaches a specified threshold. This threshold-based firing behavior results in non-differentiable spiking activity, which directly increases the complexity of spiking neural network training.

[0059] There are various methods for training spiking neural networks. Among them, the ANN-to-SNN training method has attracted widespread attention due to its promising performance and network scale. Specifically, the ANN-to-SNN training method involves first training an artificial neural network and then converting it into an SNN version with the same network structure. This training approach not only avoids the difficulties faced by directly training an SNN, but also minimizes the performance gap between the converted SNN and the ANN, making it feasible for implementation on large-scale network structures and datasets. However, a problem with current ANN-to-SNN training methods is that the time step required for the converted SNN to complete a forward inference is very large, resulting in additional delays and energy consumption that defeats the original purpose.

[0060] In response to the above-mentioned defects of the prior art, the present invention provides a method for training a pulse neural network, which obtains a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network; converts the target convolutional neural network into an initial pulse neural network; and simultaneously trains the initial pulse neural network in the time domain and the space domain, and uses the trained initial pulse neural network as the target pulse neural network. Since the present invention trains the pulse neural network in the time domain and the space domain after converting the convolutional neural network into a pulse neural network, the information transmission capability of the pulse neural network in the time domain and the space domain can be further optimized. This solves the problem that the SNN obtained by the existing ANN-to-SNN training method has a long time step required to complete a forward reasoning.

[0061] like Figure 1 As shown, the method includes the following steps:

[0062] Step S100: Obtain a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network.

[0063] Specifically, this embodiment has similarities with the traditional ANN-to-SNN training method. Both require first training an artificial neural network and then converting it into an SNN version with the same network structure, thereby avoiding the difficulties faced by direct training of SNN (complex spatiotemporal dynamics).

[0064] In one implementation, step S100 specifically includes the following steps:

[0065] Step S101: obtaining a convolutional neural network;

[0066] Step S102: obtaining original training data, inputting a training image in the original training data into the convolutional neural network, and generating a prediction vector corresponding to the training image through the convolutional neural network;

[0067] Step S103: updating the parameters of the convolutional neural network according to the label vector corresponding to the training image and the prediction vector, and continuing to input the training image in the original training data into the convolutional neural network until the training is completed;

[0068] Step S104: Using the trained convolutional neural network as the target convolutional neural network.

[0069] Specifically, the convolutional neural network in this embodiment is untrained. In order to train it to obtain the target convolutional neural network, this embodiment prepares a certain number of samples in advance, namely the original training data. It can be understood that the original training data contains multiple training images, and each training image contains its corresponding label vector, namely the real label. During training, the training images in the original training data are input into the convolutional neural network. The convolutional neural network will automatically perform reasoning based on the input training images and output its corresponding reasoning results, namely the prediction vectors. Since the reasoning accuracy of the untrained convolutional neural network is not high, there is usually a large gap between the reasoning results it outputs and the real reasoning results, that is, the gap between the prediction vector and the label vector is large. Therefore, it is necessary to compare the gap between the prediction vector and the label vector, and use this gap as a guide to update the parameters of the convolutional neural network to adjust the network parameters of the convolutional neural network. And continue to input other training images in the original training data into the adjusted convolutional neural network model to continue adjusting its network parameters until the gap between the prediction vector output by the adjusted convolutional neural network and the label vector corresponding to the prediction vector is less than the preset threshold, which indicates that the training is completed. The convolutional neural network after training is the target convolutional neural network in this embodiment.

[0070] In one implementation, step S101 specifically includes the following steps:

[0071] Step S1011: obtaining a standard convolutional neural network;

[0072] Step S1012: determining structural information corresponding to the standard spiking neural network;

[0073] Step S1013: trimming the standard convolutional neural network according to the structural information to obtain a trimmed convolutional neural network;

[0074] Step S1014: Use the pruned convolutional neural network as the convolutional neural network.

[0075] In short, the untrained convolutional neural network in this embodiment is actually a pruned convolutional neural network. Specifically, this embodiment first obtains a standard convolutional neural network, such as a traditional VGG16, ResNet50, or other convolutional neural network, and then prunes it according to the structural information corresponding to the standard pulse neural network, so that the pruned convolutional neural network can meet the requirements of the pulse neural network and is closer to the pulse neural network in terms of structural characteristics. The pruned convolutional neural network, that is, the pruned convolutional neural network is used as the convolutional neural network to be trained.

[0076] In one implementation, the step of tailoring the standard convolutional neural network according to the structural information specifically includes the following steps:

[0077] Step S10131: Add an abs function layer after the input end of the standard convolutional neural network according to the structural information, set the bias of each convolutional layer and fully connected layer of the standard convolutional neural network to zero, adjust each activation function in the standard convolutional neural network to a ReLU activation function, and adjust the maximum pooling layer in the standard convolutional neural network to a spatial linear downsampling layer.

[0078] In short, the trimming of the standard convolutional neural network in this embodiment mainly includes four steps: 1) Add an abs function layer after the input end of the standard convolutional neural network, that is, after the preprocessing layer and before the first convolution layer, to convert all inputs to non-negative values; 2) Set the bias of all convolutional layers and fully connected layers in the standard convolutional neural network to zero, because the bias may be positive or negative, which is difficult to represent in the pulse neural network; 3) Replace all activation functions in the standard convolutional neural network with ReLU activation functions, because the activation function in the standard convolutional neural network is usually the Tanh activation function, which may cause negative activation values in the network, and negative input values are difficult to represent in the pulse neural network, so all activation functions are replaced with ReLU activation functions to make all activation values non-negative. 4) Adjust the maximum pooling layer in the standard convolutional neural network to a spatial linear downsampling layer.

[0079] For example, Figure 3 A network A selected for this embodiment is used as a standard convolutional neural network. It is a typical three-layer convolutional neural network that has been used for the classification of the Neovision2 Tower dataset. Network A consists of three convolutional blocks, each of which includes three layers. The first layer is a spatial convolution layer composed of a series of convolution kernels, the second layer is the activation function tanh(), and the third layer is the maximum pooling layer. It should be noted that the last layer of the last block does not use a pooling layer, but a fully connected layer is selected. The entire network of network A is trained using a standard backpropagation algorithm. The pruning process of network A is as follows:

[0080] 1. Add an abs() layer before the first convolutional layer of the convolutional neural network.

[0081] 2. Set the bias of all convolutional layers and fully connected layers of the convolutional neural network to zero.

[0082] 3. Replace the sigmoid activation function of the convolutional neural network with the ReLU activation function.

[0083] 4. Convert the maximum pooling in the convolutional neural network into spatial linear subsampling.

[0084] After the above steps, the pruned convolutional neural network is obtained, that is, the network A' Figure 4 As shown in the figure, for network A', converting the activation function from tanh to ReLU can speed up training and convergence, effectively avoiding the gradient disappearance during training. In addition, the input before the first convolutional layer undergoes an Abs() operation, and the transformation of the activation function ensures that the values transmitted in the network are non-negative, solving the problem that negative values are difficult to represent in spiking neural networks.

[0085] like Figure 1 As shown, the method further includes the following steps:

[0086] Step S200: Convert the target convolutional neural network into an initial spiking neural network.

[0087] Specifically, since the ultimate goal of this embodiment is to obtain a spiking neural network, it is necessary to perform network conversion on the trained target convolutional neural network to convert it into a spiking neural network. Since the performance of the spiking neural network obtained by the initial conversion is poor, this embodiment uses the spiking neural network obtained by the initial conversion as the initial spiking neural network. The performance of the initial spiking neural network needs to be optimized later before it can be put into use.

[0088] In one implementation, step S200 specifically includes the following steps:

[0089] Step S201: adding a pulse generation layer after the input end of the target convolutional neural network, and adding a pulse counting layer before the output end of the target convolutional neural network;

[0090] Step S202: Use the added target convolutional neural network as the initial spiking neural network.

[0091] Specifically, to achieve the conversion between a convolutional neural network and a spiking neural network, this embodiment requires adding a pulse generation layer after the input of the target convolutional neural network. This pulse generation layer can convert the input image into a pulse sequence that meets the format requirements for processing data in the spiking neural network. Furthermore, a pulse counting layer is added before the output of the target convolutional neural network to count the pulse sequence ultimately output by the network. After these additions are complete, the initial spiking neural network is obtained.

[0092] In one implementation, the pulse generating layer is a Poisson pulse generator.

[0093] In one implementation, step S202 specifically includes the following steps:

[0094] Step S2021: Using the added target convolutional neural network as a weighted initialization spiking neural network, and replacing each neuron in the weighted initialization spiking neural network with a leaky integral firing neuron;

[0095] Step S2021: Initialize the spiking neural network with the replaced weights as the initial spiking neural network.

[0096] Specifically, the main difference between SNN and ANN is that the SNN network uses discrete pulse signals instead of the continuous analog signals propagated in the ANN network. In order to generate pulse signals, this embodiment uses the target convolutional neural network with the addition of a pulse generation layer and a pulse counting layer as a weight-initialized pulse neural network, that is, although the weight-initialized pulse neural network has an additional pulse generation layer and a pulse counting layer, the weights of each layer still use the weights trained in the target convolutional neural network, and replace the neurons in the weight-initialized pulse neural network with leaky integral firing neurons (LIF). For LIF neurons, the input signal directly affects its state (membrane potential), and only when the membrane potential rises to the threshold potential will an output signal be generated. Therefore, after replacing the neurons in the weight-initialized pulse neural network with leaky integral firing neurons, an initial pulse neural network is obtained, and the initial pulse neural network can generate discrete pulse signals.

[0097] For example, the general representation of the LIF neuron model is as follows:

[0098]

[0099] Where u(t) is the membrane potential of the neuron at time t, τ is the time constant, I(t) is the external input potential at time t, and when the membrane potential exceeds the given threshold V th When the neuron fires a pulse, the membrane potential resets to its resting potential, V rest .

[0100] Since the spiking neurons have complex spatiotemporal dynamics and need to be back-propagated through the initial spiking neural network in both the time and space domains, the initial spiking neural network is converted into the following iterative format:

[0101]

[0102]

[0103]

[0104]

[0105] In the above formula, t represents the time instant t, n and l(n) represent the number of neurons in the nth layer and the nth layer, and w ij is the synaptic weight between postsynaptic neuron j and presynaptic neuron i, o j =1 means a pulse is issued, otherwise no pulse is issued.

[0106] In addition, the issue of threshold balance needs to be considered. Because the higher the ratio of the threshold to the weight, the longer the neuron takes to activate, thereby reducing the neuron's pulse rate. On the other hand, a relatively low threshold will cause the SNN to lose all its capabilities, causing it to lose the process of membrane voltage integration. In other words, one is over-activation and the other is under-activation, which will affect the conversion accuracy. Therefore, a suitable threshold is important. The study used the threshold balance method to normalize the network weights, setting the threshold to the normalization factor, which is the maximum output of the corresponding convolutional or linear layer.

[0107] like Figure 1 As shown, the method further includes the following steps:

[0108] Step S300: Training the initial spiking neural network in both the time domain and the space domain, and using the trained initial spiking neural network as the target spiking neural network.

[0109] Specifically, since the initial spiking neural network has complex spatiotemporal dynamics, although the initial spiking neural network is converted based on the trained convolutional neural network, since the convolutional neural network is mainly trained in the spatial domain, the performance of the initial spiking neural network in the time domain is not very good. The time step required to complete a forward reasoning is very large, which will generate additional delays and energy consumption. In order to improve the performance of the initial spiking neural network, this embodiment will add another training to the initial spiking neural network. The goal of this training is to simultaneously improve its information transmission capabilities in the time domain and the spatial domain. After the training is completed, the target spiking neural network is obtained, and the network can be directly applied for reasoning.

[0110] In one implementation, step S300 specifically includes the following steps:

[0111] Step S301: inputting a training image in the original training data into the initial spiking neural network, and generating an output vector corresponding to the training image through the initial spiking neural network;

[0112] Step S302: updating the parameters of the initial spiking neural network based on both the time domain and the spatial domain according to the label vector corresponding to the training image and the output vector, and continuing to input the training image in the original training data into the initial spiking neural network until the training is completed;

[0113] Step S303: Using the trained initial spiking neural network as the target spiking neural network.

[0114] Specifically, the training process of the initial spike neural network still uses the original training data used when training the convolutional neural network. During training, the training image in the original training data is input into the initial spike neural network. Since the initial spike neural network contains a pulse generation layer, it is possible to convert the training image into its corresponding pulse sequence. Since the initial spike neural network uses an iterative form of LIF neurons, the pulse sequence entering the initial spike neural network first passes through the first layer of convolution, then passes through the ReLU activation function and determines whether the neuron membrane potential reaches the threshold. If the threshold is reached, a pulse is generated and input to the next layer. The above process needs to be repeated as many times as there are LIF neurons in the initial spike neural network. After the transmitted pulse signal enters the activation function of the last layer, no pulse signal is generated. Instead, a linear transformation of the features is performed through a fully connected layer. Finally, the pulse sequence output by the initial spike neural network is counted within a time window T to obtain the output vector corresponding to the training image.

[0115] Because the initial spiking neural network is converted from a convolutional neural network, its performance in the time and spatial domains is still insufficient, resulting in a certain gap between its output inference results and the actual inference results. However, the label vector corresponding to the training image can be used to reflect the actual inference results corresponding to the training image. Therefore, by comparing the label vector and the output vector, the error in information transmission of the initial spiking neural network in the time and spatial domains can be calculated. The initial spiking neural network is then simultaneously updated based on the parameters of the initial spiking neural network in the time and spatial domains to adjust the network parameters of the initial spiking neural network. The adjusted initial spiking neural network is then iteratively trained in the time and spatial domains based on other training images in the original training data until the gap between the output vector of the adjusted initial spiking neural network and its corresponding standard vector is less than a preset threshold. After training is completed, the target spiking neural network is obtained.

[0116] In one implementation, the updating of parameters of the initial spiking neural network based on the time domain and the spatial domain simultaneously according to the label vector corresponding to the training image and the output vector specifically includes the following steps:

[0117] Step S3021: determining a loss function according to the label vector corresponding to the training image and the output vector;

[0118] Step S3022: performing spatial domain backpropagation and temporal domain backpropagation on the initial spiking neural network simultaneously according to the loss function;

[0119] Step S3023: Update the parameters of the initial spiking neural network through back propagation in the spatial domain and back propagation in the time domain.

[0120] In simple terms, the initial spiking neural network is mainly divided into two stages during training, one is the forward propagation stage, and the other is the back propagation stage. The forward propagation stage is to input the training image into the initial spiking neural network and obtain the output vector corresponding to the training image; while the back propagation stage is to calculate the response error of each neuron of the initial spiking neural network from back to front. In order to realize the training of the initial spiking neural network in both time domain and space domain at the same time, this embodiment needs to determine the loss function based on the label vector and the output vector, and then perform back propagation in both time domain and space domain at the same time (such as Figure 2 As shown), in order to update the parameters of the initial spiking neural network and improve the accuracy of information transmission of the initial spiking neural network in the time domain and the space domain.

[0121] In one implementation, step S3023 specifically includes the following steps:

[0122] Step S30231: Determine the target gradient corresponding to each neuron in the initial spiking neural network through back propagation in the spatial domain and back propagation in the time domain;

[0123] Step S30232: Determine a target weight value corresponding to each neuron according to the target gradient corresponding to each neuron;

[0124] Step S30233: Update the weight of each neuron according to the target weight value corresponding to each neuron.

[0125] Specifically, since the loss function value can reflect the information transmission error of the initial spiking neural network in the time domain and the spatial domain, this embodiment uses the loss function value as a guide to perform backpropagation in the spatial domain and the time domain, and sequentially determines the target gradient corresponding to each neuron in the initial spiking neural network through these two types of backpropagation. Since the weight gradient of a neuron is closely related to its own weight value, after correcting the weight gradient of each neuron to its corresponding target gradient, the target weight value corresponding to each neuron can be calculated based on the target gradient, thereby updating the weight of each neuron.

[0126] For example, the loss function of the initial spike neural network can be expressed as:

[0127]

[0128] Among them, S represents the number of samples, y s Represents the label vector, o s It is the output vector generated by the voting mechanism in the last layer. Combined with the LIF neuron model, we know that L is a function of the weight w. The gradient can be calculated and the parameters can be updated based on the time and space-based backpropagation algorithm.

[0129] The loss function L is used to update the gradient in the time domain and the space domain. The general formula for gradient update is:

[0130]

[0131] To calculate First, you need to calculate and The expression is as follows:

[0132]

[0133]

[0134] so,

[0135]

[0136] According to the iterative format of LIF neurons, So the gradient formula of W is as follows,

[0137]

[0138] In one implementation, due to the non-differentiable nature of spiking neurons, the derivative of the spiking activity is approximated by the function h(u):

[0139]

[0140] Then we get:

[0141]

[0142] The trained target spiking neural network can then be directly put into practical use, similar to traditional artificial neural networks in information processing. Because the target spiking neural network more closely resembles real-world performance, it can be used to learn how biological neural systems work.

[0143] The advantages of the present invention are:

[0144] 1. Traditional spiking neural network training methods have the following limitations: (1) Direct training of spiking neural networks is difficult. Most directly trained spiking neural networks are limited to shallow networks (less than 4 layers). For example, the SpikeProp algorithm only supports single-layer spiking neural networks. (2) The pulse time-dependent plasticity rule only considers local neuronal activity, making it difficult to achieve high performance. (3) Traditional training methods are mostly based on the transmission of information in the spatial domain, ignoring the transmission of information in the temporal dimension. This is the performance bottleneck of traditional spiking neural networks during training.

[0145] 2. This invention avoids the problems of long training cycles and slow convergence of direct spiking neural networks. By using the conversion method, large-scale spiking neural networks can be constructed. In addition, this training method is guided by a global error function, which can achieve global optimization of parameters.

[0146] 3. The present invention uses the trained pruned artificial neural network as the initialization of the spiking neural network, and then performs incremental training on the converted spiking neural network through backpropagation in the spatial and temporal domains, making full use of information transfer in the temporal and spatial domains;

[0147] 4. In traditional training methods, whether the spiking neural network is obtained by direct training or by conversion, since only information transmission in the time domain is considered, more time steps are required during inference. The present invention makes full use of the time domain and the space domain, and the time steps required in the inference stage are 10-15 times less.

[0148] Based on the above embodiment, the present invention further provides a spiking neural network, wherein the spiking neural network is trained using the above-mentioned spiking neural network training method.

[0149] Based on the above embodiments, the present invention also provides a training device for a pulse neural network, such as Figure 5 As shown, the device includes:

[0150] Convolutional neural network determination module 01, used to obtain a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network;

[0151] Neural network conversion module 02, used to convert the target convolutional neural network into an initial spiking neural network;

[0152] The spiking neural network training module 03 is used to train the initial spiking neural network in both the time domain and the space domain, and use the trained initial spiking neural network as the target spiking neural network.

[0153] Based on the above embodiment, the present invention further provides a terminal, whose principle block diagram can be shown as follows: Figure 6 As shown. The terminal includes a processor, a memory, a network interface, and a display screen connected via a system bus. The processor of the terminal is used to provide computing and control capabilities. The memory of the terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a training method for a pulse neural network is implemented. The display screen of the terminal can be a liquid crystal display or an electronic ink display.

[0154] Those skilled in the art will understand that Figure 6 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the solution of the present invention, and does not constitute a limitation on the terminal to which the solution of the present invention is applied. The specific terminal may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0155] In one implementation, one or more programs are stored in a memory of the terminal, and the terminal is configured to be executed by one or more processors, wherein the one or more programs include instructions for performing a training method for a spiking neural network.

[0156] Those skilled in the art will appreciate that all or part of the processes in the above-described embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-described embodiments. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAM bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).

[0157] In summary, the present invention discloses a method for training a pulse neural network, wherein the method obtains a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network; converts the target convolutional neural network into an initial pulse neural network; and simultaneously trains the initial pulse neural network in the time domain and the space domain, and uses the trained initial pulse neural network as the target pulse neural network. Since the present invention trains the pulse neural network in the time domain and the space domain after converting the convolutional neural network into the pulse neural network, the information transmission capability of the pulse neural network in the time domain and the space domain can be further optimized. This solves the problem that the SNN obtained by the existing ANN-to-SNN training method has a long time step required to complete a forward reasoning.

[0158] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A method for training a spiking neural network, characterized in that: The method comprises: Obtaining a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network; Converting the target convolutional neural network into an initial spiking neural network, wherein each neuron in the initial spiking neural network is a leaky integral firing neuron; The initial spiking neural network is trained simultaneously in the time domain and the space domain, and the trained initial spiking neural network is used as the target spiking neural network, including: inputting a training image in the original training data into the initial spiking neural network, and generating an output vector corresponding to the training image through the initial spiking neural network; determining a loss function based on a label vector corresponding to the training image and the output vector; performing back propagation in the space domain and back propagation in the time domain on the initial spiking neural network simultaneously according to the loss function; and updating parameters of the initial spiking neural network through the back propagation in the space domain and the back propagation in the time domain; Among them, the loss function is used to perform gradient updates based on the time domain and space domain. The formula for gradient update is: ; Where L is the loss function; w is the weight; To calculate First, you need to calculate and , the expression is as follows: ; ; in, is the partial derivative of the loss function L with respect to the neuron membrane potential u, which represents the rate of change of the loss function L given a small change in the neuron membrane potential u; is the partial derivative of the loss function L with respect to the neuron output o, which represents the rate of change of the loss function L given a small change in the neuron output o; t represents the time instant t, n and (n) represents the number of neurons in the nth layer and is the synaptic weight between postsynaptic neuron j and presynaptic neuron i, =1 means a pulse is issued, otherwise it means no pulse is issued; According to the iterative format of leaky integrate-fire neurons, =1, , the gradient formula of W is as follows: ; Due to the non-differentiable nature of spiking neurons, the function h(u) is used to approximate the derivative of spiking activity: ; Then we get: 。 2. The method for training a spiking neural network according to claim 1, wherein: The obtaining of the target convolutional neural network includes: Get a convolutional neural network; Obtaining original training data, inputting a training image in the original training data into the convolutional neural network, and generating a prediction vector corresponding to the training image through the convolutional neural network; updating the parameters of the convolutional neural network according to the label vector corresponding to the training image and the prediction vector, and continuing to input the training image in the original training data into the convolutional neural network until the training is completed; The trained convolutional neural network is used as the target convolutional neural network.

3. The method for training a pulse neural network according to claim 2, wherein: The obtaining of the convolutional neural network comprises: Get a standard convolutional neural network; Determine the structural information corresponding to the standard spiking neural network; trimming the standard convolutional neural network according to the structural information to obtain a trimmed convolutional neural network; The pruned convolutional neural network is used as the convolutional neural network.

4. The method for training a pulse neural network according to claim 3, wherein: The tailoring of the standard convolutional neural network according to the structural information includes: According to the structural information, an abs function layer is added after the input end of the standard convolutional neural network, and the bias of each convolutional layer and fully connected layer of the standard convolutional neural network is set to zero, and each activation function in the standard convolutional neural network is adjusted to a ReLU activation function, and the maximum pooling layer in the standard convolutional neural network is adjusted to a spatial linear downsampling layer.

5. The method for training a pulse neural network according to claim 1, wherein: Converting the target convolutional neural network into an initial spiking neural network includes: Adding a pulse generation layer after the input end of the target convolutional neural network, and adding a pulse counting layer before the output end of the target convolutional neural network; The added target convolutional neural network is used as the initial pulse neural network.

6. The method for training a spiking neural network according to claim 5, wherein: The step of adding the pulse generation layer and the pulse counting layer to the target convolutional neural network as the initial spiking neural network includes: Using the added target convolutional neural network as a weight-initialized spiking neural network, and replacing each neuron in the weight-initialized spiking neural network with a leaky integral firing neuron; The replaced weight-initialized spiking neural network is used as the initial spiking neural network.

7. The method for training a spiking neural network according to claim 2, wherein: The step of simultaneously training the initial spiking neural network in the time domain and the space domain and using the trained initial spiking neural network as the target spiking neural network includes: Inputting a training image in the original training data into the initial spiking neural network, and generating an output vector corresponding to the training image through the initial spiking neural network; According to the label vector corresponding to the training image and the output vector, the parameters of the initial spiking neural network are updated based on the time domain and the space domain simultaneously, and the step of inputting the training image in the original training data into the initial spiking neural network is continued until the training is completed; The initial spiking neural network after training is used as the target spiking neural network.

8. The method for training a spiking neural network according to claim 1, wherein: The updating of parameters of the initial spiking neural network by back propagation in the spatial domain and back propagation in the time domain includes: Determining a target gradient corresponding to each neuron in the initial spiking neural network through back propagation in the spatial domain and back propagation in the temporal domain; Determining a target weight value corresponding to each neuron according to a target gradient corresponding to each neuron; The weight of each neuron is updated according to the target weight value corresponding to each neuron.

9. A spiking neural network, characterized in that The pulse neural network is trained using the pulse neural network training method described in any one of claims 1-8.

10. A training device for a pulse neural network, characterized in that: The device comprises: A convolutional neural network determination module, configured to obtain a target convolutional neural network, wherein the target convolutional neural network is a pre-trained convolutional neural network; A neural network conversion module, configured to convert the target convolutional neural network into an initial spiking neural network, wherein each neuron in the initial spiking neural network is a leaky integral firing neuron; a spiking neural network training module, configured to simultaneously train the initial spiking neural network in both the time domain and the space domain, and use the trained initial spiking neural network as a target spiking neural network, comprising: inputting a training image in the original training data into the initial spiking neural network, and generating an output vector corresponding to the training image through the initial spiking neural network; determining a loss function based on a label vector corresponding to the training image and the output vector; performing backpropagation in the space domain and backpropagation in the time domain on the initial spiking neural network based on the loss function; and updating parameters of the initial spiking neural network through the backpropagation in the space domain and the backpropagation in the time domain; Among them, the loss function is used to perform gradient updates based on the time domain and space domain. The formula for gradient update is: ; Where L is the loss function; w is the weight; To calculate First, you need to calculate and , the expression is as follows: ; ; in, is the partial derivative of the loss function L with respect to the neuron membrane potential u, which represents the rate of change of the loss function L given a small change in the neuron membrane potential u; is the partial derivative of the loss function L with respect to the neuron output o, which represents the rate of change of the loss function L given a small change in the neuron output o; t represents the time instant t, n and (n) represents the number of neurons in the nth layer and is the synaptic weight between postsynaptic neuron j and presynaptic neuron i, =1 means a pulse is issued, otherwise it means no pulse is issued; According to the iterative format of leaky integrate-fire neurons, =1, , the gradient formula of W is as follows: ; Due to the non-differentiable nature of spiking neurons, the function h(u) is used to approximate the derivative of spiking activity: ; Then we get: 。 11. A terminal, characterized in that: The terminal includes a memory and one or more processors; the memory stores one or more programs; the programs include instructions for executing the pulse neural network training method as described in any one of claims 1-8; and the processor is used to execute the programs.

12. A computer-readable storage medium having a plurality of instructions stored thereon, characterized in that: The instructions are suitable for being loaded and executed by a processor to implement the steps of the pulse neural network training method described in any one of claims 1-8.