Method for converting artificial neural network into spiking neural network

By adopting the pulse neural network model with channel attention mechanism during the conversion process of artificial neural network to pulse neural network, dynamically adjusting the channel weights and solving the problem of accuracy loss during the conversion process through attention mechanism and sparse processing, the high-precision and high-efficiency conversion effect is achieved.

CN119862922APending Publication Date: 2025-04-22SHANGHAI UNIV OF ENG SCI
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411951421.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-22

AI Technical Summary

Technical Problem

The prior art is difficult to improve the accuracy of the conversion process of artificial neural network to pulsed neural network without significantly increasing the computing cost, and there is information loss, which affects the accuracy of the converted pulsed neural network.

Method used

The pulse neural network model adopts the channel attention mechanism, through the convolution layer, the channel attention layer and the LIF activation layer, dynamically adjust the channel weight, focus on important channels, reduce irrelevant calculations, and improve the inference accuracy through attention mechanism and sparse processing.

Benefits of technology

It effectively retains the original information of the artificial neural network, reduces the accuracy loss caused by pulse coding, improves the output accuracy of the pulse neural network, and significantly improves the computing efficiency, making it suitable for operation in resource-limited environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862922A_ABST
    Figure CN119862922A_ABST
Patent Text Reader

Abstract

The invention discloses a method for converting an artificial neural network into a pulse neural network, which belongs to the technical field of neural networks, and is characterized by executing the following steps: step 1, establishing a channel attention pulse neural network model; 2, inputting the data into the model, and performing preprocessing; 3, performing processing and feature extraction on the input data by using an artificial neural network, and converting continuous neural activation values into discrete pulse signals; 4, the channel attention module obtains a feature map after channel weight adjustment; 5, weighting the pulse signal according to the feature map and transmitting the weighted pulse signal to an LIF activation layer; step 6, integrating the pulse signals of each channel by the LIF activation layer to generate final network output; and 7, repeating the steps 2-6, continuously updating the attention weight and the pulse generation parameters, and realizing conversion after iterative optimization of a set number of rounds. The efficiency of converting the artificial neural network into the pulse neural network is improved in combination with a channel attention mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for converting an artificial neural network into a pulse neural network, and belongs to the technical field of neural networks. Background Art

[0002] Artificial neural networks (ANNs) have achieved remarkable success in many artificial intelligence applications (e.g., computer vision, natural language processing, speech recognition, etc.). However, the high power consumption and computational complexity of traditional ANN models limit their application in resource-constrained environments (e.g., mobile devices, edge computing, and embedded systems), especially in scenarios that require high energy efficiency. In addition, the continuous activation function calculation of ANNs is different from the discrete pulse transmission mechanism of biological neurons, resulting in poor adaptability to bionic neuromorphic hardware.

[0003] With the continuous development of artificial intelligence technology, spiking neural network (SNN), as a computing model closer to the biological nervous system, has shown good performance in processing time series data, low-power computing, and adaptability to complex dynamic environments, showing the advantages of low power consumption and high energy efficiency. However, directly designing or training high-precision SNNs is very expensive in terms of computing resources and time costs, and it is usually difficult to achieve the accuracy of ANNs. Therefore, there is a need to convert existing artificial neural networks into spiking neural networks. However, due to the discreteness of pulse signals and the limitations of time encoding methods, the conversion of ANNs to SNNs using existing technologies will result in model information loss, which affects the accuracy of the converted SNNs. This loss of accuracy hinders the widespread application of SNNs.

[0004] Therefore, how to improve the accuracy of the conversion process from artificial neural network to pulse neural network and reduce information loss without significantly increasing the computing cost has become an urgent problem to be solved. Summary of the invention

[0005] The purpose of the present invention is to propose a method for converting an artificial neural network into a spiking neural network in order to solve the technical problems mentioned in the above background technology, so as to more effectively utilize the information in the artificial neural network model and accurately convert it into a spiking neural network while maintaining the performance, thereby obtaining a higher energy efficiency ratio in a resource-constrained environment. The specific technical solution is as follows:

[0006] A method for converting an artificial neural network into a spiking neural network, performing the following steps:

[0007] Step 1: Establish a channel attention pulse neural network model consisting of an input layer, a five-layer convolution module and an output layer, where each convolution module includes a convolution layer, a channel attention layer, and a LIF activation layer;

[0008] Step 2: Input the data into the channel attention spike neural network model and preprocess the data to make it suitable for spike coding;

[0009] Step 3: Use the artificial neural network to be converted to process and extract features from the input data, and convert the continuous neural activation value into a discrete pulse signal through a preset pulse coding to adapt to the pulse characteristics of the pulse neural network;

[0010] Step 4: The channel attention module of the channel attention layer dynamically assigns the weight of each channel according to the characteristics of the input data, and the channel attention pulse neural network model adaptively selects the key channels. By assigning higher weights to important channels, the original information of the artificial neural network is retained during the conversion process, and finally the feature map after the channel weight adjustment is obtained;

[0011] Step 5: In the forward propagation of the spiking neural network, the pulse signal is weighted according to the feature map after channel weight adjustment and transmitted to the LIF activation layer. At this time, only the activated channels will generate pulse signals, and the calculation of the inactivated channels will be skipped, so that the neurons can focus on processing the information on important channels, further reducing the computational overhead;

[0012] Step 6: The LIF activation layer integrates the pulse signals of each channel. Through the screening and sparse processing of the attention mechanism, the neurons in the output layer make more accurate responses based on the core information and generate the final network output, effectively improving the reasoning accuracy of the spiking neural network.

[0013] Step 7: Repeat steps 2 to 6, and perform backpropagation to continuously update the attention weights and pulse generation parameters to adapt to the characteristics of different input data. After a set number of iterative optimization rounds, accurate conversion from artificial neural network to pulse neural network is achieved.

[0014] Furthermore, the convolution layer in step 1 applies multiple convolution kernels to extract different features. Each convolution kernel produces an output channel. Each channel corresponds to a feature, and all sample outputs of each channel are normalized to learn independent stretching and offset parameters for each channel.

[0015] Furthermore, a batch normalization layer is provided after the convolution layer in step 1, and the batch normalization layer normalizes the output of each neuron, so that the input distribution of each neuron is more stable, thereby accelerating the convergence speed of the network.

[0016] Furthermore, the LIF layer in step 1 is a model that simulates the working process of biological neurons. When the membrane potential reaches a certain threshold, the neuron will fire a pulse, and the membrane potential will fall back to the resting potential. When the initial voltage is the resting value and there is input current, V(t) is expressed by the formula:

[0017]

[0018] Furthermore, the output layer in step 1 is a fully connected layer, which expands the output feature map of the convolutional layer into a one-dimensional tensor.

[0019] Furthermore, the preprocessing in step 2 includes standardization and / or regularization of the data.

[0020] Furthermore, the channel attention module in step 4 performs global average pooling and global maximum pooling operations on the input feature map, pools each channel, and obtains the average feature and maximum feature of the channel. Global average pooling can provide averaged global information, and global maximum pooling can provide the most important feature information of each channel.

[0021] Furthermore, the global average pooling and global maximum pooling steps are:

[0022] Step 41: Calculation x max =max i,j (x ijc ), where x ijc is the feature value of the cth channel at position (i, j) in the input feature map x, H is the height of the input feature map, W is the width of the original feature map, x avg is the average feature after the global average pooling operation, x max It is the largest feature after the global maximum pooling operation;

[0023] Step 42: Place the x avg Taking the average value, we get x max Taking the average value, we get The two-dimensional feature map is converted into a one-dimensional vector and input into a fully connected neural network for the following processing: Where FC represents a fully connected neural network, W avg is the weight vector of the fully connected layer for the feature vector after average pooling, W max It is the weight vector of the fully connected layer for the feature vector after maximum pooling;

[0024] Step 43: Use the two weight vectors obtained in step 42 to fuse the weights obtained by the fully connected neural network for the feature maps after average pooling and maximum pooling: W channel =W avg +W max , W channel The tensor is a tensor with one-dimensional feature channels. In order to make W channel The tensor matches the shape of the input feature map x, and W channelThe size of the tensor is expanded to the same size as the input feature map x. express;

[0025] Step 44: Multiply the input feature map x by the channel weight tensor after channel weight processing element by element to obtain the feature map x adjusted by the channel attention mechanism att , the formula is as follows:

[0026] Beneficial effects:

[0027] 1) In the process of converting artificial neural network to pulse neural network, the model of the present invention can better retain important information in the original neural network through the channel attention mechanism, reduce the accuracy loss caused by pulse coding, and thus improve the output accuracy of the pulse neural network.

[0028] 2) The channel attention mechanism allows the model to dynamically adjust channel weights and focus on the channels that have the greatest impact on the output of the pulse neural network, effectively reducing the processing requirements for unimportant channels and irrelevant calculations, thereby alleviating the burden on neurons. This enables the model to achieve high precision while significantly improving computing efficiency, making it suitable for running on resource-limited edge devices or low-power environments.

[0029] 3) The model can adaptively adjust channel weights according to different input data, so that it has stronger generalization ability and robustness when processing diversified inputs, thereby improving the applicability and practical application value of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a schematic diagram of the process of the present invention;

[0031] Figure 2 is an equivalent circuit diagram corresponding to the LIF model in the present invention;

[0032] Figure 3 This is a comparison chart of the accuracy of the present invention and the prior art based on the CIFAR-10 dataset;

[0033] Figure 4 This is a comparison chart of the accuracy of the present invention and the prior art based on the CIFAR-100 dataset;

[0034] Figure 5 This is a comparison chart of the accuracy of the present invention and the prior art based on the ImageNet dataset;

[0035] Figure 6 It is the pulse neural network after conversion in the embodiment. DETAILED DESCRIPTION

[0036] In order to make the technical means, creative features, objectives and effects of the present invention easier to understand, the present invention is further described below in conjunction with specific illustrations and embodiments.

[0037] like Figure 1 As shown, a method for converting an artificial neural network into a spiking neural network performs the following steps:

[0038] Step 1: Establish a channel attention pulse neural network model consisting of an input layer, a five-layer convolution module and an output layer, where each convolution module includes a convolution layer, a channel attention layer, and a LIF activation layer; the convolution layer applies multiple convolution kernels to extract different features, each convolution kernel generates an output channel, each channel corresponds to a feature, and all sample outputs of each channel are normalized, and independent stretching and offset parameters are learned for each channel; a batch normalization layer is set after the convolution layer, and the batch normalization layer normalizes the output of each neuron, making the input distribution of each neuron more stable and accelerating the convergence speed of the network; Figure 2 As shown in the figure, the LIF layer is a model that simulates the working process of biological neurons. When the membrane potential reaches a certain threshold, the neuron will fire a pulse, and the membrane potential will fall back to the resting potential. When the initial voltage is the resting value and there is input current, V(t) is expressed by the formula: The output layer is a fully connected layer that expands the output feature map of the convolutional layer into a one-dimensional tensor;

[0039] Step 2: Input the data into the channel attention spike neural network model and perform preprocessing, which includes standardizing and / or regularizing the data to make the data suitable for spike coding;

[0040] Step 3: Use the artificial neural network to be converted to process and extract features from the input data, and convert the continuous neural activation value into a discrete pulse signal through a preset pulse coding to adapt to the pulse characteristics of the pulse neural network;

[0041] Step 4: The channel attention module of the channel attention layer dynamically assigns the weight of each channel according to the characteristics of the input data, and the channel attention pulse neural network model adaptively selects the key channels. By assigning higher weights to important channels, the original information of the artificial neural network is retained during the conversion process, and finally the feature map after the channel weight adjustment is obtained; the channel attention module performs global average pooling and global maximum pooling operations on the input feature map, pools each channel, and obtains the average feature and maximum feature of the channel. Global average pooling can provide averaged global information, and global maximum pooling can provide the most important feature information of each channel. The steps of global average pooling and global maximum pooling are:

[0042] Step 41: Calculation xmax =max i,j (x ijc ), where x ijc is the feature value of the cth channel at position (i, j) in the input feature map x, H is the height of the input feature map, W is the width of the original feature map, x avg is the average feature after the global average pooling operation, x max It is the largest feature after the global maximum pooling operation;

[0043] Step 42: Place the x avg Taking the average value, we get x max Taking the average value, we get The two-dimensional feature map is converted into a one-dimensional vector and input into a fully connected neural network for the following processing: Where FC represents a fully connected neural network, W avg is the weight vector of the fully connected layer for the feature vector after average pooling, W max It is the weight vector of the fully connected layer for the feature vector after maximum pooling;

[0044] Step 43: Use the two weight vectors obtained in step 42 to fuse the weights obtained by the fully connected neural network for the feature maps after average pooling and maximum pooling: W channel =W avg +W max , W channel The tensor is a tensor with one-dimensional feature channels. In order to make W channel The tensor matches the shape of the input feature map x, and W channel The size of the tensor is expanded to the same size as the input feature map x using W channel express;

[0045] Step 44: Multiply the input feature map x by the channel weight tensor after channel weight processing element by element to obtain the feature map x adjusted by the channel attention mechanism att , the formula is as follows: att =W channel x;

[0046] Step 5: In the forward propagation of the spiking neural network, the pulse signal is weighted according to the feature map after channel weight adjustment and transmitted to the LIF activation layer. At this time, only the activated channels will generate pulse signals, and the calculation of the inactivated channels will be skipped, so that the neurons can focus on processing the information on important channels, further reducing the computational overhead;

[0047] Step 6: The LIF activation layer integrates the pulse signals of each channel. Through the screening and sparse processing of the attention mechanism, the neurons in the output layer make more accurate responses based on the core information and generate the final network output, effectively improving the reasoning accuracy of the spiking neural network.

[0048] Step 7: Repeat steps 2 to 6, and perform backpropagation to continuously update the attention weights and pulse generation parameters to adapt to the characteristics of different input data. After a set number of iterative optimization rounds, accurate artificial neural network to conversion is achieved.

[0049] Embodiment: Select the data sets CIFAR-10, CIFAR-100, and ImageNet respectively, divide the training data set and the test data set into 80% training data and 20% test data, use the VGG-16 artificial neural network with ReLU as the activation function, and train with parameters of learning rate 0.001, batch size 64, and training round number 200, and finally obtain an artificial neural network model with higher accuracy.

[0050] Then replace the ReLU activation function of the artificial neural network model with the spike function of the spiking neural network; normalize the weights of the artificial neural network model and scale the weights to [0,1] to adapt to the input dynamic range of the spiking neural network; set the time step required for the spiking neural network simulation to 100 steps to ensure sufficient propagation of the pulse information; use temporal coding to convert the continuous value input data into a pulse sequence; initialize the neuron membrane potential to 0; decode the output pulse sequence of the spiking neural network and compare it with the output value of the original artificial neural network model, adjust the membrane potential threshold and time step of the spiking neural network to match the performance, and the converted spiking neural network is as follows: Figure 6 shown.

[0051] like Figure 3-Figure 5 The accuracy of the pulse neural network converted by the present invention is significantly better than that of SNN-AP, QCFS, and IC-SNN used in the prior art.

[0052] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the principles and spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for converting an artificial neural network into a spiking neural network, characterized in that: Follow these steps: Step 1: Establish a channel attention spike neural network model consisting of an input layer, a five-layer convolutional module and an output layer, where each convolutional module includes a convolutional layer, a channel attention layer, and a LIF activation layer; Step 2: Input the data into the channel attention spike neural network model and preprocess the data to make it suitable for spike coding; Step 3: Use the artificial neural network to be converted to process and extract features from the input data, and convert the continuous neural activation value into a discrete pulse signal through a preset pulse coding; Step 4: The channel attention module of the channel attention layer dynamically assigns the weight of each channel according to the characteristics of the input data, and the channel attention pulse neural network model adaptively selects the key channels. By assigning higher weights to important channels, the original information of the artificial neural network is retained during the conversion process, and finally the feature map after the channel weight adjustment is obtained; Step 5: In the forward propagation of the spiking neural network, the pulse signal is weighted according to the feature map adjusted by the channel weight and transmitted to the LIF activation layer. At this time, only the activated channels will generate pulse signals, and the calculation of the inactivated channels will be skipped; Step 6: The LIF activation layer integrates the pulse signals of each channel and generates the final network output through screening and sparse processing of the attention mechanism; Step 7: Repeat steps 2 to 6, and perform backpropagation to continuously update the attention weights and pulse generation parameters to adapt to the characteristics of different input data. After a set number of iterative optimization rounds, accurate conversion from artificial neural network to pulse neural network is achieved.

2. The knowledge graph triple verification method according to claim 1, characterized in that: The convolution layer described in step 1 applies multiple convolution kernels to extract different features. Each convolution kernel produces an output channel, each channel corresponds to a feature, and all sample outputs of each channel are normalized to learn independent stretching and offset parameters for each channel.

3. The knowledge graph triple verification method according to claim 1, characterized in that: A batch normalization layer is set after the convolution layer described in step 1. The batch normalization layer normalizes the output of each neuron, making the input distribution of each neuron more stable and accelerating the convergence speed of the network.

4. The knowledge graph triple verification method according to claim 1, characterized in that: The LIF layer described in step 1 is a model that simulates the working process of biological neurons. When the membrane potential reaches a certain threshold, the neuron will fire a pulse, and the membrane potential will fall back to the resting potential. When the initial voltage is the resting value and there is input current, V(t) is expressed by the formula:

5. The knowledge graph triple verification method according to claim 1, characterized in that: The output layer described in step 1 is a fully connected layer that expands the output feature map of the convolutional layer into a one-dimensional tensor.

6. The knowledge graph triple verification method according to claim 1, characterized in that: The preprocessing described in step 2 includes standardization and / or regularization of the data.

7. The knowledge graph triple verification method according to claim 1, characterized in that: The channel attention module described in step 4 performs global average pooling and global maximum pooling operations on the input feature map, pools each channel, and obtains the average feature and maximum feature of the channel. Global average pooling can provide averaged global information, and global maximum pooling can provide the most important feature information of each channel.

8. The knowledge graph triple verification method according to claim 4, characterized in that: The global average pooling and global maximum pooling steps are: Step 41: Calculation x max =max i,j (x ijc ), where x ijc is the feature value of the cth channel at position (i, j) in the input feature map x, H is the height of the input feature map, W is the width of the original feature map, x avg is the average feature after the global average pooling operation, x max It is the largest feature after the global maximum pooling operation; Step 42: Place the x avg Taking the average value, we get x max Taking the average value, we get The two-dimensional feature map is converted into a one-dimensional vector and input into a fully connected neural network for the following processing: Where FC represents a fully connected neural network, W avg is the weight vector of the fully connected layer for the feature vector after average pooling, W max It is the weight vector of the fully connected layer for the feature vector after maximum pooling; Step 43: Use the two weight vectors obtained in step 42 to fuse the weights obtained by the fully connected neural network for the feature maps after average pooling and maximum pooling: W channel =W avg +W max , W channel The tensor is a tensor with one-dimensional feature channels. In order to make W channel The tensor matches the shape of the input feature map x, and W channel The size of the tensor is expanded to the same size as the input feature map x. express; Step 44: Multiply the input feature map x by the channel weight tensor after channel weight processing element by element to obtain the feature map x adjusted by the channel attention mechanism att , the formula is as follows:

Citation Information

Cited By

  • Multi-modal man-machine interaction chip based on adaptive threshold spiking neural network

    CN120780159A

  • Multimodal human-machine interaction chip based on adaptive threshold pulse neural network

    CN120780159B