Spiking neural network training method and system, and electronic device and storage medium
By dividing the sample data into sub-sample data and processing in parallel, the problems of low resource utilization and poor efficiency in pulsed neural network training are solved, and more efficient resource utilization and training speed are achieved.
Patent Information
- Application Number
- PCT/CN2024/120078
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-25
- Filing Date
- 2024-09-20
- Publication Date
- 2025-04-03
AI Technical Summary
During the training process, pulsed neural networks are wasted computing resources and training time is extended due to low resource utilization and poor training efficiency.
By dividing the sample data into sub-sample data and processing the sub-sample data in parallel in the initial pulse neural network, the computing resources of each network data layer are fully utilized to reduce idle time.
Improve the resource utilization and efficiency of pulsed neural network training and reduce training time.
Smart Images

Figure CN2024120078_03042025_PF_FP_ABST
Abstract
Description
Pulse neural network training method, system, electronic device and storage medium Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a pulse neural network training method, system, electronic device and storage medium. Background Art
[0002] A spiking neural network (Spiking Neural Network) is a computational model that simulates the biological nervous system and can process information by simulating the transmission of pulses between neurons.
[0003] In the related technology, pulse neural network training needs to be carried out through multiple layers of data processing layers. However, since the processing performance of pulse neural networks for conventional parallel computing tasks such as matrix transposition and parameter optimization is low, and the pulse neural network accelerator needs to process multiple time steps of training data in each data processing layer in turn during training, each data processing layer will transmit the calculation results to the next data processing layer for further calculation only after all the training data have been processed. As a result, when the current data processing layer is processing data, other data processing layers are idle. This will lead to reduced resource utilization and also reduce the efficiency of pulse neural network training.
[0004] Summary of the Invention
[0005] The main purpose of the embodiments of the present application is to propose a pulse neural network training method, system, electronic device and storage medium, which can improve the efficiency of pulse neural network training while improving resource utilization.
[0006] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a pulse neural network training method, the method comprising: obtaining first sample data, dividing the first sample data into multiple sub-sample data; inputting the multiple sub-sample data into an initial pulse neural network, wherein the initial pulse neural network is provided with multiple network data layers; on any one of the network data layers, processing each of the sub-sample data in sequence according to the chronological order of processing to obtain corresponding sub-sample features, and after obtaining any one of the sub-sample features, inputting the first obtained sub-sample feature into the next layer of the network data layer for processing until multiple target sample features output by the last network data layer are obtained; obtaining multiple cumulative gradients of the initial pulse neural network based on the multiple target sample features, and adjusting the parameters of the initial pulse neural network based on the cumulative gradients to obtain a trained target pulse neural network.
[0007] According to some embodiments of the present application, before inputting the multiple sub-sample data into the initial pulse neural network, it also includes: calling multiple pre-deployed pulse neural network accelerators; calculating the first total resource demand of the initial pulse neural network and the first total resource supply of each pulse neural network accelerator, and obtaining the deployment range of the pulse neural network accelerator according to the first total resource demand divided by the first total resource supply; dividing the initial pulse neural network according to the deployment range to obtain multiple data blocks, and deploying the network data blocks to the pulse neural network accelerator; wherein each of the data blocks includes at least one network data layer.
[0008] According to some embodiments of the present application, after deploying the network data blocks onto the pulse neural network accelerator, it also includes: calling a pre-deployed graphics processor; calculating the first data processing time of the graphics processor for the first sample data, and based on the first data processing time, calculating the proportion of processing time of the graphics processor for processing the first sample data; and determining the parameter adjustment method of the initial pulse neural network based on the processing time proportion.
[0009] According to some embodiments of the present application, calculating the proportion of processing time of the graphics processor for processing the first sample data based on the first data processing time includes: calculating the second data processing time of the pulse neural network accelerator for the first sample data; and obtaining the proportion of processing time of the graphics processor for processing the first sample data by dividing the first data processing time by the second data processing time.
[0010] According to some embodiments of the present application, determining the parameter adjustment method of the initial pulse neural network based on the processing time ratio includes: obtaining a preset time ratio; comparing the processing time ratio with the preset time ratio, if the processing time ratio is less than the preset time ratio, setting the parameter adjustment method of the initial pulse neural network to synchronous adjustment; if the processing time ratio is greater than the preset time ratio, setting the parameter adjustment method of the initial pulse neural network to asynchronous adjustment.
[0011] According to some embodiments of the present application, the parameters of the initial spiking neural network are adjusted based on the accumulated gradient to obtain a trained target spiking neural network, including: if the parameter adjustment method of the initial spiking neural network is synchronous adjustment, stopping the calculation of the spiking neural network accelerator, obtaining the accumulated gradient of each spiking neural network accelerator in turn through the graphics processor, adjusting the parameters of the corresponding spiking neural network accelerator based on the accumulated gradient, and updating the parameters to the initial spiking neural network to obtain the trained target spiking neural network; wherein the parameters of each spiking neural network accelerator are obtained by iteratively updating when processing each first sample data; if the parameter adjustment method of the initial spiking neural network is asynchronous adjustment, obtaining the accumulated gradient of each spiking neural network accelerator in turn through the graphics processor, adjusting the parameters of the spiking neural network accelerator based on the accumulated gradient, and updating the accumulated parameters to the spiking neural network to obtain the trained target spiking neural network.
[0012] According to some embodiments of the present application, adjusting the parameters of the corresponding pulse neural network accelerator based on the accumulated gradient and updating the parameters to the initial pulse neural network to obtain a trained target pulse neural network includes: obtaining parameters from the first storage area of each of the pulse neural network accelerators in sequence through the graphics processor; adjusting the parameters in each first storage area based on the accumulated gradient corresponding to each of the pulse neural network accelerators, and updating the adjusted parameters to the initial pulse neural network to obtain a trained target pulse neural network.
[0013] According to some embodiments of the present application, adjusting the parameters of the pulse neural network accelerator based on the accumulated gradient, and updating the accumulated parameters to the pulse neural network to obtain a trained target pulse neural network, includes: obtaining parameters from the first storage area of each of the pulse neural network accelerators in turn through the graphics processor; adjusting the parameters of each of the pulse neural network accelerators based on the accumulated gradient, and updating the parameters to the first storage area; replacing the mark of the first storage area with the first calculation area at the current moment, so that the first storage area becomes a new first calculation area and after the first calculation area becomes a new first storage area, obtaining the trained target neural network; wherein, the first calculation area is used to perform real-time processing on the sub-sample data in turn.
[0014] According to some embodiments of the present application, obtaining multiple cumulative gradients of the initial spiking neural network based on multiple target sample features includes: based on the sub-sample data corresponding to the multiple target sample features, searching for sub-gradient data corresponding to the sub-sample data in each of the network data layers; and accumulating multiple sub-gradient data corresponding to each of the first sample data in each of the network data layers to obtain multiple cumulative gradients of the initial spiking neural network.
[0015] To achieve the above-mentioned purpose, the second aspect of an embodiment of the present application proposes a pulse neural network training system, which includes: a sub-sample data division module, which is used to obtain first sample data and divide the first sample data into multiple sub-sample data; a sub-sample data input module, which is used to input multiple sub-sample data into an initial pulse neural network, wherein the initial pulse neural network is provided with multiple network data layers; a sub-sample data processing module, which is used to process each sub-sample data in sequence on any one of the network data layers in a chronological order of processing to obtain corresponding sub-sample features, and after obtaining any one of the sub-sample features, input the first obtained sub-sample feature into the next layer of the network data layer for processing until multiple target sample features output by the last network data layer are obtained; a target pulse neural network acquisition module, which is used to obtain multiple cumulative gradients of the initial pulse neural network based on the multiple target sample features, and adjust the parameters of the initial pulse neural network based on the cumulative gradients to obtain a trained target pulse neural network.
[0016] To achieve the above-mentioned purpose, the third aspect of the embodiments of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the pulse neural network training method described in any one of the embodiments of the first aspect of the present application when executing the computer program.
[0017] To achieve the above-mentioned purpose, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the pulse neural network training method described in any one of the embodiments of the first aspect of the present application.
[0018] The spiking neural network training method, system, electronic device, and storage medium proposed in the present application obtain first sample data, divide the first sample data into multiple sub-sample data, and input the multiple sub-sample data into an initial spiking neural network, so that the sub-sample data can be input into the initial spiking neural network in parallel for training, thereby speeding up the training process. The initial spiking neural network is provided with multiple network data layers. Afterwards, on any network data layer, each sub-sample data is processed in sequence according to the chronological order of processing to obtain corresponding sub-sample features. After obtaining any sub-sample feature, the first obtained sub-sample feature is input into the next network data layer for processing, thereby fully utilizing the computing resources of each network data layer and reducing the idle time of each network data layer until multiple target sample features output by the last network data layer are obtained. The cumulative gradient of the initial spiking neural network is obtained based on the multiple target sample features, and the parameters of the initial spiking neural network are adjusted based on the cumulative gradient to obtain a trained target spiking neural network. The present application can improve resource utilization while improving the efficiency of spiking neural network training. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] FIG1 is a schematic diagram of the structure of a spiking neural network training system provided in an embodiment of the present application;
[0020] FIG2 is a flow chart of a spiking neural network training method provided in an embodiment of the present application;
[0021] FIG3 is a diagram of the training process of the first sample data provided in an embodiment of the present application;
[0022] FIG4 is a diagram of a training process of multiple subsample data provided by an embodiment of the present application;
[0023] FIG5 is a flow chart before step S102 in FIG2 ;
[0024] FIG6 is a flow chart after step S203 in FIG5 ;
[0025] FIG7 is a flow chart of calculating the time ratio according to an embodiment of the present application;
[0026] FIG8 is a flow chart of step S303 in FIG6 ;
[0027] FIG9 is a flow chart of adjusting parameters to obtain a target spiking neural network according to an embodiment of the present application;
[0028] FIG10 is a flow chart of synchronization adjustment parameters provided in an embodiment of the present application;
[0029] FIG11 is a flowchart of asynchronous parameter adjustment provided by an embodiment of the present application;
[0030] FIG12 is a flow chart of synchronously adjusting parameters to obtain a target spiking neural network according to an embodiment of the present application;
[0031] FIG13 is a flow chart of asynchronously adjusting parameters to obtain a target spiking neural network according to an embodiment of the present application;
[0032] FIG14 is a flow chart of calculating the initial spiking neural network loss value provided by an embodiment of the present application;
[0033] FIG15 is an overall flow chart of the spiking neural network training method provided in an embodiment of the present application;
[0034] FIG16 is a schematic diagram of the functional modules of a spiking neural network training system provided in an embodiment of the present application;
[0035] FIG17 is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0037] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0039] A spiking neural network (SNN) is a biologically inspired artificial intelligence (AI) neural network model with powerful capabilities for representing spatiotemporal information, processing asynchronous event information, and self-organizing learning. Compared to traditional AI neural networks, spiking neural networks utilize precise pulse-time models and pulse encoding to capture more information and achieve greater computational power. Current spiking neural network accelerators and simulation architectures leverage the high sparsity of input pulse signals and single-bit representation to deliver higher computing power and energy efficiency than conventional AI chips.
[0040] However, during the pulse neural network training process, when training large data samples, it is necessary to perform separate calculations on each network data layer based on multiple time steps. After each network data layer calculates a complete time step, it is transmitted to the next network data layer for calculation. The other network data layers that have not been trained on the data samples will be idle, resulting in a waste of system resources. At the same time, it also reduces the efficiency of pulse neural network training.
[0041] Based on this, the embodiments of the present application provide a pulse neural network training method, system, electronic device and storage medium, which can improve the efficiency of pulse neural network training while improving resource utilization.
[0042] The pulse neural network training method, system, electronic device and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the pulse neural network training system in the embodiments of the present application is described.
[0043] Referring to FIG. 1 , illustratively, the spiking neural network training system includes a controller 101 , a graphics processor 102 , and a spiking neural network accelerator 103 .
[0044] Controller 101 is the system's nerve center and command center. Based on instruction opcodes and timing signals, controller 101 generates operational control signals to control instruction fetching and execution. For example, controller 101 can generate operational control signals to control graphics processor 102 and spiking neural network accelerator 103 to train an initial spiking neural network, resulting in a trained spiking neural network.
[0045] In some embodiments, each spiking neural network training system has a graphics processing unit (GPU) 102 and multiple spiking neural network accelerators 103. It is understandable that the current spiking neural network accelerator 103 and simulation architecture have a natural advantage in processing pulse signals, but when processing conventional parallel computing tasks such as matrix transposition and parameter optimization, the performance is often far lower than that of the GPU 102. In addition, due to the characteristics of the spiking neural network itself, compared to the artificial neural network (ANN), each network data layer of the spiking neural network has to process the calculation of multiple time steps and the storage of intermediate results, which greatly increases the amount of computation and storage requirements.
[0046] Since the computing power that the graphics processor 102 needs to process during the pulse neural network training process is very small compared to the pulse neural network accelerator 103, this application saves the storage of the pulse neural network accelerator 103 by offloading the storage of the pulse neural network state portion with the highest memory demand to the graphics processor 102 for processing. At the same time, the powerful floating-point computing capability of the graphics processor 102 can significantly improve the training speed of the pulse neural network, so that the training task can be completed more quickly. In addition, part of the parallel computing task can be allocated to the graphics processor for processing, and the specific setting is made according to the actual situation. Therefore, the controller 101, a graphics processor 102 and multiple pulse neural network accelerators 103 can form a high-performance pulse neural network training system.
[0047] The pulse neural network training method in the embodiments of the present application can be illustrated by the following examples.
[0048] It should be noted that in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first. Moreover, the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0049] FIG2 is an optional flowchart of a pulse neural network training method provided in an embodiment of the present application. The method in FIG2 may include but is not limited to steps S101 to S104.
[0050] Step S101: Acquire first sample data, and divide the first sample data into a plurality of sub-sample data.
[0051] In some embodiments, the first sample data is training data for training a spiking neural network, and may specifically be graphic sample data, text sample data, video sample data, biological data, etc. The first sample data may be obtained from a public dataset or acquired in real time.
[0052] In some embodiments, the first sample data can be divided into multiple sub-sample data, and the sub-sample data can be processed in parallel. Specifically, if the first sample data is divided into sub-sample data A and sub-sample data B, then after processing sub-sample data A, the processing results of sub-sample data A can be transmitted to the next network data layer for processing, while sub-sample data B can continue to be processed in the original network data layer. It is not necessary to process the entire first sample data in the original network data layer before transmitting the processing results to the next network data layer for processing, which saves training time and improves the efficiency of spiking neural network training.
[0053] It is understandable that the first sample data can be divided into time window division, feature division, data enhancement division, etc. Furthermore, the first sample data can be analyzed to determine the division method of the first sample data. For example, time window division can be used for EEG signals and speech signals; feature division can be used for pixel values in image data and word vectors in text data; and data enhancement division can be used in some scenarios where sample enhancement is required. By determining the division method of the first sample data, different training requirements and training scenarios can be adapted, and the efficiency of pulse neural network training and the accuracy of the division of the first sample data can be improved.
[0054] Step S102: inputting a plurality of sub-sample data into an initial spiking neural network, wherein the initial spiking neural network is provided with a plurality of network data layers.
[0055] In some embodiments, a spiking neural network (SNN) is an artificial neural network model that simulates the working principles of the nervous system, simulating the pulse transmission and information processing between brain neurons. The initial spiking network is the spiking neural network to be trained. In the initial spiking neural network, multiple first sample data or multiple subsample data are input into the spiking neural network for processing and learning.
[0056] In some embodiments, the network data layer is an important component of the spiking neural network, and each network data layer has specific functions and roles. The network data layer can be divided into an input layer, a hidden layer, and an output layer. Specifically, when the subsample data is input into the initial spiking neural network, it first passes through the input layer. The input layer converts the subsample data into the form of a pulse signal and transmits it in the spiking neural network. Furthermore, the hidden layer is responsible for processing and transforming the information of the input layer. The neurons in the hidden layer receive the pulse signal of the input layer, and calculate and process the pulse signal according to the weights and thresholds of the spiking neural network, and then pass the processed pulse signal to the next layer, namely the output layer. Furthermore, the output layer receives the pulse signal from the hidden layer and converts the pulse signal into the output result of the spiking neural network.
[0057] It is understandable that in addition to the input layer, hidden layer and output layer, the pulse neural network can also include convolutional layers, pooling layers, recursive layers and other network data layers that may need to be involved in the process of training the pulse neural network. The embodiments of the present application do not impose specific restrictions on this.
[0058] Step S103: On any network data layer, each sub-sample data is processed in sequence according to the processing time sequence to obtain the corresponding sub-sample features. After obtaining any sub-sample feature, the sub-sample feature obtained first is input into the next network data layer for processing until multiple target sample features are obtained from the last network data layer.
[0059] It is understandable that in some scenarios with small sample data, the first sample data may not be divided. On any network data layer, the first sample data may be input into the network data layer for processing in sequence. After obtaining at least one sub-sample feature corresponding to the first sample data, the sub-sample feature obtained first is input into the next network data layer for processing. On the original network data layer, the unprocessed first sample data continues to be processed, and then the obtained sub-sample feature is transmitted to the next network data layer for processing until the current first sample data is processed.
[0060] It is understandable that pulse neural networks generally use discrete time steps to simulate the pulse transmission process of neurons. Therefore, during the training process, training will also be carried out according to the time step. For example, in related technologies, sample data is generally trained in each network data layer. After the three steps of the first network data layer are trained and the training results are obtained, the training results are transmitted to the second layer, and training is carried out in sequence to obtain the training results. This training method will result in that during the training process, there is always only one pulse neural network accelerator performing calculations, and the other pulse neural network accelerators are always idle, which will waste a lot of computing resources and reduce the training efficiency of the pulse neural network.
[0061] The present application can process each sub-sample data in sequence on any network data layer in the order of processing time. For example, if the time step is 3, then the present application can transfer the obtained at least one sub-sample feature to the second network data layer after calculating the first time step for the sub-sample data in the first network data layer, and the second network data layer calculates the sub-sample feature transmitted by the first network data layer in the first time step, and so on. At the same time, the first network data layer continues to calculate the second time step for the sub-sample data, and transfers the at least one sub-sample feature obtained in the second time step to the second network data layer for calculation. Through the parallel computing method of the present application, the idle time of each pulse neural network accelerator can be reduced, computing resources can be saved, and the training efficiency of the initial pulse neural network can be improved.
[0062] It can be understood that in the embodiments of the present application, the card number of the SNN accelerator, the serial number of the first sample data or sub-sample data processed, the time step serial number, etc., which are represented by numbers do not refer to specific values, but are only used for distinction and related explanations.
[0063] Please refer to Figure 3. Assume that the time step T is 3, F represents forward calculation, B represents reverse calculation, a represents the card number of the pulse neural network accelerator (SNN accelerator), such as 2 in F2,1,0; b represents the sequence number of the first sample data currently being processed, such as 1 in F2,1,0; c represents the time step sequence number, such as 0 in F2,1,0, and Update represents parameter update. In Figure 3, in the network data layer corresponding to SNN accelerator 0, the first sample data 0 is processed. After 0 time steps of processing, a first sample feature corresponding to F0,0,0 is obtained. This feature is transmitted to the next network data layer for processing, and a first sample feature corresponding to F1,0,0 is obtained. During this period, in the network data layer corresponding to SNN accelerator 0, the first sample data continues to be processed. After 1 time step of processing, a first sample feature corresponding to F0,0,1 is obtained. This feature is transmitted to the next network data layer for processing, and a first sample feature corresponding to F1,0,1 is obtained. The rest of the processing flow is similar to the above and will not be repeated here. It is understandable that when the amount of the first sample data is small, the first sample data does not need to be divided. It is only necessary to obtain the first sample features in real time during the training process and transmit them to the next network data layer for processing. In this way, parallel training of the pulse neural network is achieved, and there is no need to wait until the first sample data is completely processed before transmitting it to the next network data layer for processing, thereby improving the efficiency of the pulse neural network training.
[0064] In some embodiments, in any network data layer, each sub-sample data can be processed separately in the order of processing time, and feature extraction of multiple sub-sample data can be performed at the same time. For example, when sub-sample data A is processed in the first network data layer, the last sub-sample feature is transmitted to the second layer for processing. At the same time, sub-sample data B is started to be processed in the first network data layer. In this way, feature extraction of multiple sub-sample data can be performed at the same time, instead of processing the next sub-sample data after all network data layers have processed one sub-sample data. In this way, processing delay can be reduced, data processing efficiency can be greatly improved, and the training time of the pulse neural network can be shortened.
[0065] It can be understood that further dividing the first sample data to obtain multiple sub-sample data can shorten the training time of the sub-sample data. For example, when sub-sample data A has been reversely calculated, other sub-sample data may be forward calculated in the first network data layer, may be forward calculated in the second network data layer, and so on. In this way, the utilization rate of network resources is greatly improved.
[0066] Please refer to Figure 4. The representation method of each data in Figure 4 is consistent with Figure 3 and will not be repeated here. In Figure 4, in the network data layer corresponding to SNN accelerator 0, such as network data layer 1, sub-sample data 0 is first processed. After 0 time steps of processing, a sub-sample feature corresponding to F0, 0, 0 is obtained, which is transmitted to the next network data layer, such as network data layer 2 for processing, and a sub-sample feature corresponding to F1, 0, 0 is obtained. During this period, in the network data layer 1 corresponding to SNN accelerator 0, the sub-sample data continues to be processed. After 1 time step of processing, a sub-sample feature corresponding to F0, 0, 1 is obtained. It is transmitted to network data layer 2 for processing, and a sub-sample feature corresponding to F1, 0, 1 is obtained. After processing 2 time steps, a subsample feature corresponding to F0, 0, 2 is obtained and transmitted to network data layer 2 for processing. At this time, subsample data 0 is processed in network data layer 1, and network data layer 1 begins processing the next subsample data 1, starting from time step 0 to obtain a subsample feature corresponding to F0, 1, 0, which is transmitted to network data layer 2 for processing, and so on. In this way, the multiple subsample data divided from each first sample data can be processed in parallel, greatly improving the efficiency of the first sample data processing, which is of great significance for training with large amounts of first sample data.
[0067] Step S104: obtaining multiple cumulative gradients of the initial spiking neural network based on multiple target sample features, and adjusting the parameters of the initial spiking neural network based on the cumulative gradients to obtain a trained target spiking neural network.
[0068] It is understood that the cumulative gradient refers to the sub-gradient data of multiple sub-sample data corresponding to each first sample data in each pulse neural network accelerator, and all the sub-gradient data corresponding to the first sample data are accumulated to obtain the cumulative gradient. In the process of training the pulse neural network, after each pulse neural network accelerator completes the training of a sub-sample data, it will obtain the cumulative gradient corresponding to the parameter. After that, the optimization algorithm is used to update the parameters of the pulse neural network according to the cumulative gradient to obtain the trained target pulse neural network. It is understandable that during the training process, the training of the pulse neural network can be stopped by continuously adjusting the parameters until the preset training stop condition is reached, thereby improving the stability and reliability of the network.
[0069] In some embodiments, after obtaining the target sample features output by the last network data layer, that is, after completing the reverse calculation of the current subsample data, multiple subsample data corresponding to the target sample features can be searched, the cumulative gradient of each subsample data at each network data layer can be obtained, and the parameters of each network data layer can be adjusted based on the cumulative gradient. It can be understood that since the last network data layer completes the calculation first, the parameters of the last layer are updated first. For example, if the order of forward calculation is the first layer, the second layer, and the third layer, and the order of reverse calculation is the third layer, the second layer, and the first layer, then the parameters of the third layer are updated first, followed by the second layer and the first layer.
[0070] The spiking neural network training method, system, electronic device, and storage medium proposed in the present application obtain first sample data, divide the first sample data into multiple sub-sample data, and input the multiple sub-sample data into an initial spiking neural network, so that the sub-sample data can be input into the initial spiking neural network in parallel for training, thereby speeding up the training process. The initial spiking neural network is provided with multiple network data layers. Afterwards, on any network data layer, each sub-sample data is processed in sequence according to the chronological order of processing to obtain corresponding sub-sample features. After obtaining any sub-sample feature, the first obtained sub-sample feature is input into the next network data layer for processing, thereby making full use of the computing resources of each network data layer and reducing the idle time of each network data layer until the multiple target sample features output by the last network data layer are obtained. The cumulative gradient of the initial spiking neural network is obtained based on the multiple target sample features, and the parameters of the initial spiking neural network are adjusted based on the cumulative gradient to obtain the trained target spiking neural network. The present application can improve the efficiency of spiking neural network training while improving resource utilization.
[0071] Referring to FIG. 5 , in some embodiments, before step S102 , the steps include but are not limited to steps S201 to S203 :
[0072] Step S201, calling multiple pre-deployed pulse neural network accelerators.
[0073] It is understandable that a spiking neural network accelerator, or SNN accelerator, refers to a hardware accelerator for spiking neural networks. An SNN accelerator can accelerate the simulation and calculation of spiking neural networks. A spiking neural network accelerator typically includes a series of dedicated circuits and processing units for implementing the calculation and communication of spiking neural networks. A spiking neural network accelerator can provide efficient pulse signal transmission and processing capabilities to accelerate the training and inference process of spiking neural networks. The design of a spiking neural network accelerator can be optimized for the characteristics of spiking neural networks, such as supporting highly parallel computing, low power consumption, and high energy efficiency.
[0074] Step S202: Calculate the total first resource requirement of the initial spiking neural network and the total first resource supply of each spiking neural network accelerator, and obtain the deployment range of the spiking neural network accelerator by dividing the total first resource requirement by the total first resource supply.
[0075] In some embodiments, the total first resource requirement of the pulse neural network can be calculated based on the number of neurons in the pulse neural network, or the number of synapses in the pulse neural network, or the input data dimension of the pulse neural network. It can also be calculated based on the number of layers of the pulse neural network and the number of neurons in each layer. This application does not limit the specific calculation method.
[0076] In some embodiments, the first total resource supply of the spiking neural network accelerator can be calculated based on the computing power and performance of the spiking neural network accelerator, or based on the storage capacity of the spiking neural network accelerator, or based on the data transmission bandwidth of the spiking neural network accelerator, or based on the number and speed of the network connections of the spiking neural network accelerator. It is understood that the first total resource supply is not limited to the above calculation method, and the specific calculation method and formula can be adjusted according to the specific system and device.
[0077] In some embodiments, the deployment range of the pulse neural network accelerator can be obtained by dividing the total first resource demand by the total first resource supply. For example, a pulse neural network has 20 layers. By adding the total resource demand of each layer, the total first resource demand is 10 (for ease of understanding, as an example only). The total first resource supply of each pulse neural network accelerator is 2. Then the entire pulse neural network requires 5 pulse neural network accelerators, that is, the deployment range of the pulse neural network accelerator is: each pulse neural network accelerator is deployed corresponding to 4 network data layers. It can be understood that calculating the deployment range of the pulse neural network accelerator can ensure the reasonable allocation of resources and the optimization of performance.
[0078] Furthermore, since the total resource requirements of each layer of the initial pulse neural network may not be the same, the total resource requirements of each network data layer of the initial pulse neural network can be calculated, so that the pulse neural network accelerator can be divided into a more accurate deployment range according to the total resource requirements of each network data layer. For example, the total resource requirements of the third network data layer are twice that of the first network data layer and the second network data layer. Then, a pulse neural network accelerator can be deployed for the first network data layer and the second network data layer, and a pulse neural network accelerator can be deployed separately for the third network data layer, so as to fully utilize the computing resources of the pulse neural network accelerator and avoid the unreasonable allocation of computing resources affecting the training efficiency of the pulse neural network.
[0079] Step S203: Divide the initial pulse neural network according to the deployment range to obtain multiple data blocks, and deploy the network data blocks to the pulse neural network accelerator; wherein each data block includes at least one network data layer.
[0080] In some embodiments, by dividing the initial pulse neural network into multiple data blocks, each data block can be deployed on a pulse neural network accelerator, thereby reasonably allocating the computing range of each pulse neural network accelerator and effectively utilizing the computing resources of the pulse neural network accelerator.
[0081] For example, if it is calculated that the deployment range of the pulse neural network is to deploy a pulse neural network accelerator for every 4 network data layers, the pulse neural network is divided, and every 4 network data layers are a data block, and a pulse neural network accelerator is deployed on each data block.
[0082] Referring to FIG. 6 , in some embodiments, after step S203 , the steps further include but are not limited to steps S301 to S303 :
[0083] Step S301: calling a pre-deployed graphics processor.
[0084] In some embodiments, a graphics processing unit (GPU) is a hardware device used to process images and perform image calculations. The GPU has parallel processing units and high memory bandwidth, and can more efficiently process a large number of parallel computing tasks.
[0085] It is understandable that in the process of calculating the pulse neural network, the parallel computing tasks and the network status of the pulse neural network can be offloaded to the GPU of the pulse neural network training system for processing, thereby saving the storage requirements of the pulse neural network accelerator. At the same time, since the GPU has powerful parallel computing capabilities, it can significantly improve the training speed of the pulse neural network.
[0086] Step S302 : calculating a first data processing time of the graphics processor for the first sample data, and calculating a processing time ratio of the graphics processor for processing the first sample data based on the first data processing time.
[0087] In some embodiments, the first data processing time of the first sample data can be estimated through theoretical calculation based on the processing power of the graphics processor and the data size; or, a test program can be written to input the first sample data into the graphics processor and record the processing time. Alternatively, the computing power required to deploy the GPU can be calculated and then divided by the computing power of the GPU itself to obtain the first data processing time. This application does not specifically limit the calculation method.
[0088] In some embodiments, the second data processing time of the spiking neural network accelerator for the first sample data can be calculated. Specifically, first, the data processing speed of the spiking neural network accelerator and the size of the first sample data need to be obtained to calculate the second data processing time. Furthermore, the processing speed of the spiking neural network accelerator is converted into the amount of data that can be processed per second, for example, 100 frames of image processing per second. The size of the first sample data is divided by the amount of data that can be processed per second to obtain the second data processing time.
[0089] In some embodiments, the proportion of the processing time of the graphics processor processing the first sample data can be calculated by dividing the first data processing time by the second data processing time, thereby determining the time occupied by the graphics processor in performing operations such as parameter adjustment.
[0090] Step S303: Determine a parameter adjustment method for the initial spiking neural network based on the processing time ratio.
[0091] In some embodiments, the performance and efficiency of the spiking neural network can be improved by determining the parameter adjustment method based on the processing time ratio. It is understandable that since the GPU processes the state of the spiking neural network, that is, the GPU adjusts the state of the spiking neural network, if the GPU processing time ratio is too large, it means that the parameter adjustment will take too much time, and the parameters should be adjusted asynchronously. If the GPU processing time ratio is too small, it means that the parameter adjustment will not affect the training process of the spiking neural network, and therefore the parameters can be adjusted synchronously.
[0092] 7 , in some embodiments, calculating the processing time ratio of the graphics processor for processing the first sample data based on the first data processing time includes, but is not limited to, steps S401 to S402:
[0093] Step S401: Calculate the second data processing time of the pulse neural network accelerator for the first sample data.
[0094] In some embodiments, the second data processing time of the spiking neural network accelerator for the first sample data can be calculated. Specifically, the second data processing time can be calculated by obtaining the data processing speed of the spiking neural network accelerator and the size of the first sample data. Furthermore, the processing speed of the spiking neural network accelerator can be converted into the amount of data that can be processed per second, for example, 100 frames of image processing per second. Then, the first sample data can be divided by the amount of data that can be processed per second to obtain the second data processing time.
[0095] Step S402 : Obtain a processing time ratio of the graphics processor for processing the first sample data by dividing the first data processing time by the second data processing time.
[0096] In some embodiments, the processing time ratio of the graphics processor to process the first sample data can be calculated based on the first data processing time divided by the second data processing time, thereby determining the time occupied by the graphics processor when performing operations such as parameter adjustment. For example, if the first data processing time is 1 second and the second data processing time is 10 seconds, then the processing time ratio is 10% divided by 10 seconds. It can be understood that since the graphics processor's processing of the first sample data is a parameter update process, the processing time ratio can be used to determine whether the graphics processor will take too much time to update the parameters of the pulse neural network, thereby determining whether the parameter adjustment method is synchronous adjustment or asynchronous adjustment.
[0097] Referring to FIG. 8 , in some embodiments, step S303 includes but is not limited to steps S501 to S503:
[0098] Step S501: Obtain a preset time ratio.
[0099] In some embodiments, the preset time percentage can be set according to the data volume of the first sample data, or according to the total computing power of the pulse neural network accelerator and the total computing power of the GPU, or can be set by technical personnel, and there is no specific limitation on this.
[0100] In step S502, the processing time ratio is compared with the preset time ratio. If the processing time ratio is less than the preset time ratio, the parameter adjustment mode of the initial spiking neural network is set to synchronous adjustment.
[0101] In some embodiments, since the parameters of the pulse neural network are adjusted through the GPU, the processing time ratio can be compared with the preset time ratio. If the processing time ratio is less than the preset time ratio, such as the processing time ratio is 2% and the preset time ratio is 5%, it means that the time required for adjusting the parameters of the pulse neural network will not affect the normal training of the pulse neural network. Therefore, the parameter adjustment method of the initial pulse neural network can be set to synchronous adjustment.
[0102] Step S503 : If the processing time ratio is greater than the preset time ratio, the parameter adjustment mode of the initial spiking neural network is set to asynchronous adjustment.
[0103] In some embodiments, the processing time ratio can be compared with the preset time ratio. If the processing time ratio is greater than the preset time ratio, such as the processing time ratio is 10% and the preset time ratio is 5%, it means that the parameter adjustment of the pulse neural network takes too much time. If the calculation of the pulse neural network accelerator is stopped and the parameters are adjusted, the efficiency of the pulse neural network training will be affected. Therefore, the parameter adjustment method can be set to asynchronous adjustment to improve the training efficiency.
[0104] Referring to FIG. 9 , in some embodiments, adjusting the parameters of the initial spiking neural network based on the accumulated gradient to obtain a trained target spiking neural network includes, but is not limited to, steps S601 to S602:
[0105] Step S601: If the parameter adjustment method of the initial pulse neural network is synchronous adjustment, stop the calculation of the pulse neural network accelerator, obtain the cumulative gradient of each pulse neural network accelerator in turn through the graphics processor, adjust the parameters of the corresponding pulse neural network accelerator based on the cumulative gradient, and update the parameters to the initial pulse neural network to obtain the trained target pulse neural network; wherein, the parameters of each pulse neural network accelerator are obtained by iteratively updating when processing each first sample data.
[0106] It can be understood that synchronous adjustment means stopping the calculation of the pulse neural network accelerator and adjusting the parameters after each calculation of the first sample data is completed. Synchronous adjustment is suitable for training scenarios where the processing time accounts for a relatively small proportion. Even if the training is stopped to adjust the parameters, it will not have much impact on the training efficiency.
[0107] In some embodiments, in order to prevent the spiking neural network accelerator from occupying too much memory, the cumulative gradient of each spiking neural network accelerator can be obtained through a graphics processor. The parameters of each spiking neural network accelerator are obtained by continuously iteratively updating when processing each sub-sample data. Specifically, when the spiking neural network accelerator processes each sub-sample data, it obtains the gradient information corresponding to each sub-sample data. The cumulative gradient can be obtained by accumulating the gradient information of multiple sub-sample data corresponding to the first sample data. Based on the cumulative gradient, the parameters of the spiking neural network accelerator and the spiking neural network can be updated. After each first sample data is trained, the parameters are updated. Through continuous iterative updates, the performance of the spiking neural network can be optimized.
[0108] Referring to Figure 10 , in some embodiments, W in Figure 10 represents the GPU performing computational processing tasks such as parameter optimization and convolution kernel transposition based on the accumulated gradients calculated by the spiking neural network accelerator. U represents the GPU sending the optimized parameters to the spiking neural network accelerator via a peripheral component interconnect express (PCIE) bus. F represents forward computation, B represents reverse computation, and 0 or n represents the order of computation, such as F0 to Fn representing forward computation from F0, F1, ..., Fn, which are not listed here. As shown in Figure 10 , after the spiking neural network accelerator (SNN accelerator) completes computation on each first sample data, each spiking neural network accelerator stops computing and waits for the GPU to update its parameters. The GPU sequentially calculates the gradients on each spiking neural network accelerator and then adjusts its parameters. Once all parameters are updated, it begins computing the next first sample data. As shown in Figure 10 , during the GPU's parameter calculation and transmission process, the spiking neural network accelerator is idle to prevent interference from the computation on the parameters.
[0109] In step S602, if the parameter adjustment method of the initial pulse neural network is asynchronous adjustment, the cumulative gradient of each pulse neural network accelerator is obtained in sequence through the graphics processor, and the parameters of the pulse neural network accelerator are adjusted based on the cumulative gradient, and the cumulative parameters are updated to the pulse neural network to obtain the trained target pulse neural network.
[0110] It's understandable that asynchronous adjustment is suitable for training scenarios where processing time accounts for a significant portion of the training time. If training is stopped to adjust parameters, a significant amount of time will be spent updating the parameters, thus impacting the training process. Therefore, asynchronous adjustment allows for parameter adjustments without disrupting the normal training process, improving training efficiency.
[0111] In some embodiments, if the parameter adjustment method of the initial spiking neural network is asynchronous adjustment, the cumulative gradient of each spiking neural network accelerator can be obtained one by one through a graphics processing unit (i.e., GPU). Specifically, when each spiking neural network accelerator calculates new sub-sample data, the gradient is accumulated starting from 0, and the accumulated value corresponding to each sub-sample data is stored in the spiking neural network accelerator. The storage method can be to establish an index for storage, establish the same index for each sub-sample data and the corresponding gradient, or to store them in groups. This embodiment of the present application does not impose any specific restrictions on this.
[0112] For example, if the first sample data is divided into sub-sample data 1, sub-sample data 2, and sub-sample data 3, the spiking neural network accelerator 2 accumulates the gradient information of sub-sample data 1, the gradient information of sub-sample data 2, and the gradient information of sub-sample data 3 to obtain the cumulative gradient of the first sample data in the spiking neural network accelerator 2. It is understandable that the calculation method of the first sample data in other spiking neural network accelerators is also the same, and will not be described in detail here.
[0113] It can be understood that after the parameters of each spiking neural network accelerator are updated according to the accumulated gradient, the parameters can be synchronously updated to the initial spiking neural network, thereby obtaining the trained target spiking neural network.
[0114] Please refer to Figure 11. The W in the figure represents the graphics processing unit (GPU) completing parameter optimization, convolution kernel transposition and other computational processing tasks based on the cumulative gradient calculated by the pulse neural network accelerator. U indicates that the graphics processor sends the optimized parameters to the pulse neural network accelerator through the data transmission bus (Peripheral Component Interconnect Express, PCIE), F represents forward calculation, B represents reverse calculation, 0 or n represents the order of calculation, such as F0 to Fn represents forward calculation from F0, F1,..., Fn, which are not listed one by one. After the calculation of a sub-sample data is completed, the graphics processor starts to obtain the gradient and perform parameter optimization calculation. At this time, each pulse neural network accelerator does not stop calculating, but continues to use the original parameters to iterate the calculation of the next sub-sample data, and the gradient starts to accumulate again from 0 until the pulse neural network accelerator completes the iterative calculation of all sub-sample data of the first sample data. Further, the parameters on each pulse neural network accelerator are updated by the GPU. When all pulse neural network accelerators obtain the latest parameters, they start calculating using the new parameters. By adjusting parameters asynchronously, the computing time of the graphics processor and the transmission time of the data transmission bus (Peripheral Component Interconnect Express, PCIE) can be completely hidden, thereby improving the computing efficiency of the pulse neural network accelerator.
[0115] Referring to FIG. 12 , in some embodiments, adjusting the parameters of the corresponding spiking neural network accelerator based on the accumulated gradient and updating the parameters to the initial spiking neural network to obtain a trained target spiking neural network includes, but is not limited to, steps S701 to S702:
[0116] Step S701: Obtain parameters from the first storage area of each pulse neural network accelerator in sequence through the graphics processor.
[0117] It is understandable that a graphics processor can be used to update the parameters in the spiking neural network to alleviate the computing power burden of the spiking neural network accelerator and improve the efficiency of spiking neural network training. During the process of training the spiking neural network by the spiking neural network accelerator, the parameters are stored in the first storage area, and the graphics processor sequentially obtains the parameters from the first storage area of each spiking neural network accelerator.
[0118] Step S702: Based on the accumulated gradient corresponding to each spiking neural network accelerator, adjust the parameters in each first storage area, and update the adjusted parameters to the initial spiking neural network to obtain a trained target spiking neural network.
[0119] In some embodiments, the graphics processor can calculate the loss value using a preset loss function to calculate the target sample features and the reference sample features, calculate the cumulative gradient of each parameter based on the loss value, and adjust and update the parameters of the first storage area based on the cumulative gradient to obtain a trained spiking neural network. In some embodiments, the cumulative gradient can be directly calculated using a spiking neural network accelerator, and the graphics processor can update the parameters of the first storage area in each spiking neural network accelerator.
[0120] 13 , in some embodiments, based on the accumulated gradients, the parameters of the spiking neural network accelerator are adjusted, and the accumulated parameters are updated to the spiking neural network to obtain a trained target spiking neural network, including but not limited to steps S801 to S803:
[0121] Step S801: Obtain parameters from the first storage area of each pulse neural network accelerator in sequence through the graphics processor.
[0122] In some embodiments, a graphics processor can retrieve parameters from the first storage area of each spiking neural network accelerator to facilitate parameter adjustment, with each spiking neural network accelerator corresponding to a first storage area. In some embodiments, the graphics processor is responsible for reading parameters from the first storage area of each spiking neural network accelerator and updating the parameters based on the accumulated gradient.
[0123] Step S802: Adjust the parameters of each pulse neural network accelerator based on the accumulated gradient, and update the parameters to the first storage area.
[0124] In some embodiments, the parameters of each spiking neural network accelerator can be adjusted based on the cumulative gradient of each spiking neural network accelerator, that is, based on the cumulative gradient obtained by summing the subsample data on each spiking neural network accelerator, and the parameters can be updated to the first storage area to facilitate subsequent spiking neural network training based on the updated parameters, thereby continuously improving the performance of the spiking neural network. In some embodiments, the cumulative gradient can be stored in the first storage area or in a separate storage module provided by the system.
[0125] Step S803: Replace the mark of the first storage area with the mark of the first calculation area at the current moment, so that the first storage area becomes the new first calculation area and the first calculation area becomes the new first storage area, and obtain the trained target neural network; wherein, the first calculation area is used to process the sub-sample data in real time in sequence.
[0126] In some embodiments, to ensure that the accumulated parameters are updated without affecting the normal training of the spiking neural network, a first storage area and a first computation area can be provided in each spiking neural network accelerator. During spiking neural network training, the first storage area is used to store the accumulated gradients and parameters of the previous first sample data and asynchronously adjust the parameters of the spiking neural network based on the accumulated gradients. While the parameters of the spiking neural network are asynchronously adjusted, the spiking neural network continues to be trained via the first computation area. After the asynchronous adjustment of the parameters of the spiking neural network is completed and the first computation area has completed training on the new first sample data, the labels of the first computation area and the first storage area are swapped. In other words, the original first computation area is used as the new first storage area, and the original first storage area with updated parameters is used as the new first computation area. This allows the graphics processor to continue asynchronously adjusting the parameters of the spiking neural network based on the new first storage area, and the spiking neural network accelerator to continue training the spiking neural network based on the new first computation area, thereby saving computing time, fully utilizing computing resources, and improving the training efficiency of the spiking neural network.
[0127] Referring to FIG. 14 , in some embodiments, obtaining multiple cumulative gradients of an initial spiking neural network based on multiple target sample features includes, but is not limited to, steps S901 to S902:
[0128] Step S901 : Based on the sub-sample data corresponding to the multiple target sample features, searching for the sub-gradient data corresponding to the sub-sample data in each network data layer.
[0129] In some embodiments, corresponding sub-sample data can be obtained based on the target sample characteristics, and sub-gradient data of the sub-sample data in each network data layer can be found. The sub-gradient data is obtained by calculating each sub-sample data by the pulse neural network accelerator of each network data layer. For example, taking three time steps as the calculation basis, the sub-gradient data corresponding to the sub-sample data is obtained after the pulse neural network accelerator calculates three time steps.
[0130] Step S902: In each network data layer, multiple sub-gradient data corresponding to each first sample data are accumulated to obtain multiple accumulated gradients of the initial spiking neural network.
[0131] It is understood that, in each network data layer, multiple sub-gradient data corresponding to each first sample data can be accumulated. That is, in each network data layer, all sub-gradient data are added together to obtain multiple accumulated gradients of the initial spiking neural network. It is understood that during the training of each spiking neural network on the first sample data, in each spiking neural network accelerator, the parameters are not updated, but the gradients are accumulated starting from 0.
[0132] Exemplarily, the network data layer has three layers. For the first sample data A, it is divided into two sub-sample data, namely sub-sample data a and sub-sample data b. In each layer of the network data layer, for example, in the first layer of the network data layer, sub-sample data a is first trained, and the gradient of sub-sample data a is accumulated from 0. Afterwards, sub-sample data b is trained. At this time, the parameters are not updated. In the process of training sub-sample data b, the parameters of sub-sample data a are used, but the gradient of sub-sample data still accumulates from 0. Finally, for the first layer of the network data layer, the cumulative gradient is the sub-gradient data of sub-sample data a plus the sub-gradient data of sub-sample data b. The cumulative gradient algorithm of the second and third layers of the network data layer is also the same and will not be elaborated here. Thus, multiple cumulative gradients of the initial pulse neural network are obtained, that is, the cumulative gradient corresponding to the first sample data A in each network data layer.
[0133] Please refer to FIG15 , which illustrates an overall description of the technical solution of the present application through an embodiment.
[0134] In some embodiments, the controller can count all current hardware resource conditions, including the total first resource supply of the SNN accelerator (pulse neural network accelerator) and the hardware resource conditions of the GPU (graphics processing unit), including computing resources and storage resources. Afterwards, the total first resource demand required by each network data layer of the initial SNN (initial pulse neural network) is counted. According to the total first resource demand required by the initial SNN divided by the total first resource supply, the deployment range of the network data layer that each SNN accelerator needs to deploy is obtained. According to the deployment range, the initial SNN is sliced, and the divided network data layer mapping is deployed on the SNN accelerator.
[0135] Furthermore, based on the computing power of the SNN accelerator and the GPU, the first data processing time for the GPU to process a first sample of data and the second data processing time for the SNN accelerator to process a first sample of data can be calculated. The processing time ratio of the GPU to process the first sample of data can be calculated by dividing the first data processing time by the second data processing time. Based on the processing time ratio, the parameter update method of the initial spiking neural network can be determined. Furthermore, a first storage area and a first computing area can be allocated in the SNN accelerator to store parameters during the training process.
[0136] It is understandable that when the initial SNN training begins, the GPU needs to be initialized and the first sample data needs to be divided into multiple sub-sample data for training to improve the training efficiency of the initial SNN. The SNN accelerator processes each sub-sample data in sequence according to the chronological order of processing to obtain the corresponding sub-sample features. After obtaining any sub-sample feature, the sub-sample feature obtained first is input into the next layer of network data layer for processing, thereby realizing pipelined parallel calculation of time steps. At the same time, in each network data layer, the gradient of each sub-sample data is accumulated, and the GPU optimizes the parameters of the initial SNN based on the accumulated gradient calculated by the SNN accelerator.
[0137] It is understandable that when optimizing the parameters of an SNN, both synchronous and asynchronous adjustments can be used. Specifically, the judgment is based on the processing time ratio. If the processing time ratio is less than the preset time ratio, it means that the time ratio for parameter updates is very small, and synchronous adjustment can be performed. If the processing time ratio is greater than the preset time ratio, it means that the time ratio for parameter updates is large, and asynchronous adjustment is required to avoid excessive parameter update time, which affects the initial SNN training efficiency.
[0138] In some embodiments, if synchronous adjustment is adopted, the SNN accelerator stops calculation, waits for the parameters to be updated, and then uses the new parameters for training; if asynchronous adjustment is adopted, the SNN accelerator does not update the original parameters after calculating each sub-sample data, and continues to use the original parameters to calculate the next sub-sample data until the calculation of the entire first sample data is completed, and then the parameters of each sub-sample data are accumulated.
[0139] Furthermore, the GPU completes the parameter update of each SNN accelerator through the data transmission bus (Peripheral Component Interconnect Express, PCIE) to obtain the trained target SNN. The SNN accelerator uses the updated parameters to perform the next round of training iterations until it reaches the preset number of iterations or the number of convergences, and then inputs the target SNN to end the training of the pulse neural network.
[0140] Referring to FIG. 16 , an embodiment of the present application further provides a spiking neural network training system that can implement the above-mentioned spiking neural network training method. The spiking neural network training system includes:
[0141] The sub-sample data division module 1601 is configured to obtain first sample data and divide the first sample data into a plurality of sub-sample data;
[0142] A subsample data input module 1602 is configured to input a plurality of subsample data into an initial spiking neural network, wherein the initial spiking neural network is provided with a plurality of network data layers;
[0143] The subsample data processing module 1603 is configured to process each subsample data in sequence on any network data layer in the order of processing time to obtain corresponding subsample features. After obtaining any subsample feature, the subsample feature obtained first is input to the next network data layer for processing until multiple target sample features are output by the last network data layer.
[0144] The target spiking neural network acquisition module 1604 is used to obtain multiple cumulative gradients of the initial spiking neural network based on multiple target sample features, and adjust the parameters of the initial spiking neural network based on the cumulative gradients to obtain a trained target spiking neural network.
[0145] The specific implementation of the spiking neural network training system is substantially the same as the specific embodiment of the spiking neural network training method described above, and will not be described in detail here. Subject to meeting the requirements of the embodiments of this application, the spiking neural network training system may also include other functional modules to implement the spiking neural network training method described in the embodiments above.
[0146] The present application also provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the aforementioned spiking neural network training method when executing the computer program. The electronic device can be any intelligent terminal, such as a tablet computer or an in-vehicle computer.
[0147] Please refer to FIG17 , which illustrates a hardware structure of an electronic device according to another embodiment. The electronic device includes:
[0148] The processor 1701 can be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0149] The memory 1702 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1702 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1702 and is called by the processor 1701 to execute the pulse neural network training method of the embodiments of this application.
[0150] Input / output interface 1703, used to implement information input and output;
[0151] Communication interface 1704, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.);
[0152] Bus 1705 , which transmits information between various components of the device (e.g., processor 1701 , memory 1702 , input / output interface 1703 , and communication interface 1704 );
[0153] The processor 1701 , the memory 1702 , the input / output interface 1703 and the communication interface 1704 are connected to each other in communication within the device via a bus 1705 .
[0154] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned pulse neural network training method.
[0155] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0156] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0157] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0158] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0159] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0160] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0161] It should be understood that in this application, "at least one (item)" and "several" refer to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0162] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of the above units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0163] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0164] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0165] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0166] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A pulse neural network training method, characterized in that: The method comprises: Acquire first sample data, and divide the first sample data into a plurality of sub-sample data; Inputting a plurality of the sub-sample data into an initial spiking neural network, wherein the initial spiking neural network is provided with a plurality of network data layers; On any one of the network data layers, each of the sub-sample data is processed in sequence according to the order of processing time to obtain corresponding sub-sample features, and after any one of the sub-sample features is obtained, the sub-sample features obtained first are input to the next layer of the network data layer for processing, until a plurality of target sample features output by the last network data layer are obtained; Based on the multiple target sample features, multiple cumulative gradients of the initial spiking neural network are obtained, and based on the cumulative gradients, the parameters of the initial spiking neural network are adjusted to obtain a trained target spiking neural network.
2. The pulse neural network training method according to claim 1, characterized in that: Before inputting the plurality of sub-sample data into the initial spiking neural network, the method further includes: Calling multiple pre-deployed spiking neural network accelerators; Calculating a first total resource requirement of an initial spiking neural network and a first total resource supply of each spiking neural network accelerator, and obtaining a deployment range of the spiking neural network accelerator by dividing the first total resource requirement by the first total resource supply; The initial pulse neural network is divided according to the deployment range to obtain multiple data blocks, and the network data blocks are deployed on the pulse neural network accelerator; wherein each of the data blocks includes at least one network data layer.
3. The pulse neural network training method according to claim 2, characterized in that: After the network data is divided into blocks and deployed on the pulse neural network accelerator, the method further includes: Calling the pre-deployed graphics processor; calculating a first data processing time of the graphics processor for the first sample data, and calculating a processing time ratio of the graphics processor for processing the first sample data according to the first data processing time; According to the processing time proportion, a parameter adjustment method of the initial spiking neural network is determined.
4. The pulse neural network training method according to claim 3, characterized in that: The calculating, according to the first data processing time, a proportion of the processing time of the graphics processor processing the first sample data includes: Calculating a second data processing time of the pulse neural network accelerator on the first sample data; The processing time ratio of the graphics processor for processing the first sample data is obtained by dividing the first data processing time by the second data processing time.
5. The pulse neural network training method according to claim 3, characterized in that: The method of adjusting the parameters of the initial spiking neural network according to the processing time ratio includes: Get the preset time ratio; Comparing the processing time ratio with the preset time ratio, if the processing time ratio is less than the preset time ratio, setting the parameter adjustment mode of the initial pulse neural network to synchronous adjustment; If the processing time ratio is greater than the preset time ratio, the parameter adjustment mode of the initial pulse neural network is set to asynchronous adjustment.
6. The pulse neural network training method according to claim 5, characterized in that: The adjusting the parameters of the initial spiking neural network based on the accumulated gradient to obtain a trained target spiking neural network includes: If the parameter adjustment mode of the initial spiking neural network is synchronous adjustment, the calculation of the spiking neural network accelerator is stopped, the accumulated gradient of each spiking neural network accelerator is obtained in sequence through the graphics processor, and the parameters of the corresponding spiking neural network accelerator are adjusted based on the accumulated gradient, and the parameters are updated to the initial spiking neural network to obtain the trained target spiking neural network; wherein the parameters of each spiking neural network accelerator are obtained by iteratively updating when processing each of the first sample data; If the parameter adjustment method of the initial pulse neural network is asynchronous adjustment, the cumulative gradient of each of the pulse neural network accelerators is obtained in turn through the graphics processor, and based on the cumulative gradient, the parameters of the pulse neural network accelerator are adjusted, and the accumulated parameters are updated to the pulse neural network to obtain the trained target pulse neural network.
7. The pulse neural network training method according to claim 6, characterized in that: The step of adjusting the corresponding parameters of the spiking neural network accelerator based on the accumulated gradient and updating the parameters to the initial spiking neural network to obtain a trained target spiking neural network includes: Obtaining parameters from the first storage area of each of the pulse neural network accelerators in sequence by the graphics processor; Based on the accumulated gradient corresponding to each of the pulse neural network accelerators, the parameters in each of the first storage areas are adjusted, and the adjusted parameters are updated to the initial pulse neural network to obtain a trained target pulse neural network.
8. The pulse neural network training method according to claim 6, characterized in that: The method of adjusting the parameters of the spiking neural network accelerator based on the accumulated gradient and updating the accumulated parameters to the spiking neural network to obtain a trained target spiking neural network includes: Obtaining parameters from the first storage area of each of the pulse neural network accelerators in sequence by the graphics processor; Based on the accumulated gradient, adjusting the parameters of each of the pulse neural network accelerators, and updating the parameters to the first storage area; The mark of the first storage area is replaced with the mark of the first calculation area at the current moment, so that the first storage area becomes a new first calculation area and the first calculation area becomes a new first storage area, and a trained target neural network is obtained; wherein, the first calculation area is used to process the sub-sample data in real time in sequence.
9. The pulse neural network training method according to claim 1, characterized in that: The step of obtaining a plurality of accumulated gradients of the initial spike neural network based on the plurality of target sample features comprises: Based on the sub-sample data corresponding to the plurality of target sample features, searching for the sub-gradient data corresponding to the sub-sample data in each of the network data layers; In each of the network data layers, a plurality of the sub-gradient data corresponding to each of the first sample data are accumulated to obtain a plurality of accumulated gradients of the initial spiking neural network.
10. A pulse neural network training system, characterized in that: The system comprises: A sub-sample data division module, used for acquiring first sample data and dividing the first sample data into a plurality of sub-sample data; A sub-sample data input module, used for inputting a plurality of the sub-sample data into an initial spiking neural network, wherein the initial spiking neural network is provided with a plurality of network data layers; A sub-sample data processing module is used to process each of the sub-sample data in sequence on any of the network data layers to obtain corresponding sub-sample features in accordance with the chronological order of processing, and after obtaining any of the sub-sample features, input the first obtained sub-sample feature to the next network data layer for processing, until a plurality of target sample features output by the last network data layer are obtained; The target spiking neural network acquisition module is used to obtain multiple cumulative gradients of the initial spiking neural network based on multiple target sample features, and adjust the parameters of the initial spiking neural network based on the cumulative gradients to obtain a trained target spiking neural network.
11. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the pulse neural network training method according to any one of claims 1 to 9 when executing the computer program.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the pulse neural network training method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Signal processing method for neurons in spiking neural network and network training method
CN113255905A
Training method of spiking neural network
CN114037047A
Training method and training device of spiking neural network
CN115204350A
Pulse neural network training method and system, electronic equipment and storage medium
CN117350355A
Training a multi-stage network to reconstruct mr images
US20220261629A1
Cited By
Model training method, model reasoning method and equipment
CN120409560A