Snn training method and device, storage medium, chip and electronic device
Patent Information
- Application Number
- CN202610327230.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-01
- Publication Date
- 2026-08-21
AI Technical Summary
但是申请人发现该方案训练得到的SNN的推理准确率仍有进步空间
[0037](1)本发明所提出的训练方法所训练出的SNN推理精度更高;
Smart Images

Figure CN122616618A_ABST
Abstract
Description
[0001] This application is a divisional application of Chinese invention patent application 202210763686.4 (title: SNN training method and device, storage medium, chip and electronic device), and this application inherits and enjoys all the rights of the original application. Technical Field
[0002] This invention relates to a method and apparatus for training SNNs, a storage medium, a chip, and an electronic device, specifically to a method and apparatus for training the time constant or decay coefficient of a spiking neural network with an error return allocation strategy in the spatial and temporal domains. Background Technology
[0003] The configuration parameters of a spiking neural network (SNN) typically include synaptic weights, time constants (related to the decay coefficient threshold), and other parameters associated with the spiking neurons. Existing techniques for training spiking neural networks usually only consider the impact of a single time step, neglecting the temporal dependencies between spiking neurons. To address this, prior art 1 proposed a temporal backpropagation strategy that backpropagates errors to the preceding layers of the network. However, the applicant found that the inference accuracy of the SNN trained using this scheme still has room for improvement.
[0004] To address this issue, the applicant proposed a spatiotemporal spiking neural network training method in prior art 2, which effectively overcomes the technical problem. However, this training method only applies to configuration parameters such as synaptic weights, and it is unclear how to train configuration parameters such as time constants in the spatiotemporal domain. The entire technical content of prior art 2 is incorporated herein by reference, and the notation and terminology used in prior art 2 will continue to be used.
[0005] Existing technology 1: Shrestha, SB, & Orchard, G. SLAYER: spike layer error reassignment in time. NeurIPS 2018. (pp.1419-1428).
[0006] Prior art 2: CN114565079 A;
[0007] Prior art 3: CN114372568A.
[0008] There is a pressing need in the field for neuromorphic chips, including SNN processors, to deliver better task performance, which is the primary technical challenge that the field urgently seeks to address. Summary of the Invention
[0009] To solve or alleviate some or all of the above-mentioned technical problems, the present invention is achieved through the following technical solution (the symbol markings in this part may differ by 1 from those in the following text, because the layer number is advanced by one layer after step S6, in order to maintain the continuity of symbol reference):
[0010] A method for training a Sub-Neural Network (SNN) is provided. The SNN to be trained comprises L layers, where L is a positive integer not less than 2, and the Lth layer of the SNN is the output layer. The method includes the following steps: receiving a batch of sample data from the training dataset and using this batch of sample data as the input of the SNN; running the SNN and obtaining its output; calculating the current network loss based on the SNN's output; starting from the output layer of the SNN as the current layer, obtaining the current layer component of the gradient of the network loss with respect to the decay coefficient or time constant in reverse order of the layer numbers; obtaining the gradient of the network loss with respect to the decay coefficient or time constant by summing all layer components of the gradient of the network loss with respect to the decay coefficient or time constant; and adjusting the decay coefficient or time constant of the SNN based on the gradient of the network loss with respect to the decay coefficient or time constant.
[0011] In one type of embodiment, the decay coefficient or time constant of the SNN is adjusted multiple times based on multiple batches of sample data received from the training dataset to obtain at least a portion of the SNN configuration parameters.
[0012] At least a portion of the obtained SNN configuration parameters are deployed into a chip with an SNN processor, thereby enabling the chip to process ambient signals. The SNN configuration parameters may also include axonal delay and / or synaptic weight matrix.
[0013] For an SNN to be trained, its corresponding SNN configuration parameters are initialized before training. The initialization methods include, but are not limited to: setting all to zero, random initialization according to a normal distribution, default values, and random values within a reasonable range.
[0014] In one embodiment, adjusting the time constant of the SNN based on the gradient of the network loss with respect to the decay coefficient includes: obtaining the gradient of the network loss with respect to the time constant based on the gradient of the network loss with respect to the decay coefficient or its current layer component, and the relationship between the decay coefficient and the time constant, and adjusting the time constant of the SNN based on the gradient of the network loss with respect to the time constant.
[0015] The gradient of the network loss with respect to the time constant can be obtained by taking the current layer component of the gradient of the network loss with respect to the time constant (after step S4) and then summing it with respect to all layer components, or it can be obtained by taking the gradient of the network loss with respect to the decay coefficient and then summing it with respect to the relationship between the two (after step S8).
[0016] In certain embodiments, the sample data is one or more of signals of vision, audition, touch, smell, electrocardiogram, electromyogram, vibration, and IMU types.
[0017] In certain embodiments, the current layer component of the gradient of the network loss with respect to the attenuation coefficient , where is the sequence number of the current layer, n is the time step, T is the total length of the time steps, is the impulse response kernel, is the first gradient of the network loss with respect to the layer, is the second variable of the layer, is the cross-correlation operation.
[0018] The first gradient of the network loss with respect to the layer here, that is, the gradient of the network loss with respect to the impulse response signal output by the layer.
[0019] In certain embodiments, when , , where is the network loss, is the impulse response signal output by the L-th layer; when < L, , where is the second gradient of the weighted postsynaptic input of the network loss with respect to the +1 layer, is the synaptic weight matrix between the layer and the +1 layer.
[0020] In certain embodiments, the weighted postsynaptic input of the +1 layer , where is the impulse response signal output by the layer; and the second gradient of the weighted postsynaptic input of the network loss with respect to the +1 layer: , where is the first variable corresponding to the +1 layer, and m is a temporary variable.
[0021] In certain embodiments, the first variable corresponding to the +1 layer is:
[0022] ;
[0023] where is the refractory period kernel, and "*" is the convolution operation. This is a proxy gradient function.
[0024] In some embodiments, for the second variable ,satisfy: ,in For the surrogate gradient function, Let be the third variable, and satisfy: ,
[0025] ,in Let I be the attenuation coefficient, and let I be the identity matrix. For the first The film voltage of the layer, The threshold for neuronal impulse firing. For the first The output pulse sequence of the layer.
[0026] In one type of embodiment, after obtaining the aforementioned second gradient, the network loss is calculated with respect to the synaptic weight matrix. gradient:
[0027] ,in The transpose is used as a marker; and it is determined whether the current layer index is 1. If it is, the gradient of the network loss with respect to the decay coefficient is obtained by summing the gradient components of the network loss with respect to the decay coefficient of all layers of the SNN; if not, the current layer index is decremented by 1, and then the first gradient of the network loss with respect to the current layer is calculated for each time step.
[0028] In one embodiment, the synaptic weight matrix is updated / adjusted based on the gradient of the network loss with respect to the synaptic weight matrix; a target synaptic weight matrix is obtained as at least part of the network configuration parameters based on training with multiple batches of sample data. The SNN network configuration parameters include at least the aforementioned time constant or decay coefficient, and the target synaptic weight matrix.
[0029] In one embodiment, the axon delay is adjusted using the gradient of the network loss with respect to the axon delay; the axon delay obtained after multiple adjustments is used as at least a part of the SNN network configuration parameters; wherein the gradient of the network loss with respect to the axon delay is:
[0030] ,in For the first Axonal delay in layer neurons, For the first Layers with impulse response kernels exhibiting axonal delay properties.
[0031] The SNN training method is executed by a training device that loads sample data and computer code that executes the SNN training method to obtain at least a portion of the SNN configuration parameters.
[0032] A storage medium storing computer code, by executing the computer code, to implement the SNN training method as described in any of the preceding claims.
[0033] An SNN training device includes a computing unit and a storage medium as described above, wherein configuration parameters of the SNN are obtained by loading or compiling computer code on the storage medium and executing it by the computing unit.
[0034] A chip includes an SNN processor, on which configuration parameters of an SNN are deployed, and the configuration parameters of the SNN include at least the decay coefficient or time constant of the SNN obtained by the SNN training method as described in any of the preceding claims.
[0035] An electronic device includes a chip as described above. The chip senses environmental signals, performs inference, and obtains a reasoning result. The electronic device then responds based on the reasoning result.
[0036] Some or all of the embodiments of the present invention have the following beneficial technical effects:
[0037] (1) The training method proposed in this invention produces SNNs with higher inference accuracy;
[0038] (2) Deploying a chip containing an SNN processor trained by the present invention results in higher inference accuracy and better performance in actual application scenarios.
[0039] Further beneficial effects will be described in the preferred embodiments.
[0040] The technical solutions / features disclosed above are intended to summarize the technical solutions and features described in the Detailed Embodiments section, and therefore the scope of the description may not be entirely the same. However, these new technical solutions disclosed in this section are also part of the numerous technical solutions disclosed in this invention document. The technical features disclosed in this section, together with the technical features disclosed in the subsequent Detailed Embodiments section and some contents in the drawings not explicitly described in the specification, disclose more technical solutions in a reasonable combination.
[0041] The technical solution formed by combining all the technical features disclosed at any position in this invention is used to support the summary of the technical solution, the modification of the patent document, and the disclosure of the technical solution. Attached Figure Description
[0042] Figure 1 It is the existing SRM neuron model;
[0043] Figure 2 It is the network model of SNN in the existing technology;
[0044] Figure 3 This is a schematic diagram of the convolution process involving impulse response kernels in existing technologies;
[0045] Figure 4 This is a schematic diagram of the accumulation and pulse firing process of LIF neurons in existing technology;
[0046] Figure 5 This is a flowchart of the forward process involved in a certain embodiment of the present invention;
[0047] Figure 6 This is a flowchart illustrating the reverse process in a certain embodiment of the present invention;
[0048] Figure 7 This is a diagram showing the relationship between several components in a certain embodiment of the present invention. Detailed Implementation
[0049] Since it is impossible to exhaustively describe all alternative solutions, the key points of the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Other technical solutions and details not disclosed in detail below generally belong to technical objectives or features that can be achieved by conventional means in the art, and due to space limitations, they will not be described in detail here.
[0050] Unless it refers to division, the " / " in any position in this invention represents logical "OR". The serial numbers "first", "second", etc., in any position in this invention are merely descriptive distinguishing marks and do not imply an absolute temporal or spatial order, nor do they imply that terms prefixed with such serial numbers necessarily refer to different things than the same terms prefixed with other modifiers.
[0051] This invention describes various key points used to combine into various specific embodiments, which will be incorporated into various methods and products. In this invention, even if a key point is described only when introducing a method / product solution, it means that the corresponding product / method solution also explicitly includes that technical feature.
[0052] The description of the existence or inclusion of a step, module, or feature at any location in this invention does not imply that such existence is exclusive or unique. Those skilled in the art can obtain other embodiments by supplementing the technical solutions disclosed in this invention with other technical means. The embodiments disclosed in this invention are generally for the purpose of disclosing preferred embodiments, but this does not imply that opposite embodiments of the preferred embodiments are excluded by this invention. As long as such opposite embodiments at least solve some technical problem of this invention, they are intended to be covered by this invention. Based on the key points described in the specific embodiments of this invention, those skilled in the art can substitute, delete, add, combine, or change the order of certain technical features to obtain a technical solution that still follows the concept of this invention. These solutions that do not depart from the technical concept of this invention are also within the protection scope of this invention.
[0053] This invention first describes the basic knowledge and terminology of spiking neurons and spiking neural networks. This part is common technical knowledge in the field, and the notation system is consistent with that of prior art 2. In addition, the same symbols in this invention can generally refer to their meaning when they first appear or the meaning implied by the notation system of this invention, and will generally not be repeated hereafter.
[0054] Figure 1 A spike response (SRM) neuron model is described, with LIF and IAF neurons being two special cases of SRM neurons. The neuron receives multiple input spike sequences (each sequence numbered 1, 2, …, i, …), and one of these input spike sequences is denoted as… Where t is the time marker in a continuous system. Impulse response signal yes With impulse response kernel (abbreviated as) The result after convolution: (Unless otherwise specified, * in this invention represents a convolution operation). The impulse response kernel can also have an axonal delay D property, i.e. Postsynaptic voltage (PSP) is an impulse response signal. Synaptic weight The result after multiplication. The neuron receives the postsynaptic voltage from each pathway and sums them, taking into account the refractory period nucleus. After the influence (which works in conjunction with the neuron's output) is applied, the neuron's membrane voltage is obtained. If the membrane voltage exceeds the neuronal impulse firing threshold... If a pulse (or pulse event) is emitted, it becomes the output of that neuron. (abbreviated as s), the present invention is also applicable to the multi-pulse mechanism mentioned in prior art 2.
[0055] refer to Figure 2This is a general description of the structure of a spiking neural network. Each black circle in the diagram represents a neuron, and several neurons form a layer. The diagram shows a spiking neural network with L (positive integer) layers. In the... To the In the network connection of layer +1, the weight matrix , which corresponds to one space, It is the input expansion matrix. Axon delay. , which corresponds to one Space, in which and They are the first Layer network (abbreviated as 1st layer network) (layer) and +1 The number of neurons in the network layer. This invention is not limited to any specific SNN structure.
[0056] For ease of description and without loss of generality, let's call it the [number]. layer( =1,2,…,L) represents the current layer, the first layer is the input layer of the SNN, the Lth layer is the output layer of the SNN, and the time step is n (n=1,2,…,T, where T is the last time step and also the total length of the time steps), which corresponds to the time marker of the continuous-time (t) system in the discrete system. The input pulse sequence of the layer is (Consider the notation for time steps as follows) ), No. The output pulse sequence of the layer is (Consider the notation for time steps as follows) ), No. membrane voltage of the layer , No. Layer input impulse response signal (Also the first) The output impulse response signal of layer -1). The input of the spiking neural network is... The output of the spiking neural network is .
[0057] For example, the convolution process involving the aforementioned impulse response kernel is in Figure 3 This is vividly described. For the nth time step, the... Layer input impulse response signal satisfy:
[0058] , where n≥m.
[0059] refer to Figure 4This diagram illustrates the membrane voltage and pulse firing time of a LIF neuron. The LIF neuron initially receives input current and continuously accumulates membrane voltage. When the membrane voltage exceeds a threshold, it fires a pulse (or pulse event), and the membrane voltage returns to its resting potential. Before reaching the firing threshold and without receiving further input current, the membrane voltage gradually decreases. For example, in a discrete-time system, the formula describing the membrane voltage of a LIF neuron can be:
[0060] .
[0061] In some embodiments, the attenuation coefficient can be defined as or (The latter is a first-order approximation of the Taylor expansion of the former), where It is a time constant. The length of a single time step (also known as the simulation time step).
[0062] refer to Figure 5 This describes the forward process of the present invention. This process is substantially consistent with that of prior art 2, which is incorporated herein by reference.
[0063] The training device receives a batch of samples from the training dataset (either from the training device's storage or from a remote storage device) and inputs a burst sequence into the SNN. n=1,2,…,T, the index of the current layer During the training of a certain batch of samples, the forward process is the process of inference on the input samples by the SNN with the current configuration parameters (synaptic weights, time constant / decay coefficient, etc.).
[0064] Then, before reaching the neurons in the current layer, the input pulse sequence of the current layer... With impulse response kernel Perform a convolution operation to obtain the input impulse response signal of the current layer. For example, for impulse response kernels The element with index n is .
[0065] Next, the membrane voltage of the current layer is obtained. Membrane voltage is a variable reflecting the state of a neuron and is a primary factor in determining whether it has been activated. For the membrane voltage of the current layer, it satisfies:
[0066] ;
[0067] Among them, the refractory period nuclear The element marked as n is .
[0068] Next, based on the current layer voltage, the current layer output pulse sequence is obtained. .if When the membrane voltage exceeds a threshold, a pulse is emitted, such as the common single-pulse form. Of course, it can also be in the form of multiple pulses. For example, when the membrane voltage reaches 3 to 4 times the threshold, a pulse with an amplitude of 3 can be emitted, and the amplitude information of the pulse can be carried when transmitting a single event.
[0069] At this point, determine the sequence number of the current layer. Is it equal to L? If it is, then calculate the current network loss based on the SNN output. (Not the total number of network layers L);
[0070] Otherwise, the current layer's sequence number should satisfy: At this point, the index of the current layer is incremented by 1 once. That is, to move forward one layer (i.e., forward).
[0071] Then, based on the new input pulse sequence of the current layer, perform convolution with the impulse response kernel as described above. This process is a similar repetition of the aforementioned process and will not be repeated here.
[0072] After completing the entire process described above, when the current layer reaches the Lth layer, the output of the SNN network is: The aforementioned forward process is a conventional process in the field, and the present invention does not specifically limit the specific details and parameters.
[0073] refer to Figure 6 This invention discloses the reverse process of the present invention, which differs from prior art 2. The current network loss obtained in the forward process is referred to herein as the network loss. For example, the process includes the following steps:
[0074] Step S1: Obtain the network loss with respect to the nth time step at each time step n. Layer output pulse response signal First gradient:
[0075] ;
[0076] Step S2: Based on the surrogate gradient function The first variable is calculated sequentially by incrementing the value m (starting from m=n and continuing until m=T; m is a temporary variable), where the first variable is defined as:
[0077] ;
[0078] It is not difficult to obtain that when m < n, the corresponding first variable is 0; starting from m = n to calculate the first variable, when m = n, its result is explicitly defined; and when m > n, the calculation depends on its previous result . Since the first variable is calculated by incrementing m, the previous result it depends on is known at this time.
[0079] Step S3: By incrementing the value of n (from 1 to T), obtain the third variable one by one , and then obtain the second variable . The specific process is as follows. For the third variable: , , where I is the identity matrix.
[0080] It is not difficult to see that for n = 1, its result is explicitly defined; when n > 1, since the value of n is incremented, its calculation result depends on the previous known result .
[0081] After obtaining the result of the third variable at the nth time step , it is obvious to obtain the result of the second variable at the nth time step .
[0082] Step S4: Obtain the current layer component of the gradient of the network loss with respect to the decay coefficient . Since the result of has been obtained in step S3, and the first gradient with respect to the layer is known at this time, it is feasible to obtain , where is the cross-correlation operation.
[0083] As mentioned above, since the relationship between the time constant and the decay coefficient is clear, according to the relationship between the two, it is easy to obtain the current layer component of the gradient of the network loss with respect to the time constant: .
[0084] Step S5: Obtain the second gradient of the weighted postsynaptic input of the network loss with respect to the current layer (the layer) at each time step. For the nth time step, it is specifically:
[0085] ;
[0086] where is the cross-correlation operation. Referring to the result of step S2 and the result of obtaining the first gradient before entering step S2 (step S1 or step S7), it is easy to obtain the second gradient in step S5.
[0087] Step S6: Obtain the network loss with respect to the synaptic weight matrix (Establish the first) -1st floor and the The gradient of the synaptic weight matrix of the network connections between layers:
[0088] ,in This is a transpose marker;
[0089] And determine the sequence number of the current layer. Is it 1? If not, then Should meet For the current layer's sequence number Decrement by 1, that is Then proceed to step S7; if so, proceed to step S8.
[0090] Step S7: For each time step, obtain the network loss with respect to the _th ... The first gradient of the layer:
[0091] ;
[0092] Unlike the method used to obtain the first gradient in step S1, the first gradient for layers other than L is obtained based on the second gradient and the synaptic weight matrix. The network loss here relates to the Lth layer. The first gradient of the layer is still the network loss with respect to the th layer. The gradient of the layer output impulse response signal, i.e.:
[0093] , ≠L.
[0094] Step S8: Obtain the network loss with respect to the attenuation coefficient gradient:
[0095] ;
[0096] In step S4, the current layer component of the gradient of the network loss with respect to the decay coefficient is calculated. After repeating the aforementioned steps, all layers (all) of the gradient of the network loss with respect to the decay coefficient are processed. All the information has already been obtained before executing step S8, so step S8 is easy to execute. In other words, the sum of all (all) layer components of the gradient of the SNN network loss with respect to the decay coefficient is the gradient of the network loss with respect to the decay coefficient.
[0097] Alternatively, in step S4, since there is a definite relationship between the decay coefficient and the time constant, the current layer component of the gradient of the network loss with respect to the time constant can be easily obtained from the current layer component of the gradient of the network loss with respect to the decay coefficient. Therefore, the gradient of the network loss with respect to the time constant can also be easily obtained in step S8.
[0098] Step S9: Using the aforementioned network loss with respect to the attenuation coefficient... The gradient is used to adjust / update the decay coefficient of the SNN.
[0099] If you choose to train the aforementioned exponential decay coefficient, since the decay coefficient ranges between (0, 1), it will usually be clipped to the above range if the updated decay coefficient exceeds this range.
[0100] For example, based on the aforementioned relationship between the time constant and the attenuation coefficient, such as It is not difficult to conclude that:
[0101] ;
[0102] In other words, by taking the derivative of a simple composite function and using the gradient of the network loss with respect to the decay coefficient, it is easy to derive the gradient of the network loss with respect to the time constant, and then update / adjust the time constant based on this gradient. Other possible methods for determining the relationship between the time constant and the decay coefficient are not listed here.
[0103] There are various methods for adjusting / updating trained parameters (decay coefficients / time constants, etc.) based on gradients, which are available to those skilled in the art, such as SGD and ADAM. This invention does not limit this approach. This invention is particularly suitable for training SNNs based on LIF neurons.
[0104] By using multiple batches of samples, the aforementioned forward and reverse processes are repeatedly repeated, continuously adjusting / updating the attenuation coefficient or time constant until the optimal configuration parameters are obtained. For example, after reaching a preset number of adjustments or a preset performance level, the obtained configuration parameters (including the time constant or attenuation coefficient) are used as the final configuration parameters.
[0105] As for the training scheme for axonal delay, it can be easily obtained by rewriting the impulse response kernel in the aforementioned scheme. The gradient of the network loss with respect to axonal delay can be obtained through... This is obtained using the chain rule. For example, the first... The axonal delay of layer neurons is Meanwhile, the impulse response kernel of this layer has axonal delay properties. Therefore, the gradient of the network loss with respect to axonal delay satisfies:
[0106] ;
[0107] use After simplification, we have:
[0108] ;
[0109] Then, based on the gradient of the network loss with respect to axon delay, the axon delay is adjusted / updated; by using the training sample data and performing this adjustment multiple times, the network configuration parameters regarding axon delay can be obtained.
[0110] The aforementioned method for training decay coefficients or time constants can be used in conjunction with prior art 2 for training SNN networks. In one embodiment, the synaptic weight matrix is updated / adjusted based on the gradient of the network loss with respect to the synaptic weight matrix; a target synaptic weight matrix is obtained as at least part of the network configuration parameters based on training with multiple batches of sample data. The SNN network configuration parameters include at least the aforementioned time constant or decay coefficient, as well as the target synaptic weight matrix, axonal delay, etc. Deploying these SNN configuration parameters into a neuromorphic chip yields an SNN with corresponding inference capabilities.
[0111] For mixed-signal SNN processors, the time constant can be expressed more easily and directly through the bias current of the circuit; however, for digital signal SNN processors, the attenuation coefficient is more suitable. Therefore, different configuration parameters are selected based on the different characteristics of the SNN processor: attenuation coefficient or time constant.
[0112] A storage medium containing computer code, which is executed to implement any of the aforementioned SNN training methods.
[0113] The SNN training device includes a computing unit and a storage medium as described in any of the preceding claims, wherein SNN configuration parameters are obtained by loading or compiling computer code on the storage medium and having it executed by the computing unit.
[0114] These SNN configuration parameters, using appropriate software tools, can be deployed / mapped into neuromorphic chips (chips containing SNN processors). These neuromorphic chips can then use these configuration parameters to perform inference processes based on input signals (images, sounds, vibrations, etc.) detected from the environment in practical applications, obtaining inference results, such as detecting abnormal electrocardiogram signals, a specific keyword, or a specific gesture. Therefore, this invention also discloses a chip including an SNN processor, on which SNN configuration parameters obtained by any of the aforementioned methods are deployed, such as attenuation coefficients / time constants, and may also include synaptic weights, axonal delays, etc.
[0115] Electronic devices, such as smart toys, health monitoring devices, wearable devices, and robots, deploy any of the aforementioned chips, preferably neuromorphic chips with multimodal information processing capabilities as described in prior art 3. These electronic devices operate in a manner similar to biological neurons, achieving environmental awareness with extremely low power consumption while protecting privacy. For example, a user's computer in sleep mode can detect the user's intention to use the device based on environmental information captured by an event camera, and then decide whether to activate facial recognition to enter the corresponding workspace / account, etc. The relationship between these components / functions can be referenced... Figure 7 .
[0116] Although the invention has been described with reference to specific features and embodiments, various modifications, combinations, and substitutions can be made therein without departing from the invention. The scope of protection of this invention is not limited to the specific embodiments of processes, machines, manufactures, material compositions, apparatuses, methods, and steps described in the specification, and these methods and modules may also be implemented in one or more related, interdependent, cooperative, or upstream / downstream products or methods.
[0117] Therefore, the specification and drawings should be simply regarded as a description of some embodiments of the technical solutions defined by the appended claims, and thus the appended claims should be interpreted in accordance with the principle of the greatest reasonable interpretation, and are intended to cover as much as possible all modifications, variations, combinations or equivalents within the scope of the invention, while avoiding unreasonable interpretations.
[0118] To achieve better technical effects or for the needs of certain applications, those skilled in the art may make further improvements to the technical solution based on this invention. However, even if such improvements / designs are inventive and / or progressive, as long as they rely on the technical concept of this invention and cover the technical features defined in the claims, the technical solution should also fall within the protection scope of this invention.
[0119] The technical features mentioned in the appended claims may have alternative technical features, or the order of certain technical processes or material organization may be rearranged. Those skilled in the art, upon learning of this invention, will readily conceive of these alternative means, or alter the order of the technical processes or material organization, and then employ substantially the same means to solve substantially the same technical problems and achieve substantially the same technical effects. Therefore, even if the claims explicitly define the aforementioned means and / or order, these modifications, alterations, and substitutions should all fall within the scope of protection of the claims based on the principle of equivalents.
[0120] The method steps or modules described in the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the steps and components of each embodiment have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application or design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered outside the scope of protection claimed by this invention.
Claims
1. An SNN training method, wherein the SNN to be trained includes... L layer, L For a positive integer not less than 2, the first integer in the SNN is... L The layer is an output layer, characterized in that, The method includes the following steps: A batch of sample data is received from the training dataset and used as the input of the SNN. The SNN is then run and its output is obtained. The sample data is one or more of the following types of signals: visual, auditory, tactile, olfactory, electrocardiogram, electromyography, vibration, and IMU. Calculate the current network loss based on the output of the SNN; Starting from the output layer of the SNN as the current layer, the current layer components of the gradient of the network loss with respect to the decay coefficient or time constant are obtained sequentially according to the reverse order of the layer numbers. The gradient of the network loss with respect to the decay coefficient or time constant is obtained by summing all layer components of the gradient of the SNN network loss with respect to the decay coefficient or time constant. Adjust the decay coefficient or time constant of the SNN based on the gradient of the network loss with respect to the decay coefficient or time constant.
2. The SNN training method according to claim 1, characterized in that: Based on multiple batches of sample data received from the training dataset, the decay coefficient or time constant of the SNN is adjusted multiple times to obtain at least a portion of the SNN configuration parameters.
3. The SNN training method according to claim 1, characterized in that: The SNN training method also includes: Based on the gradient of the network loss with respect to the decay coefficient or its current layer component, and the relationship between the decay coefficient and the time constant, the gradient of the network loss with respect to the time constant is obtained, and the time constant of the SNN is adjusted based on the gradient of the network loss with respect to the time constant.
4. The SNN training method according to any one of claims 1-3, characterized in that: The current layer component of the gradient of the network loss with respect to the decay coefficient. ,in Here, n is the sequence number of the current layer, n is the time step, and T is the total length of the time steps. It is an impulse response kernel; Regarding the network loss, the first The first gradient of the layer, i.e., the network loss with respect to the th layer. The gradient of the layer output impulse response signal; For the first The second variable of the layer, For cross-correlation operations.
5. The SNN training method according to claim 4, characterized in that: when hour, ,in For network losses, For the first L Layer outputs pulse response signal; when < L hour, ,in It is about network loss regarding the first The second gradient of the synaptic input after weighting at layer +1 It is the first Layer and First Synaptic weight matrix between +1 layers.
6. The SNN training method according to claim 5, characterized in that: No. Weighted synaptic input at +1 layer ,in For the first Layer outputs pulse response signal; And network losses regarding the first The second gradient of the synaptic input after weighting by +1 layer is: ,in For the first The first variable corresponding to layer +1, m is a temporary variable.
7. The SNN training method according to claim 6, characterized in that: The first The first variable corresponding to layer +1 is: ; in The kernel has a refractory period, and "*" indicates a convolution operation. This is a proxy gradient function.
8. The SNN training method according to claim 7, characterized in that: For the second variable ,satisfy: ,in For the surrogate gradient function, Let be the third variable, and satisfy: , ,in The attenuation coefficient is... I It is the identity matrix. For the first The film voltage of the layer, The threshold for neuronal impulse firing. For the first The output pulse sequence of the layer.
9. The SNN training method according to claim 8, characterized in that: After obtaining the aforementioned second gradient, calculate the network loss with respect to the synaptic weight matrix. gradient: ,in This is a transpose marker; And determine whether the current layer number is 1. If it is, then: obtain the gradient of the network loss with respect to the decay coefficient by summing the gradient components of the network loss of all layers of SNN with respect to the decay coefficient. If not, then: decrement the current layer number by 1, and then for each time step, calculate the first gradient of the network loss with respect to the current layer.
10. A storage medium storing computer code, characterized in that: By executing the computer code, the SNN training method according to any one of claims 1-9 can be implemented.
Citation Information
Patent Citations
Brain-like chip and electronic equipment
CN114372568A
Space-time domain spiking neural network training method, chip and electronic product
CN114565079A