Pulse neural network training method based on adaptive gradient

By adaptively adjusting the width of the proxy gradient in the pulsed neural network and matching the membrane potential dynamics, the problems of gradient vanishing and mismatch are solved, the model performance is improved and energy consumption is reduced.

CN119578468APending Publication Date: 2025-03-07ZHEJIANG UNIV OF TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411646485.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

In the existing pulse neural network training methods, the gradient disappearance or mismatch problem leads to a degradation of model performance, and the alignment between the membrane potential and the proxy gradient cannot be effectively controlled.

Method used

The pulse neural network training method based on adaptive gradients is adopted, and the width of the proxy gradient is correlated with the statistical characteristics of the membrane potential through the correlation function, and the width of the proxy gradient is adaptively adjusted to match the membrane potential dynamics.

Benefits of technology

It effectively alleviates the problem of gradient disappearance or mismatch, improves the performance of the pulsed neural network model, and achieves low energy consumption and high classification performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119578468A_ABST
    Figure CN119578468A_ABST
Patent Text Reader

Abstract

The invention discloses an adaptive gradient-based spiking neural network training method, which comprises the following steps of: firstly, constructing a to-be-trained spiking neural network adopting LIF model neurons, and inputting data set samples into the to-be-trained spiking neural network in batches; then obtaining pre-synaptic inputs of all neurons in each layer and membrane potentials of all neurons in each layer in the spiking neural network to be trained, associating the width of the proxy gradient with statistical characteristics of the membrane potentials through a correlation function, and adaptively adjusting the width of the proxy gradient in each layer; and finally, calculating cross entropy loss of an output layer of the pulse neural network and a sample label, performing gradient back propagation, and updating a synaptic weight. According to the method, the problem of gradient disappearance or mismatching caused by fixed proxy gradient function width is effectively relieved, the energy consumed by single reasoning of the network is less, and the trained network has excellent classification performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of brain-like computing spiking neural networks, and specifically relates to a spiking neural network training method based on adaptive gradient. Background Art

[0002] As a new paradigm that combines biological rationality and computational efficiency, spiking neural networks (SNNs) achieve sparse encoding and asynchronous processing of information by simulating the pulse emission and temporal dynamics of biological neurons. Unlike artificial neural networks (ANNs) that use continuous activation and product operations, spiking neural networks can achieve low-latency reasoning and low-power computing on neuromorphic hardware with their unique discrete pulse emission and accumulation operations. Today, spiking neural networks have shown great potential in many application areas such as image classification, target detection, and target tracking.

[0003] Backpropagation is an effective method for training high-performance spiking neural networks. However, the discontinuity of spiking neurons hinders the direct application of gradient descent in spiking neural networks. To address the non-differentiability of spiking activity, the proxy gradient method uses a smooth curve to distribute the gradient of the output signal into a set of temporally adjacent analog terms. Unfortunately, when the pulse propagates in the spatiotemporal domain, the membrane potential distribution of the neuron will shift and may not be aligned with the gradient obtainable interval of the fixed proxy gradient, resulting in gradient vanishing or mismatching problems. In order to match the membrane potential dynamics with the gradient obtainable interval, researchers have mainly developed two types of methods: (1) membrane potential regulation and (2) proxy gradient optimization. The membrane potential regulation method redistributes the membrane potential of the neuron through a modulator before the neuron is activated, or defines a distribution loss to correct the offset membrane potential, but this relies on a pre-designed modulator, has low operability or requires more parameters. The proxy gradient optimization method responds to the membrane potential dynamics by automatically adjusting the sharpness of the proxy gradient, but ignores whether the updated proxy gradient can match the membrane potential dynamics during training.

[0004] In general, most existing gradient matching methods tend to focus only on the regulation of membrane potential or the optimization of proxy gradients in isolation, which not only increases the model reasoning burden and reduces biological interpretability, but also fails to effectively control the alignment between them during training. Summary of the invention

[0005] The purpose of this application is to provide a pulse neural network training method based on adaptive gradient, to solve the gradient vanishing or mismatching problem faced by existing pulse neural network training, and to improve the performance of the pulse neural network model.

[0006] In order to achieve the above purpose, the technical solution of this application is as follows: A spiking neural network training method based on adaptive gradient, comprising: Construct a spiking neural network to be trained using LIF model neurons, input the data set samples into the spiking neural network to be trained in batches, and perform forward propagation; Obtain the presynaptic inputs of all neurons in each layer of the spiking neural network to be trained; Obtain the membrane potential of all neurons in each layer of the spiking neural network to be trained; The width of the proxy gradient is associated with the statistical characteristics of the membrane potential through a correlation function, and the width of the proxy gradient of each layer is adaptively adjusted; Calculate the cross entropy loss between the output layer of the spiking neural network and the sample label, perform gradient backpropagation, and update the synaptic weights.

[0007] Furthermore, the obtaining of presynaptic inputs of all neurons in each layer of the spiking neural network to be trained includes: The postsynaptic pulse output from the previous layer passes through a convolutional layer to obtain the presynaptic input of the current layer; Normalize the presynaptic input of the current layer, then scale and offset it to get the normalized presynaptic input.

[0008] Furthermore, the normalized presynaptic input is Express, satisfy Distribution, where , , is the number of channels of the convolutional layer, and Indicates The learnable affine transformation parameters of channels, represents a normal distribution, is the neuron's spike firing threshold.

[0009] Furthermore, the obtaining of the membrane potential of all neurons in each layer of the spiking neural network to be trained includes: in, Represents all neurons in the current layer time step membrane potential, Represents the decay factor of the neuron.

[0010] Furthermore, the membrane potential ,when When, meet distribution; when When, meet distributed; in , is the time step, and are learnable affine transformation parameters, represents a normal distribution, is the neuron's spike firing threshold.

[0011] Furthermore, the width of the proxy gradient is associated with the statistical characteristics of the membrane potential through the association function, and the width of each layer of the proxy gradient is adaptively adjusted, including: Set the width of each layer of proxy gradient ,in represents the membrane potential variance.

[0012] The present invention proposes a pulse neural network training method based on adaptive gradient, which has the following beneficial effects compared with the prior art: (1) The correlation function can adaptively adjust the width of the proxy gradient to capture the membrane potential dynamics at different time steps, effectively alleviating the gradient vanishing or mismatching problem caused by the fixed width of the proxy gradient function; (2) The energy consumed by a trained spiking neural network for a single inference is about 20 times lower than that of an artificial neural network with the same structure; (3) Excellent classification performance was achieved on the static datasets CIFAR10, CIFAR100, and Tiny-ImageNet, as well as the neuromorphic dataset CIFAR10-DVS; (4) The width of the proxy gradient is adjusted synchronously through the statistical characteristics of the membrane potential dynamics, providing a stable gradient flow that can effectively accelerate the convergence speed of the pulse neural network without increasing the model inference burden or introducing additional parameters. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 This is a flow chart of the adaptive gradient-based spiking neural network training method for this application. DETAILED DESCRIPTION

[0014] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0015] An embodiment of the present application, such as Figure 1 As shown, a pulse neural network training method based on adaptive gradient is provided, comprising: Step S1: construct a spiking neural network to be trained using LIF model neurons, input the data set samples into the spiking neural network to be trained in batches, and perform forward propagation.

[0016] The neurons of the pulse neural network to be trained in this application adopt the LeakyIntegrate-and-Fire (LIF) model, and its mathematical expression is: The superscript , subscript and Respectively represent Layer, neurons and time steps, , and They represent the presynaptic input, membrane potential and postsynaptic pulse of the neuron respectively. represents the decay factor of the neuron, is the pulse emission threshold of the neuron. The time step T is a hyperparameter, and each batch of data needs to execute T time steps.

[0017] The training method of the present application can be used to train pulse neural networks of any structure, not limited to the specific structure of the pulse neural network. For example, the constructed pulse neural network model to be trained is a ResNet-19 structure, which includes 1 coding layer, 8 ResNet residual block layers, 1 flat layer and 2 fully connected layers. Each ResNet residual block consists of 2 convolutional layers. The residual block layer input passes through 2 convolutional layers in sequence, and then the output is accumulated with the current residual block layer input, and then the binary pulse matrix is ​​output through the neuron as the input of the next layer.

[0018] The first layer is the encoding layer, which uses a convolutional layer with 128 3×3 filters and a step size of 1. The input is a real-valued matrix of batch×T×3×32×32, and the output is a binary pulse matrix of batch×T×128×32×32, where batch represents the number of batches input into the pulse neural network model at one time, and T represents the time step.

[0019] From the second to the fourth layer, each layer performs a ResNet residual block operation in turn. The two convolutional layers of the ResNet residual block use 128 3×3 filters with a step size of 1. The outputs of the second to the fourth layers are all batch×T×128×32×32 binary pulse matrices.

[0020] The fifth layer is the ResNet residual block layer, which uses 256 3×3 filters, a convolutional layer with a stride of 2 and 256 3×3 filters, a convolutional layer with a stride of 1, and the output is a binary impulse matrix of batch×T×256×16×16.

[0021] From the sixth to the seventh layer, each layer performs a ResNet residual block operation in turn. The two convolutional layers of the ResNet residual block use 256 3×3 filters with a step size of 1. The outputs of the sixth to the seventh layers are all batch×T×256×16×16 binary pulse matrices.

[0022] The eighth layer is the ResNet residual block layer, which uses 512 3×3 filters, a convolutional layer with a stride of 2 and 512 3×3 filters, a convolutional layer with a stride of 1, and the output is a binary impulse matrix of batch×T×512×8×8.

[0023] The ninth layer is the ResNet residual block layer, which uses 512 3×3 filters, a convolutional layer with a stride of 1 and 512 3×3 filters, a convolutional layer with a stride of 1, and the output is a binary impulse matrix of batch×T×512×8×8.

[0024] The tenth layer is a flattening layer, which performs a global average pooling on the batch×512×8×8 binary pulse matrix and outputs a batch×T×512 real-valued vector.

[0025] The eleventh layer is a fully connected layer, with an input of a real-valued vector of batch×T×512 and an output of a binary pulse matrix of batch×T×216, that is, the number of output neurons in this layer is 216.

[0026] The twelfth layer is a fully connected layer. The input is a binary pulse matrix of batch×T×216. For the CIFAR10 dataset, the output is a real-valued vector of batch×T×10; for the CIFAR100 dataset, the output is a real-valued vector of batch×T×100.

[0027] Step S2: Obtain the presynaptic inputs of all neurons in each layer of the spiking neural network to be trained.

[0028] The presynaptic inputs of all neurons in each layer of the spiking neural network obey a normal distribution. In this embodiment, the presynaptic input distribution of all neurons in each layer of the spiking neural network to be trained is obtained, including: Step 2.1: Pass the postsynaptic pulse output from the previous layer through a convolutional layer to obtain the presynaptic input of the current layer.

[0029] Specifically, as follows: in Indicates The number of neurons in the layer, Indicates the connection Tier Neuron to Tier The synaptic weights of neurons, Indicates Tier Neuron time steps of presynaptic input, Indicates Tier Neuron time steps of postsynaptic spikes.

[0030] The presynaptic inputs of all neurons in the current layer constitute the presynaptic inputs of the current layer. .

[0031] Step 2.2: Normalize the presynaptic input of the current layer, and then scale and offset it to obtain the normalized presynaptic input.

[0032] Specifically, the normalized presynaptic input , the calculation formula is as follows: in and Represent the presynaptic input of the current layer The mean and variance of is a very small constant that can learn the affine transformation parameters and Initialized to 1 and 0 respectively for scaling and offset .

[0033] Normalized presynaptic input satisfy Distribution, where , , is the number of channels of the convolutional layer, and Indicates The learnable affine transformation parameters of channels, Represents a normal distribution. Distribution This indicates that the normalized presynaptic input is not only determined by the spike firing threshold controlled by the learnable affine transformation parameters and This provides a new perspective on the distribution of presynaptic input.

[0034] Step S3: Obtain the membrane potential of all neurons in each layer of the spiking neural network to be trained.

[0035] In this embodiment, the membrane potential of all neurons in each layer of the spiking neural network to be trained is obtained by: in, Represents all neurons in the current layer time step membrane potential, represents the decay factor of the neuron, express The previous time step.

[0036] when When, meet distribution; when When, meet Distribution; among them , is the time step, and are learnable affine transformation parameters, represents a normal distribution, is the neuron's spike firing threshold.

[0037] distributed It shows that the main reason for the deviation of neuron membrane potential is that the learnable affine transformation in the normalization layer causes the presynaptic input of the neuron to deviate from the expected distribution, thereby affecting the distribution of membrane potential. The membrane potential of all neurons in each layer of the spiking neural network obeys a normal distribution.

[0038] Step S4: Correlate the width of the proxy gradient with the statistical characteristics of the membrane potential through a correlation function, and adaptively adjust the width of each layer of the proxy gradient.

[0039] In a specific embodiment, the correlation function between the width of the proxy gradient and the statistical properties of the membrane potential is expressed as: (1) When When the membrane potential of all neurons in each layer satisfies Distribution. According to the statistical properties of membrane potential dynamics: mean E[ V]= β ¯ n ,variance . Set the width of each layer of proxy gradient , that is, the width of each layer of proxy gradient ,in represents the membrane potential variance.

[0040] (2) When When the membrane potential of all neurons in each layer satisfies Distribution. According to the statistical properties of membrane potential dynamics: mean E[ V]= 1+ β ¯ n ,variance , set the width of each layer of proxy gradient , that is, the width of each layer of proxy gradient ,in represents the membrane potential variance.

[0041] Therefore, this application associates the width of the proxy gradient with the statistical characteristics of the membrane potential through a correlation function, and adaptively adjusts the width of each layer of the proxy gradient, that is, sets the width of each layer of the proxy gradient ,in represents the membrane potential variance.

[0042] in represents the width of the proxy gradient, is a level of learnable affine transformation parameters, the mean E[ V] For adaptive regulation of membrane potential Falling into the gradient obtainable interval [ V tℎ − k 2 , V tℎ + k 2 ] The cumulative probability within .

[0043] The gradient vanishing or mismatching problem faced by spiking neural network training is mainly caused by the fact that the overlapping area between the evolving membrane potential and the gradient obtainable interval of the fixed proxy gradient is too small or too large. On the one hand, the limited overlapping area will cause the membrane potential of a large number of neurons to fall into the saturation region where the approximate derivative is zero, resulting in obstructed gradient propagation. On the other hand, when the overlapping area is saturated, a large number of neurons will contribute inaccurate approximate gradients, which will increase the error with the true gradient.

[0044] The correlation function designed in this embodiment can adaptively adjust the width of the proxy gradient to capture the membrane potential dynamics at different time steps by associating the width of the proxy gradient with the statistical characteristics of the membrane potential, thereby effectively alleviating the probability of neuron gradient disappearance in deep networks.

[0045] In this embodiment, the LIF neuron of the spiking neural network adopts a rectangular proxy gradient function, which is expressed as: The width of the proxy gradient Ensure rectangular function The area is 1, when the membrane potential Fall into the range , then the neuron will contribute The gradient value of .

[0046] In this embodiment, the LIF neuron of the pulse neural network model is constructed, and its attenuation factor The value is 0.2, the pulse emission threshold The value is 0.5.

[0047] Step S5: Calculate the cross entropy loss between the output layer of the spiking neural network and the sample label, perform gradient back propagation, and update the synaptic weights.

[0048] In this embodiment, the output layer of the spiking neural network uses the membrane potential of the neuron as the final task output and calculates the cross entropy loss of the network. , as shown below: in , and Represent the output layer, time step and number of categories of the dataset respectively, and Represent the output signal and sample label vector respectively; Gradient backpropagation is performed through the spatio-temporal backpropagation algorithm (STBP), and synaptic weights are derived according to the chain rule. The gradient is: .

[0049] It should be noted that calculating the loss function, performing gradient back propagation, and updating network parameters are relatively mature technologies in this field and will not be described in detail here.

[0050] Finally, all batches of data set samples are input into the spiking neural network. After forward propagation and backward propagation through the above steps, the spiking neural network training is completed and the parameters of the spiking neural network are obtained. The trained spiking neural network can be used for practical applications.

[0051] In a specific embodiment of the present invention, the pulse neural network is set to train N=150 rounds; for a static image data set, 100 images are input sequentially in each batch; an SGD optimizer with an initial learning rate of 0.1, a momentum of 0.9, and a weight decay of 1e-4 is selected for parameter update; afterscaling annealing is selected to adjust the learning rate, and the learning rate is set to gradually decay to 0 with N=150 rounds.

[0052] The technical solution of this application fully considers the potential factors that cause the deviation of neuronal membrane potential, and establishes a dynamic relationship between the proxy gradient and the membrane potential. By adaptively adjusting the width of the proxy gradient to accurately capture the membrane potential dynamics at different time steps, it can effectively alleviate the probability of neuronal gradient disappearance in deep networks, promote the pulse neural network to search for a better solution space, improve the model generalization ability, and improve the classification performance of the pulse neural network.

[0053] Table 1 is a comparison of the classification accuracy of this embodiment and the prior art solution on different data sets, where the time step is 4. The pulse neural network trained by the present application with the ResNet-19 structure can achieve an accuracy of 95.94% on the CIFAR10 data set and an accuracy of 78.63% on the CIFAR100 data set, which are respectively about 0.61% and 0.89% higher than the best comparative example 5.

[0054] Table 1 Comparative Example 1: RMP-Loss (Regularizing Membrane Potential Distribution for Spiking Neural Networks) method.

[0055] Comparative Example 2: TET (Temporal Efficient Training of Spiking Neural Network via Gradient Re-weighting) method.

[0056] Comparative Example 3: GLIF (A Unified Gated Leaky Integrate-and-Fire Neuron for Spiking Neural Networks) method.

[0057] Comparative Example 4: LSG (Learnable Surrogate Gradient for Direct Training Spiking Neural Networks) method.

[0058] Comparative Example 5: ASGL (Adaptive Smoothing Gradient Learning for Spiking Neural Networks) method.

[0059] Unlike traditional artificial neural networks that use continuous multiplication operations with high computational cost, pulse neural networks trigger sparse addition operations only when they receive pulses, which has the advantages of low latency and low power consumption. Table 2 is an estimate of the energy consumed by the pulse neural network with the ResNet-19 structure trained by the present application method for a single inference on the CIFAR10 dataset. When the time step is 2, the number of addition operations required for a single inference in the present application is 642.79M, while the number of multiplication operations is only 7.08M, which consumes approximately 0.61mJ of energy, which is approximately 4.8% of the artificial neural network (ANN) with the same structure. Furthermore, when the time step is 4 and 6, only 1.07mJ and 1.44mJ of energy are consumed respectively.

[0060] Table 2 The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A pulse neural network training method based on adaptive gradient, characterized in that: The adaptive gradient-based spiking neural network training method comprises: Construct a spiking neural network to be trained using LIF model neurons, input the data set samples into the spiking neural network to be trained in batches, and perform forward propagation; Obtain the presynaptic inputs of all neurons in each layer of the spiking neural network to be trained; Obtain the membrane potential of all neurons in each layer of the spiking neural network to be trained; The width of the proxy gradient is associated with the statistical characteristics of the membrane potential through a correlation function, and the width of the proxy gradient of each layer is adaptively adjusted; Calculate the cross entropy loss between the output layer of the spiking neural network and the sample label, perform gradient backpropagation, and update the synaptic weights.

2. The adaptive gradient-based spiking neural network training method according to claim 1, characterized in that: The step of obtaining the presynaptic inputs of all neurons in each layer of the spiking neural network to be trained includes: The postsynaptic pulse output from the previous layer passes through a convolutional layer to obtain the presynaptic input of the current layer; Normalize the presynaptic input of the current layer, then scale and offset it to get the normalized presynaptic input.

3. The adaptive gradient-based spiking neural network training method according to claim 2, characterized in that: The normalized presynaptic input is express, satisfy Distribution, where , , is the number of channels of the convolutional layer, and Indicates The learnable affine transformation parameters of channels, represents a normal distribution, is the neuron's spike firing threshold.

4. The adaptive gradient-based spiking neural network training method according to claim 1, characterized in that: The step of obtaining the membrane potential of all neurons in each layer of the spiking neural network to be trained includes: in, Represents all neurons in the current layer time step membrane potential, Represents the decay factor of the neuron.

5. The adaptive gradient-based spiking neural network training method according to claim 4, characterized in that: The membrane potential ,when When, meet distribution; when When, meet distributed; in , is the time step, and are learnable affine transformation parameters, represents a normal distribution, is the neuron's spike firing threshold.

6. The adaptive gradient-based spiking neural network training method according to claim 1, characterized in that: The width of the proxy gradient is associated with the statistical characteristics of the membrane potential through the association function, and the width of each layer of the proxy gradient is adaptively adjusted, including: Set the width of each layer of proxy gradient ,in represents the membrane potential variance.

Citation Information

Cited By

  • Impulse neural network image classification method and device based on isomorphic model progressive training

    CN121708357A