A training method and device for simulating hardware neural network
Through the perturbation propagation method, the gradient is calculated and physical parameters are adjusted in the simulated hardware neural network, which solves the dependence problem on mathematical models in the existing technology, and achieves higher recognition rate and versatility, which is suitable for all types of simulated hardware neural network training.
Patent Information
- Application Number
- CN202410650458.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-05-24
AI Technical Summary
The prior art relies on mathematical models when training simulated hardware neural networks, resulting in training failure or recognition rate failure, especially in complex systems, which limits the development of simulated hardware neural networks.
The perturbation propagation method is used to calculate the gradient value during the forward propagation process, and the physical parameters of the simulated memory and computing integrated array in the simulated hardware neural network are adjusted according to the gradient of each node to achieve training.
There is no need to model the simulated hardware neural network system, and it is directly used to train simulated hardware neural networks in any state, eliminating the training deviation caused by the mismatch between the mathematical model and the real system, and improving the recognition rate and training performance.
Smart Images

Figure CN118569331B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a neural network algorithm, and in particular to a training method and device for simulating hardware neural network. Background Art
[0002] Compared with the current research hotspot digital neural networks (such as CNN, ANN, GNN, etc.), analog hardware neural networks have lower power consumption and simpler circuit structure. Since the calculation process of analog hardware neural networks does not involve AD / DA and does not require the use of binary coding in computers, the circuit design corresponding to the entire calculation process is simpler. At the same time, since the circuit is simpler and uses the intrinsic properties of the system for calculation, the entire system has a very high energy efficiency ratio and is very suitable for AI deployment. In an all-optical neural network based on optical principles, the weight information of the neural network is stored in a diffraction grating. When light passes through, it will be modulated by the grating and diffracted, thereby performing calculations and projecting the diffracted light onto the detection screen. Since the process of optical calculation is the propagation process of light in space, the calculation speed of the all-optical neural network is only limited by the speed of light, so it can quickly complete calculations that take a lot of time in traditional digital neural networks. In a fully analog memristor neural network based on memristors, the weight information of the neural network is the conductance value of the memristor, and multiple memristor arrays and nonlinear computing units are cascaded to form a multi-layer analog hardware neural network. When the sensor or signal source inputs an electrical signal to the front-end memristor, the electrical signal propagates in the array at a speed close to the speed of light and is modulated by the conductivity, which can complete a large number of neural network operations at high speed and in parallel.
[0003] BP algorithm, full name Backpropagation algorithm, is a method for training digital neural networks. Its basic idea is to calculate the error between the predicted result and the correct result, and propagate this error back to each node of the neural network, adjust the weight and bias parameters in the network according to the error, so that the predicted result of the network gradually approaches the correct result. However, when the BP algorithm is applied to the training of analog hardware neural networks, some serious error problems will occur. The common practice of training an analog hardware neural network is to first model the analog hardware neural network to obtain a mathematical model, then use the BP algorithm to train it on the software according to its mathematical model, and finally update the trained weights, biases and other parameters to the analog hardware neural network system. This is because the analog hardware neural network system is different from the traditional digital computer. It cannot accurately execute the operation instructions. Its calculation process depends on the state evolution inside the analog hardware neural network system. Therefore, in order to perform the error transmission of back propagation, it is necessary to use a mathematical model for calculation. This training method of analog hardware neural network system relying on mathematical models brings many problems, especially when training analog hardware neural network systems based on analog signals, its limitations and disadvantages begin to emerge. Using the BP algorithm to train the mathematical model of the simulated hardware neural network may result in training failure or the recognition rate of the trained neural network may not meet the requirements.
[0004] The new solution is to use a hybrid computing architecture. The forward propagation process of the hybrid computing architecture is calculated in the simulated hardware neural network system, and the back propagation needs to use the chain rule in mathematics, so the back propagation process is still calculated based on the mathematical model. The training of this hybrid computing architecture uses both the mathematical model and the simulated hardware neural network system itself, and does not rely entirely on the mathematical model for pre-training. However, in this hybrid architecture, since its back propagation process still uses the chain rule in the model to calculate the gradients of each layer, this will inevitably lead to the gradient obtained by the back propagation calculation being inconsistent with the actual situation, which in turn leads to deviations in the parameter update of the neural network. These deviations will seriously reduce the performance of the neural network, making it impossible for the neural network to achieve a higher recognition rate (limited by the error of the model), and may even cause the neural network to fail. In addition, as the complexity of the simulated hardware neural network system increases, the difficulty of modeling the simulated hardware neural network will increase exponentially. Some complex systems may not even be able to establish mathematical models, which means that it is difficult for us to train some simulated hardware neural networks with complex designs, which greatly limits the development of simulated hardware neural networks. Summary of the invention
[0005] Purpose of the invention: In view of the above problems, the present invention proposes a training method and device for simulated hardware neural networks, which have higher recognition rate and versatility than the prior art, are suitable for all types of simulated hardware neural network training, and solve the problem of simulated hardware neural network training's dependence on mathematical models.
[0006] Technical solution: The technical solution adopted by the present invention is a training method for simulating hardware neural networks, including: converting training data into analog signals and inputting them into the simulating hardware neural networks, and recording the labels of the training data; after the simulating hardware neural networks establish a response to the input signals, collecting the internal signals of the simulating hardware neural networks and converting them into digital signals, and then calculating the loss value of the neural networks; injecting a perturbation signal z into the node a of the nonlinear unit in the simulating hardware neural networks, and calculating the gradient of the loss value of the neural networks relative to the node a according to the change of the loss value of the neural networks before and after the injection of the perturbation; traversing the nodes, and calculating the physical parameter matrix adjustment amount of the elements in the simulating storage and computing integrated array of each layer of the neural networks according to the gradient of the loss value of the neural networks relative to each nonlinear unit layer and the collected internal signals of the simulating hardware neural networks, as well as the connection relationship between each nonlinear unit layer and the elements in the simulating storage and computing integrated array; adjusting the physical parameters of the elements in the simulating storage and computing integrated array of each layer of the neural networks according to the physical parameter matrix adjustment amount of the elements in the simulating storage and computing integrated array of each layer of the neural networks, so as to realize the training of the simulating hardware neural networks.
[0007] The method of collecting the internal signals of the analog hardware neural network and converting them into digital signals and then calculating the loss value of each layer of the neural network includes: collecting the analog input signals of the analog storage and computing integrated array of each layer of the neural network and the analog output signals of the analog hardware neural network, converting the analog input signals and the analog output signals into digital signals, and calculating the loss value Loss of the neural network according to the converted analog input signals and analog output signals.
[0008] The loss value Loss of the neural network is calculated based on the converted analog input signal and analog output signal, and the mean square error function is used for calculation, and the calculation formula is:
[0009]
[0010] Where y is the analog output signal of the analog hardware neural network after ADC conversion, label is the label of the training data, and n is the number of samples of the training data.
[0011] The gradient of the loss value of each layer of the neural network relative to the node a is calculated according to the change of the loss value of each layer of the neural network before and after the perturbation is injected, and the calculation formula is:
[0012]
[0013] In the formula, Represents the gradient of the loss value of each layer of the neural network relative to node a, replaced by the amplitude Δz of the perturbation signal z Calculate and replace the change of loss value of each layer of neural network before and after injecting perturbation Perform calculations.
[0014] The gradient of the loss value of the neural network relative to each nonlinear unit layer is composed of the gradient of the loss value of the neural network relative to each nonlinear unit node a, expressed as a vector, and its calculation formula is:
[0015]
[0016] Where δ is the gradient of the loss value of the neural network relative to the nonlinear unit layer, the subscript n represents the nth nonlinear unit layer, the subscripts a1, a2, am, etc. represent the gradient values of the loss value of the neural network relative to different nodes, and m is the total number of nonlinear unit nodes in the nth layer.
[0017] The physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network is calculated based on the gradient of the loss value of the neural network relative to each nonlinear unit layer and the internal signal of the collected analog hardware neural network, as well as the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array. The calculation formula is:
[0018] ΔW=η(I n ×δ| n ).
[0019] Where W is the physical parameter matrix of the components in the analog storage and computing integrated array of the nth layer, η is the physical parameter matrix adjustment coefficient, δ| n is the gradient of the loss value of the neural network relative to the nth nonlinear unit layer, I n It is the input signal of the analog storage and computing integrated array.
[0020] The present invention provides a training device for simulating a hardware neural network, comprising:
[0021] A signal conversion module, used to convert training data into analog signals and input them into the analog hardware neural network;
[0022] A perturbation signal generation and injection module is used to inject perturbation signals into nodes of nonlinear units in the simulated hardware neural network;
[0023] The perturbation signal detection and readout module is used to collect the internal signals of the analog hardware neural network, convert them into digital signals, and send them to the system control module;
[0024] The system control module is used to calculate the loss value of the neural network according to the internal signal of the converted analog hardware neural network; calculate the gradient of the loss value of the neural network relative to node a according to the change of the loss value of the neural network before and after the injection of perturbations; control the perturbation to traverse the nodes, and calculate the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network according to the gradient of the loss value of the neural network relative to each nonlinear unit layer, the collected internal signal of the analog hardware neural network, and the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array; adjust the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network according to the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network.
[0025] The acquisition of internal signals of the simulated hardware neural network includes: acquiring analog input signals of the analog storage and computing integrated array of each layer of the neural network and analog output signals of the simulated hardware neural network.
[0026] The analog storage and computing integrated array includes a memristor array, a current mirror array or a floating gate transistor array; for the memristor array, the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted by using a pulse signal to modulate the conductance of the memristor array; for the current mirror array, the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted by using a pulse signal to update the value in the switch register, thereby changing the switching state of the transistor in the current mirror; for the floating gate transistor array, the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted by adjusting the gate voltage applied to the transistor.
[0027] The amplitude and frequency of the perturbation signal generated by the perturbation signal generation and injection module are adjustable.
[0028] The perturbation signal generation and injection module comprises a voltage source / current source, an adjustable resistor and a multi-way switch; the voltage source / current source generates a reference bias signal, and uses the resistance change of the adjustable resistor to generate a perturbation signal with adjustable amplitude; the multi-way switch is used to selectively connect the node and inject the perturbation signal into the node.
[0029] Beneficial effects: Compared with the prior art, the present invention has the following advantages: The present invention uses the method of perturbation propagation to calculate the gradient value in the forward propagation process, and adjusts the physical parameters of the simulated storage and computing array in the simulated hardware neural network according to the gradient of each node, so as to achieve the purpose of training the simulated hardware neural network. Therefore, the present invention does not need to model the simulated hardware neural network system to obtain a mathematical model, and can be directly used to train simulated hardware neural networks in any state. Since there is no reliance on mathematical models, the present invention eliminates the training deviation caused by the mismatch between the mathematical model and the real system, and further improves the recognition rate and training performance of the simulated hardware neural network. Compared with the traditional BP algorithm or hybrid computing architecture, this method is more suitable for dynamically changing real simulated hardware neural network systems, and can adapt to simulated hardware neural network systems in different states to train high-performance simulated hardware neural networks. At the same time, since back propagation is no longer used for calculation, the present invention greatly reduces the computer memory usage and reduces the computing energy consumption, so that the low power consumption advantage of the simulated hardware neural network can be brought into play. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a flowchart of the training method of the simulated hardware neural network described in the present invention;
[0031] Figure 2 It is a structural block diagram of the training device for simulating hardware neural network according to the present invention;
[0032] Figure 3 It is a schematic diagram of the injected perturbation signal described in the present invention. DETAILED DESCRIPTION
[0033] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0034] Example 1
[0035] The training method of the simulated hardware neural network described in the present invention has the following process: Figure 1 As shown, including:
[0036] 1. Convert the training data into analog signals and input them into the analog hardware neural network, and record the labels of the training data;
[0037] 2. After the simulated hardware neural network establishes a response to the input signal, the internal signal of the simulated hardware neural network is collected and converted into a digital signal and the loss value of the neural network is calculated;
[0038] 3. Inject a perturbation signal z into the node a of the nonlinear unit in the simulated hardware neural network, and calculate the gradient of the loss value of the neural network relative to the node a according to the change of the loss value of the neural network before and after the perturbation injection;
[0039] 4. Traverse the nodes, and calculate the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network according to the gradient of the loss value of the neural network relative to each nonlinear unit layer and the internal signal of the collected analog hardware neural network, as well as the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array;
[0040] 5. According to the physical parameter matrix adjustment amount of the components in the analog storage and computing integrated array of each layer of the neural network, the physical parameters of the components in the analog storage and computing integrated array of each layer of the neural network are adjusted to realize the training of the simulated hardware neural network.
[0041] 6. Repeat the training several times until the accuracy of the simulated hardware neural network reaches the set threshold.
[0042] The internal signals of the simulated hardware neural network are collected and converted into digital signals and the loss value of the neural network is calculated, including: collecting the analog input signals of the analog storage and computing integrated array of each layer of the neural network and the analog output signals of the simulated hardware neural network, converting the analog input signals and the analog output signals into digital signals, and calculating the loss value Loss of the neural network according to the converted analog output signals and the labels of the corresponding training data.
[0043] The loss value Loss is calculated based on the converted analog input signal and analog output signal using the mean square error function. The calculation formula is:
[0044]
[0045] In the formula, y is the analog output signal of the analog hardware neural network after ADC conversion, label is the label of the training data, and n is the number of samples of the training data. For example, in the handwritten digit recognition task, the recognition target is the digits 0 to 9, and the label label is encoded as follows:
[0046] 0→[1,0,0,0,0,0,0,0,0,0];
[0047] 1→[0,1,0,0,0,0,0,0,0,0];
[0048] ……;
[0049] 9→[0,0,0,0,0,0,0,0,0,1].
[0050] The embodiment is only an example, and the loss value can be calculated by replacing other functions.
[0051] According to the change of the loss value of each layer of the neural network before and after the injection of perturbation, the gradient of the loss value of each layer of the neural network relative to the node a is calculated. The calculation formula is:
[0052]
[0053] In the formula, Represents the gradient of the loss value of each layer of the neural network relative to node a, replaced by the amplitude Δz of the perturbation signal z Calculate and replace the change of loss value of each layer of neural network before and after injecting perturbation Perform calculations.
[0054] According to the gradient of the loss value of the neural network relative to each nonlinear unit layer, it is composed of the gradient of the loss value of the neural network relative to each nonlinear unit node a, expressed as a vector, and its calculation formula is:
[0055]
[0056] Where δ is the gradient of the loss value of the neural network relative to the nonlinear unit layer, the subscript n represents the nth nonlinear unit layer, the subscripts a1, a2, am, etc. represent the gradient values of the loss value of the neural network relative to different nodes, and m is the total number of nonlinear unit nodes in the nth layer.
[0057] According to the gradient of the loss value of the neural network relative to each nonlinear unit layer and the internal signal of the collected analog hardware neural network, as well as the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array, the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network is calculated. The calculation formula is:
[0058] ΔW=η(I n ×δ| n ).
[0059] Where W is the physical parameter matrix of the components in the analog storage and computing integrated array of the nth layer, η is the physical parameter matrix adjustment coefficient, δ| n is the gradient of the loss value of the neural network relative to the nth nonlinear unit layer, I n It is the input signal of the analog storage and computing integrated array.
[0060] The present invention uses a perturbation signal to calculate the gradient of each layer in a simulated hardware neural network. The signal only propagates forward in the physical system to obtain the gradient, without involving any back-propagation process and mathematical model. Since the method of the present invention is completely based on the physical system for forward propagation and has no model deviation, the neural network trained by the present invention has a higher recognition rate and versatility than the prior art, is applicable to all types of simulated hardware neural network training, and solves the problem of model dependence.
[0061] Example 2
[0062] Analog hardware neural networks are generally composed of n layers of neural networks cascaded together. Each layer of the neural network includes an analog storage and computing array and a nonlinear unit. The analog storage and computing array can perform matrix multiplication based on analog signals, which is equivalent to weights and biases in neural networks. The circuit nonlinear unit can perform nonlinear transformations on analog signals, which is equivalent to nonlinear activation functions in neural networks.
[0063] The analog storage and computing integrated array is directly connected to the circuit nonlinear unit, forming a fully connected layer of the analog hardware neural network. A multi-layer analog hardware neural network is a direct connection of multiple fully connected layers.
[0064] The training device for simulating hardware neural network of the present invention has a schematic diagram as shown in FIG. Figure 2 As shown, it includes a perturbation signal generation and injection module, a system control module, a signal conversion module (DAC) and a perturbation signal detection and readout module.
[0065] The signal conversion module is used to convert the training data into analog signals and input them into the analog hardware neural network.
[0066] The perturbation signal detection and readout module is used to collect the internal signals of the analog hardware neural network, convert them into digital signals, and send them to the system control module.
[0067] The system control module is used to calculate the loss value of the neural network according to the internal signal of the converted analog hardware neural network; calculate the gradient of the loss value of the neural network relative to node a according to the change of the loss value of the neural network before and after the injection of perturbations; control the perturbation to traverse the nodes, and calculate the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network according to the gradient of the loss value of the neural network relative to each nonlinear unit layer, the collected internal signal of the analog hardware neural network, and the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array; adjust the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network according to the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network.
[0068] The perturbation signal generation and injection module is composed of a voltage source / current source, an adjustable resistor and a multi-way switch. In the above example, the perturbation signal generation and injection module uses a voltage source / current source to generate a reference bias signal, and uses the change in the resistance of the adjustable resistor to generate perturbation signals of different amplitudes. The multi-way switch is used for path selection of the perturbation signal and for selecting the node into which the perturbation signal is injected. The perturbation signal can be injected into a node of the nth layer of the neural network through the multi-way switch, where n represents any layer of the neural network.
[0069] In addition, the amplitude of the perturbation signal is generally much smaller than the amplitude of the signal of the node of the simulated hardware neural network. Its amplitude ranges from one tenth to one ten-thousandth of the node signal amplitude. The specific ratio depends on the training parameters of the simulated hardware neural network and can be adjusted according to the training results to obtain the optimal ratio.
[0070] Taking an analog hardware neural network based on analog circuits as an example, it mainly includes an analog storage and computing array and a nonlinear unit module.
[0071] The physical parameter matrix W of the elements in the analog storage and computing integrated array satisfies the matrix multiplication relationship of output I=V×W for a set of analog signals V input. The analog storage and computing integrated array includes but is not limited to: a memristor array, the conductance value of the memristor array corresponds to the value in the physical parameter matrix of the elements in the analog storage and computing integrated array; a current mirror array, the switching states of multiple transistors in the current mirror correspond to the values in the physical parameter matrix of the elements in the analog storage and computing integrated array; a floating gate transistor array, the gate voltage of the floating gate transistor corresponds to the value in the physical parameter matrix of the elements in the analog storage and computing integrated array.
[0072] The nonlinear unit module corresponds to the nonlinear layer in the simulated hardware neural network and is used for performing nonlinear calculations. The output and input of the module satisfy a pre-set nonlinear relationship.
[0073] The workflow of the neural network weight training device is:
[0074] Step 1, initialize the physical parameter matrix W of the elements in the simulated storage and computing integrated array, and the matrix W can be initialized to random values.
[0075] Step 2: Take some data from the data set and store it in a temporary cache.
[0076] Step 3, take out a set of training data from part of the data in the temporary cache, use the digital-to-analog converter DAC to convert the training data into an analog signal, and use the analog signal as a training signal to input into the analog hardware neural network. After waiting for the neural network to reach a stable output state, collect the analog input signals of the analog storage and computing array in each layer of the analog hardware neural network, use the perturbation signal detection readout module, convert the analog input signals of the analog storage and computing array in each layer of the analog hardware neural network into digital input signals x, and convert the analog output signals of the analog hardware neural network into digital output signals y, and calculate the loss value according to the digital output signal y.
[0077] Step 4: Select a node a from the input nodes of the nonlinear unit in the simulated hardware neural network. Use the perturbation signal generation and injection module to inject a perturbation signal with an amplitude of Δz into the node a. The injection diagram is shown in Figure 3 .
[0078] Step 5: After the perturbation signal is injected and the neural network reaches a stable output state, the amplitude of the output signal is observed by the perturbation signal detection readout module at the output end of the neural network, and the Loss is calculated using this value. ′ .
[0079] Step 6: Using the finite difference method, the gradient of Loss relative to node a is calculated based on Loss′, Loss and Δz.
[0080] Step 7, traverse all nodes in each layer of the simulated hardware neural network to obtain the gradient of the loss value Loss relative to all nodes.
[0081] Step 8. Now that the gradient of the loss value Loss relative to all nodes of the neural network is known, the physical parameter matrix adjustment ΔW of the elements in each layer of the analog storage and computing array can be calculated based on the input signal a of each layer, the weight of each layer, and the connection relationship between the nonlinear unit layer and the analog storage and computing integrated array.
[0082] Step 9, execute this operation on all the partial data obtained in step 2 to obtain the physical parameter matrix adjustment amount ΔW of several groups of elements in the analog storage and computing integrated array, take the average of all the weights to be updated, and obtain the final weight to be updated.
[0083] Step 10: Change the storage state of the simulated storage and computing integrated array and update the weight value stored therein. The specific change method depends on the type of the simulated storage and computing integrated array:
[0084] For a memristor array, a pulse signal is used to modulate the conductance value of the memristor.
[0085] For the current mirror array, a pulse signal is used to update the value in the switch register, thereby changing the switch state of the transistor in the current mirror.
[0086] For floating gate transistor arrays, the gate voltage applied to the transistors is adjusted.
[0087] Step 11, return to step 2, take out new data from the data set for training, until the data set is empty, and this round of training is completed.
[0088] The training is repeated many times until the accuracy of the simulated hardware neural network reaches the set threshold.
Claims
1. A training method for simulating a hardware neural network, characterized in that: include: Convert the training data into analog signals and input them into the analog hardware neural network, and record the labels of the training data; After the analog hardware neural network establishes a response to the input signal, the internal signal of the analog hardware neural network is collected and converted into a digital signal, and then the loss value of the neural network is calculated; a perturbation signal z is injected into the node a of the nonlinear unit in the analog hardware neural network, and the gradient of the loss value of the neural network relative to the node a is calculated according to the change of the loss value of the neural network before and after the injection of the perturbation; the nodes are traversed, and the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network is calculated according to the gradient of the loss value of the neural network relative to each nonlinear unit layer and the collected internal signal of the analog hardware neural network, as well as the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array; the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted according to the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network, so as to realize the training of the analog hardware neural network; The gradient of the loss value of the neural network relative to the node a is calculated based on the change of the loss value of the neural network before and after the perturbation is injected, and the calculation formula is: In the formula, Represents the gradient of the loss value of the neural network relative to node a, replaced by the amplitude Δz of the perturbation signal z Calculate and replace the change in the loss value of the neural network before and after the perturbation is injected Perform calculations; The gradient of the loss value of the neural network relative to each nonlinear unit layer is composed of the gradient of the loss value of the neural network relative to the nodes of each nonlinear unit, expressed as a vector, and its calculation formula is: Where δ is the gradient of the loss value of the neural network relative to the nonlinear unit layer, and the subscript n represents the nth nonlinear unit layer. Represents the gradient value of the loss value of the neural network relative to different nodes, and m is the total number of nonlinear unit nodes in the nth layer.
2. The training method for simulating a hardware neural network according to claim 1, characterized in that: The amplitude of the perturbation signal is less than 10% of the amplitude of the internal signal of the simulated hardware neural network; the amplitude of the perturbation signal is 0.1% to 1% of the amplitude of the internal signal.
3. The training method for simulating a hardware neural network according to claim 1, characterized in that: The method of calculating the gradient of the loss value of the neural network relative to node a based on the change of the loss value of the neural network before and after the injection of the perturbation includes: after injecting the perturbation signal into node a, detecting and collecting the internal signal of the simulated hardware neural network and calculating the change of the loss value to obtain the gradient of the loss value of the neural network relative to node a.
4. The training method for simulating a hardware neural network according to claim 1, characterized in that: The internal signals of the simulated hardware neural network include: simulated input signals of the simulated storage and computing integrated array of each layer of the neural network and simulated output signals of the simulated hardware neural network.
5. The training method for simulating a hardware neural network according to claim 1, characterized in that: The calculation of the loss value of the neural network includes: calculating the loss value Loss of the neural network according to the analog output signal of the converted analog hardware neural network and the label of the corresponding training data.
6. The training method for simulating a hardware neural network according to claim 5, characterized in that: The loss value Loss of the neural network is calculated based on the analog output signal of the converted analog hardware neural network and the label of the corresponding training data, and the mean square error function is used for calculation, and the calculation formula is: Where y is the analog output signal of the analog hardware neural network after ADC conversion, label is the label of the corresponding training data, and n is the number of samples of the training data.
7. The training method of simulating hardware neural network according to claim 1, characterized in that: The physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network is calculated based on the gradient of the loss value of the neural network relative to each nonlinear unit layer and the internal signal of the collected analog hardware neural network, as well as the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array. The calculation formula is: ΔW=η(I n ×δ| n ), Where W is the physical parameter matrix of the components in the analog storage and computing integrated array of the nth layer, η is the physical parameter matrix adjustment coefficient, δ| n is the gradient of the loss value of the neural network relative to the nth nonlinear unit layer, I n It is the input signal of the converted analog storage and computing array.
8. A training device for simulating a hardware neural network, characterized in that: include: A signal conversion module, used to convert training data into analog signals and input them into the analog hardware neural network; A perturbation signal generation and injection module is used to inject perturbation signals into nodes of nonlinear units in the simulated hardware neural network; The perturbation signal detection and readout module is used to collect the internal signals of the analog hardware neural network, convert them into digital signals, and send them to the system control module; The system control module is used to calculate the loss value of the neural network according to the internal signal of the converted analog hardware neural network; calculate the gradient of the loss value of the neural network relative to the node a according to the change of the loss value of the neural network before and after the perturbation is injected; control the perturbation to traverse the nodes, calculate the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network according to the gradient of the loss value of the neural network relative to each nonlinear unit layer and the collected internal signal of the analog hardware neural network, and the connection relationship between each nonlinear unit layer and the elements in the analog storage and computing integrated array; adjust the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network according to the physical parameter matrix adjustment amount of the elements in the analog storage and computing integrated array of each layer of the neural network; The gradient of the loss value of the neural network relative to the node a is calculated based on the change of the loss value of the neural network before and after the perturbation is injected, and the calculation formula is: In the formula, Represents the gradient of the loss value of the neural network relative to node a, replaced by the amplitude Δz of the perturbation signal z Calculate and replace the change in the loss value of the neural network before and after the perturbation is injected Perform calculations; The gradient of the loss value of the neural network relative to each nonlinear unit layer is composed of the gradient of the loss value of the neural network relative to the nodes of each nonlinear unit, expressed as a vector, and its calculation formula is: Where δ is the gradient of the loss value of the neural network relative to the nonlinear unit layer, and the subscript n represents the nth nonlinear unit layer. Represents the gradient value of the loss value of the neural network relative to different nodes, and m is the total number of nonlinear unit nodes in the nth layer.
9. The training device for simulating hardware neural network according to claim 8, characterized in that: The acquisition of internal signals of the simulated hardware neural network includes: acquiring analog input signals of the analog storage and computing integrated array of each layer of the neural network and analog output signals of the simulated hardware neural network.
10. The training device for simulating hardware neural network according to claim 8, characterized in that: The analog storage and computing integrated array includes a memristor array, a current mirror array or a floating gate transistor array; for the memristor array, the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted by using a pulse signal to modulate the conductance of the memristor array; for the current mirror array, the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted by using a pulse signal to update the value in the switch register, thereby changing the switching state of the transistor in the current mirror; for the floating gate transistor array, the physical parameters of the elements in the analog storage and computing integrated array of each layer of the neural network are adjusted by adjusting the gate voltage applied to the transistor.
11. The training device for simulating hardware neural network according to claim 8, characterized in that: The amplitude and frequency of the perturbation signal generated by the perturbation signal generation and injection module are adjustable.
12. The training device for simulating hardware neural network according to claim 8, characterized in that: The perturbation signal generation and injection module comprises a voltage source / current source, an adjustable resistor and a multi-way switch; the voltage source / current source generates a reference bias signal, and utilizes the resistance change of the adjustable resistor to generate a perturbation signal with adjustable amplitude; The multi-way switch is used to selectively connect the nodes and inject perturbation signals into the nodes.
Citation Information
Patent Citations
Memristor-based neural network training method and memristor-based neural network training device
CN110796241A
Analog hardware implementation of trained neural networks for voice sharpness
CN117716370A