Adaptive and classification method based on brain-like spiking neural network and computing device
By setting the adaptive threshold of the spiking neuron in the SNN algorithm to the median of the current tensor, and combining the charging, discharging, and resetting equations, the problems of time-consuming threshold setting and low generalization performance in the prior art are solved, and efficient improvement in classification accuracy is achieved.
Patent Information
- Application Number
- CN202210287881.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-22
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-03-22
AI Technical Summary
In existing SNN algorithms, the threshold setting of spiking neurons relies on experience or experiments, which is time-consuming and has low generalization performance, making it difficult to achieve efficient training and improved classification accuracy for complex network structures.
An adaptive thresholding method is adopted, which sets the pulse firing threshold of the spiking neuron to the median of the current tensor. The activation process of the spiking neuron is defined by charging, discharging and resetting equations, and the parameters are optimized by combining time window module and backpropagation gradient.
It improves the classification accuracy and generalization performance of the SNN algorithm, maintains high classification accuracy, simplifies the threshold setting process, and reduces the need for manual intervention.
Smart Images

Figure CN114881198B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of spiking neural network, and particularly relates to an adaptive and classification method based on a brain-like spiking neural network and a computing device. BACKGROUND
[0002] As the third generation of artificial neural network, spiking neural network (SNN) mainly uses spiking neurons to accept and transmit information. Unlike deep neural network (DNN) which only uses spatial domain information of the network, SNN encodes input information of the network as spatial domain signals and maintains time domain relationship in the signal transmission process. This way of processing information is closer to the real biological nervous system and can better reflect the essence of intelligence. Because of the better biological interpretability, low power consumption, fast speed and high accuracy of training SNN, SNN has attracted more and more attention of researchers.
[0003] According to different training methods, SNN can be divided into three types: unsupervised learning, indirect supervised learning and direct supervised learning. Spiking-timing-dependent Plasticity (STDP) algorithm is a representative of unsupervised learning of spiking neural network, and STDP algorithm has been applied to digital recognition and achieved good classification results, but the network is relatively simple and cannot improve the classification performance, and the method only considers the activity of local neurons, which is difficult to meet the training demand of complex network structure. The indirect supervised learning algorithm of SNN refers to the method of converting the Convolutional neural network (CNN) into SNN, that is, converting the trained CNN network parameters into SNN with the same structure. This kind of algorithm first designs a kind of cutting CNN network with similar structure according to the classical CNN network, then trains and updates the parameters of the network to obtain the optimal parameters, and finally imports the obtained parameters into the SNN network structure similar to the cutting CNN structure to obtain the final prediction result. The only difference between the cutting CNN structure and the SNN structure is the activation neuron. The classification accuracy realized by the transition algorithm is very close to that of CNN, and the performance is comparable to that of CNN, but this conversion algorithm depends too much on CNN, which is a replacement of CNN algorithm and can only approach the performance of CNN, but cannot surpass it. In addition, the CNN to SNN algorithm deviates from the original intention of SNN, and is not a good method to explore the learning properties of SNN. The direct supervised learning algorithm of SNN draws on the idea of forward and backpropagation (BP) of CNN and directly trains SNN. In the forward propagation, the activation function in CNN is replaced by the pulse activation function, realizing the functions of charging, discharging and resetting, that is, when the membrane potential exceeds the threshold, a pulse is generated and recorded as 1 and used as the input of the next layer, and then the membrane potential is reset to the initial potential; when the membrane potential does not exceed the threshold, no pulse is generated and recorded as 0 and used as the input of the next layer, and the membrane potential is accumulated in the next time window. In the backpropagation, the gradient replacement function is used to update the parameters. Although this algorithm achieves good classification accuracy, the threshold parameter of charging and discharging directly affects the performance of SNN algorithm. If the threshold is set too large, the pulse emission is less and a larger time window is needed for the accumulation of membrane potential; if the threshold is set too small, the pulse emission is frequent and the classification performance is affected. The threshold setting of this kind of algorithm needs to rely on people's experience or be selected through experiments, which is time-consuming and has low generalization performance. SUMMARY
[0004] The purpose of the present application is to provide a kind of based on brain-like spiking neural network's self-adapting and classification method and computing device for solving the problem of training SNN threshold parameter setting.
[0005] To achieve the above object, the technical scheme adopted by the present application is as follows:
[0006] An adaptive threshold method based on a brain-like spiking neural network, the spiking neural network is configured to input spiking neurons for activation, the activation process includes firing;
[0007] The adaptive threshold method comprises: setting the pulse emission threshold of the spiking neuron to the median of the current tensor; the spiking neuron is configured to fire according to the following firing equation:
[0008]
[0009] Where S(t) is the pulse emitted by the spiking neuron, sign() is the sign function, U(t) is the membrane potential at time t, U th is the pulse emission threshold.
[0010] Further, the activation process further includes reset, and the spiking neuron is configured to reset according to the following reset equation:
[0011] U(t) = U(t)(1-S(t))+U re S(t)
[0012] Where U(t) is the membrane potential at time t, S(t) is the pulse emitted by the spiking neuron, U re is the reset potential.
[0013] Further, the activation process further includes charging, and the spiking neuron charges according to the following charging equation:
[0014]
[0015] Where U(t) is the membrane potential at time t, τ is the membrane time constant, U re is the reset potential, and X(t) is the input of the spiking neuron at time t.
[0016] A classification method based on a spiking neural network, the spiking neural network is preset with spiking neurons, and the pulse emission threshold of the spiking neuron is the median of the current tensor; the classification method comprises:
[0017] Obtain a data set and use it as input of the spiking neural network;
[0018] Perform time window processing on the input cycle to obtain a plurality of pulse values;
[0019] Output a classification result according to the pulse values.
[0020] Further, the spiking neural network comprises a time window module configured to output a spike value based on the spiking neuron, the time window module comprising a CBSA module and a FC module, wherein the CBSA module and the FC module each have a normalization unit and an activation unit, the CBSA unit further having a convolution unit and a pooling unit, and the FC module further having a stretching unit;
[0021] The method of performing the time window processing in cycles comprises:
[0022] S1, sequentially performing convolution, normalization actions on the input, and inputting the spiking neuron for activation, the activation process comprising performing charging, discharging and resetting actions; leaving the membrane potential after the spiking neuron is reset to the next time window for accumulation, and averaging the spikes emitted by the spiking neuron;
[0023] S2, taking the pooled output in S1 as input to perform convolution, normalization and activation operations again to obtain a first output result;
[0024] S3, stretching the first output result to form a two-dimensional tensor, normalizing the two-dimensional tensor, and inputting the spiking neuron for activation, the activation process comprising performing charging, discharging and resetting actions; leaving the membrane potential after the spiking neuron is reset to the next time window for accumulation;
[0025] S4, taking the spikes emitted by the spiking neuron in S3 as input, and performing normalization and activation operations thereon, and taking the emitted spikes after activation as input, and performing normalization and activation operations again to obtain a second output result; performing S1 to S4 in cycles.
[0026] Further, the classification method further comprises: outputting a classification result according to the second output result.
[0027] Further, the classification method further comprises: the spiking neuron performs a charging action according to the following equation:
[0028]
[0029] wherein U(t) is the membrane potential at time t, τ is the membrane time constant, U re is the reset potential, and X(t) is the input of the spiking neuron at time t.
[0030] Further, the classification method further comprises: the spiking neuron performs a discharging action according to the following equation:
[0031]
[0032] Among them, S(t) is the pulse emitted by the spiking neuron, sign() is the sign function, U(t) is the membrane potential at time t, and U th is the pulse emission threshold.
[0033] Furthermore, the classification method further includes: the spiking neuron performs a reset action according to the following equation:
[0034] U(t)=U(t)(1-S(t))+U re S(t)
[0035] Among them, U(t) is the membrane potential at time t, S(t) is the pulse emitted by the spiking neuron, and U re is the reset potential.
[0036] A computing device includes a memory and a processor, wherein the memory stores computer-executable instructions. When the processor executes the computer-executable instructions, the computing device performs the following method:
[0037] Construct a spiking neuron and set its pulse emission threshold to the median of the current tensor; the spiking neuron discharges according to the following equation:
[0038]
[0039] Among them, S(t) is the pulse emitted by the spiking neuron, sign() is the sign function, U(t) is the membrane potential at time t, and U th is the pulse emission threshold.
[0040] The present invention has the advantages that by configuring an adaptive threshold method for the SNN algorithm, not only the pulse neuron threshold problem is solved, but also the high classification accuracy of the SNN algorithm is maintained. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 2 is a schematic diagram of the operation of the pulse neural network provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to better understand the present application by those skilled in the art, more clearly understand the purpose, technical scheme and advantages of the present application, the technical scheme in the embodiments of the present application is described clearly and completely below in combination with specific examples and with reference to the drawings. It should be noted that the implementation mode not shown or described in the drawings is the form known by those skilled in the art. In addition, although this article can provide examples of parameters containing specific values, it should be understood that the parameters do not need to be exactly equal to the corresponding values, but can be approximately equal to the corresponding values within the acceptable error tolerance or design constraints. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the scope of protection of the present application. In addition, the terms "include" and "have" in the specification and claims of the present application and any modification thereof are intended to cover non-exclusive inclusion, for example, a process, method, device, product or equipment containing a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or equipment.
[0044] In one embodiment of the present application, an adaptive threshold method based on brain-like spiking neural network is provided, and the adaptive threshold method includes setting the pulse emission threshold of the pulse neuron as the median of the current tensor. The SNN algorithm based on the adaptive threshold method is taken as an example for specific description:
[0045] In the present embodiment, the SNN algorithm includes the following steps:
[0046] a. Obtain classification data as the input of the SNN network;
[0047] b. Design and build the SNN classification network structure;
[0048] c. Build the pulse neuron activation function, and set the threshold as the median of the current tensor;
[0049] d. Train the neural network, and update the weight parameters by using back propagation;
[0050] e. Evaluate the model on the test data.
[0051] Specifically, the pulse neuron function in step c contains three functions of charging, discharging and resetting. In the present embodiment, LIF (Leaky Integrate-and-Fire) pulse neuron is adopted, and its dynamics is defined as:
[0052]
[0053] where U(t) is the membrane potential at time t, τ is the membrane time constant, U re is the reset potential, and X(t) is the input to the spiking neuron at time t.
[0054] Thus the charging equation for the spiking neuron is:
[0055]
[0056] where U(t) is the membrane potential at time t, τ is the membrane time constant, U re is the reset potential, and X(t) is the input to the spiking neuron at time t.
[0057] The firing equation for the spiking neuron is:
[0058]
[0059] where S(t) is the spike emitted by the spiking neuron, sign() is the sign function, U(t) is the membrane potential at time t, U th is the spike emission threshold, and U th is the current tensor median.
[0060] The reset equation for the spiking neuron is:
[0061] U(t) = U(t)(1-S(t))+U re S(t) (3)
[0062] where U(t) is the membrane potential at time t, S(t) is the spike emitted by the spiking neuron, U re is the reset potential.
[0063] The above equations (1), (2), (3) together constitute the SNN algorithm forward propagation spiking neuron.
[0064] The gradient of the back propagation in step d is replaced by the derivative of the sigmoid function, and the sigmoid function is defined as follows:
[0065]
[0066] Thus the derivative of the sigmoid function σ'(x) = σ(x)(1-σ(x)).
[0067] In this embodiment, as Figure 1As shown, the pulse neural network includes an input module, a time window module, and an output module. The time window module includes a CBSA module and an FC module. The CBSA unit has a convolution unit, a normalization unit, an activation unit, and a pooling unit. The FC module has a stretching unit, a normalization unit, and an activation unit. The activation unit is configured to input a pulse neuron to perform charging, discharging, and resetting actions. The pulse neuron performs corresponding charging, discharging, and resetting actions according to the above formula (1), formula (2), and formula (3). Details are not repeated here.
[0068] The input module is configured to obtain a data set. The time window module is configured to output pulse values based on pulse neurons, and the pulse emission threshold of the pulse neurons is the median of the current tensor. The output module is configured to output a classification result according to the pulse values output by the time window module.
[0069] In an embodiment of the present application, a classification method based on a brain-like pulse neural network is provided. The pulse neural network is preconfigured with pulse neurons, and the pulse emission threshold of the pulse neurons is the median of the current tensor.
[0070] The classification method includes the following steps: first, obtaining a data set and taking it as the input of the pulse neural network. Second, performing time window processing on the input to obtain multiple pulse values. The method of performing time window processing includes: S1, performing convolution, normalization actions on the input in turn, and inputting the pulse neurons for activation. The activation process includes performing charging, discharging, and resetting actions. The membrane potential after the pulse neurons are reset is left to the next time window for accumulation, and the pulses emitted by the pulse neurons are averaged and pooled. S2, taking the pooled output in S1 as the input to perform convolution, normalization, and activation operations again to obtain a first output result. S3, stretching the first output result to form a two-dimensional tensor, normalizing the two-dimensional tensor, and inputting the pulse neurons for activation. The activation process includes performing charging, discharging, and resetting actions. The membrane potential after the pulse neurons are reset is left to the next time window for accumulation. S4, taking the pulses emitted by the pulse neurons in S3 as the input, and performing normalization and activation operations thereon. The pulses emitted after activation are taken as the input, and normalization and activation operations are performed again to obtain a second output result. S1 to S4 are performed in a loop. Finally, a classification result is output according to the second output result. It should be noted that the pulse neurons perform activation operations according to the above formula (1), formula (2), and formula (3) in this embodiment, and details are not repeated here.
[0071] In this embodiment, the parameter settings of the pulse neural network are shown in Table 1:
[0072] Table 1 Parameter settings of the pulse neural network
[0073] Parameters Time window τ U re ]]> Learning rate Batch size Number of training rounds Cosine annealing period Numerical 10 2 0 0.001 100 200 40
[0074] As shown in Figure 1 First, the input module acquires the dataset as input directly.
[0075] Second, the time window module performs a time window cycle for the same input. Take the specific process of performing a time window as an example for description:
[0076] The CBSA module is executed twice in succession. First, the module performs a 3*3 convolution (Con) to maintain the image size unchanged, with an input channel of 1 and an output channel of 128. Then, batch normalization (BN) is performed, followed by spiking action, i.e., charging, discharging, and resetting operations, with the emitted pulses serving as the input for the next step and the reset membrane potential being accumulated for the next time window. Finally, 2*2 average pooling with a step size of 2 is performed on the input pulses. The second time the module is executed, the convolution layer has an input channel of 128 and an output channel of 128, and the remaining steps are the same as the first execution of the module, which will not be repeated here.
[0077] The FC module is executed three times in succession. First, the output of the CBSA module is stretched to form a 2-dimensional tensor. Then, the first execution of the module inputs the 2-dimensional tensor into a linear layer with a parameter setting of (6272, 1024), followed by batch normalization and spiking action, i.e., charging, discharging, and resetting operations, with the discharged pulses serving as the input for the next step and the reset membrane potential being accumulated for the next time window. The second execution of the module inputs the discharged pulses from the previous step into a linear layer with a parameter setting of (1024, 100), and the remaining operations are the same as the first execution of the module, which will not be repeated here. The third execution of the module has a linear layer parameter setting of (100, 10), and the remaining operations are the same as above, which will not be repeated here. Finally, the pulse output of the module serves as the input for the next time window until the end of the last time window, and the pulse output serves as an output within the time window.
[0078] Finally, the output module takes the mean of all pulse outputs of a time window as the final output, and the probability maximum is taken as the final classification result.
[0079] In this embodiment, the parameters used by the training SNN algorithm shown in Table 1 are combined, and the Adam optimizer is used to update the parameters of the SNN during the training process. The specific training steps are as follows:
[0080] a. Obtain the MNIST and Fashion-Mnist dataset;
[0081] b. Build a neural network of the adaptive threshold SNN algorithm according to the network structure shown in FIG. 1, and use the network parameters shown in Table 1; Figure 1
[0082] c. The pulse neuron uses the above-mentioned formula (1), formula (2) and formula (3) to realize the charging, discharging and resetting functions, wherein the threshold U th is set as the median of the current input tensor;
[0083] d. Train the adaptive threshold SNN built on a server with a GPU model of V100 and a memory of 32G, and the final classification result is shown in Table 2:
[0084] Table 2 Classification result
[0085] Dataset MNIST Fashion-Mnist Classification accuracy 99.45% 94.01%
[0086] The idea of the classification method embodiment is the same as the working process of the pulse neural network in the above embodiment, and the entire content of the above pulse neural network embodiment is incorporated into the classification method embodiment by way of full text reference, and will not be repeated.
[0087] In an embodiment of the present application, a computing device is provided, the computing device comprising a memory and a processor, the memory storing computer executable instructions, when the processor executes the computer executable instructions, the computing device executes the following method:
[0088] The pulse emission threshold of the pulse neuron is set as the median of the current tensor; the discharge equation of the pulse neuron is:
[0089]
[0090] Wherein, S(t) is the pulse emitted by the pulse neuron, sign() is the sign function, U(t) is the membrane potential at time t, and U th is the pulse emission threshold.
[0091] The idea of the computing device embodiment is the same as the working process of the classification method in the above embodiment, and the entire content of the above classification method embodiment is incorporated into the computing device embodiment by way of full text reference, and will not be repeated.
[0092] In an embodiment of the present application, a computer readable storage medium is provided, the computer readable storage medium storing a computer program programmed or configured to execute the following method:
[0093] A pulse neuron is constructed and a pulse emission threshold of the pulse neuron is set as a median of the current tensor; wherein a discharge equation of the pulse neuron is:
[0094]
[0095] Wherein S(t) is a pulse emitted by the pulse neuron, sign() is a sign function, U(t) is a membrane potential at t moment, and U th is the pulse emission threshold.
[0096] The idea of the computer readable storage medium embodiment is the same as the working process of the classification method in the above embodiment, and the entire content of the above classification method embodiment is incorporated into the computer readable storage medium embodiment by the way of full text reference, and will not be repeated.
[0097] The above only describes the preferred embodiments of the present application, and does not limit the patent scope, and any equivalent structure or equivalent process transformation made by using the content of the specification and drawings, directly or indirectly applied to other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A classification method based on a spiking neural network, characterized in that, The pulse neural network is preset with a pulse neuron, and a pulse emission threshold of the pulse neuron is a median of a current tensor; the classification method comprises: obtaining a data set and taking the data set as an input of the pulse neural network; performing time window processing on the input cyclically to obtain a plurality of pulse values; outputting a classification result according to the pulse values; the pulse neural network comprises a time window module configured to output a pulse value based on the pulse neuron, the time window module comprising a CBSA module and an FC module, wherein the CBSA module and the FC module each have a normalization unit and an activation unit, the CBSA module further has a convolution unit and a pooling unit, and the FC module further has a stretching unit; the method for cyclically performing the time window processing comprises: S1, sequentially performing convolution, normalization actions on the input, the convolution process keeping the image size unchanged, and inputting the pulse neuron for activation, the activation process comprising performing charging, discharging and resetting actions; leaving the membrane potential after the pulse neuron is reset to the next time window for accumulation, and performing average pooling on the pulses emitted by the pulse neuron; S2, taking the pooled output in S1 as the input to perform convolution, normalization and activation operations again to obtain a first output result; S3, stretching the first output result to form a two-dimensional tensor, normalizing the two-dimensional tensor, and inputting the pulse neuron for activation, the activation process comprising performing charging, discharging and resetting actions; leaving the membrane potential after the pulse neuron is reset to the next time window for accumulation; S4, taking the pulses emitted by the pulse neuron in S3 as the input, and performing normalization and activation operations thereon, then taking the emitted pulses after activation as the input, and performing normalization and activation operations again to obtain a second output result; S1 to S4 are cyclically performed; the pulse neuron performs the discharging action according to the following equation: where S(t) is the spike emitted by the spiking neuron, sign() is the sign function, U(t) is the membrane potential at time t, and U th is the spike emission threshold.
2. The classification method of claim 1, wherein, the classification method further comprises outputting a classification result according to the second output result.
3. The classification method of claim 1, wherein, the classification method further comprises that the pulse neuron performs the charging action according to the following equation: where U(t) is the membrane potential at time t, τ is the membrane time constant, U re is the reset potential, and X(t) is the input to the spiking neuron at time t.
4. The classification method of claim 1, wherein, the classification method further comprises that the pulse neuron performs the resetting action according to the following equation: U(t) = U(t)(l - S(t)) + U re S(t) wherein U(t) is the membrane potential at time t, S(t) is the spike emitted by the spiking neuron, U re is the reset potential.
5. A computing device, comprising: for classifying images, the computing device comprises a memory and a processor, the memory stores computer executable instructions, and when the processor executes the computer executable instructions, the computing device executes the classification method according to any one of claims 1-4 and the following method: constructing a pulse neuron and setting a pulse emission threshold of the pulse neuron as a median of a current tensor; the pulse neuron discharges according to the following equation: Where S(t) is the spike emitted by the spiking neuron, sign() is the sign function, U(t) is the membrane potential at time t, and U th is the spike emission threshold.
Citation Information
Patent Citations
Spiking neural network model building method
CN114092763A