A method for training weights of a memristor neural network

By modifying the conductance of the memristor array and iteratively optimizing based on changes in the loss value, the performance degradation of the memristor neural network after offline training was solved, and the recognition accuracy was improved.

CN117131917BActive Publication Date: 2026-03-17UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

When existing memristor neural networks are trained offline and then ported to an array, they suffer from loss of accuracy and performance degradation, especially in classification tasks where classification accuracy is reduced.

Method used

By modifying the conductance value on the memristor array and deciding whether to save the modification based on the change in loss value before and after each modification, the conductance value is iteratively optimized, ultimately improving the performance of the memristor neural network.

Benefits of technology

The recognition accuracy of the memristor neural network was improved from 42% to 82%, solving the problem of performance degradation after offline training. The method is simple and easy to automate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117131917B_ABST
    Figure CN117131917B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of memristor neural network calculation, and particularly relates to a kind of memristor neural network weight training method.The present application writes neural network weight parameter into memristor array, and the conductance value of the memristor is increased by ΔG1 by applying forward pulse to the memristor.If the loss value of the inference process after modification is reduced compared with before modification, the present modification is saved;if the loss value generated by the inference process after the conductance value of the memristor is increased is increased compared with before modification, reverse pulse is applied to the memristor, so that the conductance value of the memristor is reduced by 2ΔG2;Such cycle makes the weight precision obtained by the present application for the target memristor approach to the ideal value in a way of successive approximation.The present application effectively solves the defect that the performance of neural network is reduced after the neural network is transplanted to the memristor in an offline training mode in the prior art, and the memristor neural network weight training rule proposed in the present application is simple and easy to realize automation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of memristor neural network computing, and specifically relates to a method for training weights in a memristor neural network. Background Technology

[0002] Memristors are capable of running neural network algorithms efficiently in a "memory computing" manner and are considered one of the most promising basic electronic components in the post-Moore era.

[0003] Existing memristor neural networks generally adopt an offline training method (ex situ) during deployment. That is, the neural network to be deployed is first trained in a computer and its main parameters (network weight values ​​and bias values) are extracted. Then, the parameter values ​​are quantized into the conductance values ​​of the memristor and finally written into the memristor array through electrical pulses.

[0004] However, because the conductivity of memristors is lower than that of the weights in a computer-trained neural network, there is a loss of accuracy during offline training. Furthermore, the conductivity of memristors fluctuates over time, leading to performance degradation when a neural network trained offline is ported to a memristor array. Typically, in classification tasks, the classification accuracy of a memristor neural network trained offline is lower than that of a neural network trained in a computer. Summary of the Invention

[0005] To address the aforementioned problems and shortcomings, and to resolve the performance degradation of neural networks after offline training is implemented on memristors in existing technologies, this invention provides a memristor neural network weight training method to improve recognition accuracy after offline training. After the neural network weight parameters are written into the memristor array, the conductance values ​​are modified by trial and error. Based on a comparison of the change in loss values ​​generated during the inference process before and after each conductance modification, the method determines whether to save the current conductance value modification and the direction of subsequent conductance value updates. This iterative modification of the conductance values ​​of relevant memristors on the memristor array ultimately improves the performance of the memristor neural network.

[0006] A method for training weights in a memristor neural network, the specific steps of which are as follows (e.g.) Figure 1 As shown):

[0007] Step 1: Train a neural network in a computer, quantize its network weight parameters into memristor conductance values, and write them into the memristor array by voltage pulses.

[0008] Step 2: Encode the training set samples (such as the MNIST dataset) into voltage vectors and feed them into the memristor array. Measure and calculate the loss value L0 corresponding to the target memristor at this time. The loss value is the cross-entropy between the target vector and the actual obtained vector.

[0009] Step 3: Increase the conductance of the target memristor in the memristor array by ΔG1 by applying a voltage pulse, and calculate the corresponding loss value L1 of the memristor at this time.

[0010] Let the current conductance state of the memristor be G1, and the two adjacent conductance states be G0 and G2, and satisfy G0 < G1 < G2, then 0 < ΔG1 < (G2 - G1).

[0011] Step 4: If L0 is less than L1, then reduce the conductance of the memristor by 2ΔG2 by applying a reverse voltage pulse, and retain the modified conductance value of the memristor. Otherwise, retain the modified conductance value of the target memristor in Step 3.

[0012] Let the current conductance state of the memristor be G4, and the two adjacent conductance states be G3 and G5, and satisfy G3 < G4 < G5, then 0 < ΔG2 < (G4 - G3).

[0013] Step 5: Repeat steps 2 to 4 n times for the target memristor corresponding to the network weight parameters of the last layer in the neural network until the recognition accuracy is improved to 80% and the neural network weight training of the target memristor is completed; and traverse all target memristors in the memristor array.

[0014] Furthermore, the aforementioned To address the issue of ΔG2, if the value of ΔG1 is too large, it will make successive approximations difficult or even impossible to converge. If the value is too small, it will require a large number of iterations n to converge, which in turn leads to a dilemma of high computational resource consumption.

[0015] Furthermore, in step 2, the training samples are datasets used for classification and recognition tasks, such as the MNIST dataset or the CIFAR-10 dataset.

[0016] Furthermore, in step 5, 2≤n is required to form the performance optimization concept of successive approximation. However, when the number is too large, it will consume computing resources and the optimization effect will gradually decrease.

[0017] In summary, this invention writes the neural network weight parameters into a memristor array, attempts to modify the conductance value of the target memristor, and compares the change in the loss value generated during the inference process before and after each conductance modification to determine whether to save the current conductance value modification. This process is repeated for all target memristors on the memristor array to ultimately complete the training of the memristor neural network weights. By applying a positive pulse to the memristor, the conductance value of the memristor is increased by ΔG1. If the loss value during the inference process decreases after the modification compared to before the modification, the modification is saved; if the loss value during the inference process increases after the increase in the memristor conductance value, a negative pulse is applied to the memristor, causing the conductance value to decrease by 2ΔG2. This cycle is repeated to ensure that the weight accuracy obtained by training the target memristor in this invention successively approaches the ideal value. This invention effectively solves the defect in the prior art where the performance of the neural network degrades after being ported to a memristor using offline training. Furthermore, the memristor neural network weight training rules proposed in this invention are simple and easy to automate. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the method flow of the present invention.

[0019] Figure 2 The MNIST dataset sample used in the example.

[0020] Figure 3 This is a schematic diagram illustrating the principle of matrix multiplication for memristor arrays.

[0021] Figure 4 The image shown is a rendering of an example. Detailed Implementation

[0022] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.

[0023] A method for training weights in a memristor neural network (e.g.) Figure 1 As shown in the figure, i represents the index of the target memristor in the memristor array, and j represents the current traversal number.

[0024] In this embodiment, a two-layer fully connected neural network (with an input layer containing 784 neurons, a hidden layer containing 50 neurons, and an output layer containing 10 neurons) is used to process images in the MNIST dataset. Figure 2 This embodiment uses [the method] for identification. The specific operating procedure is as follows:

[0025] Step 1: The trained neural network weight parameters are quantized into memristor conductance values ​​and written into the memristor array by applying corresponding voltage pulses.

[0026] Step 2: Expand 100 single-channel 8-bit depth images with a pixel size of 28×28 into a matrix of 100 rows and 784 columns according to the pixel value of each pixel, and encode the matrix into 100 voltage vectors with a dimension of 784 according to the amplitude encoding principle.

[0027] Step 3: 100 voltage vectors with 784 dimensions are sequentially applied to each row of the relevant memristors in the memristor cross array. According to Ohm's law and Kirchhoff's current law, the current value output by each column of the relevant memristor represents the matrix-vector multiplication result of the input voltage vector and the memristor's conductance matrix. Figure 3 ).

[0028] Step 4: Activate the multiplication result using the activation function Softmax(x). The activation functions used include, but are not limited to, Sigmoid(x), Tanh(x), Relu(x), and Softmax(x).

[0029] Step 5: The activated vector signal is encoded into a voltage vector according to the amplitude encoding principle and applied to the relevant target memristor in the memristor array. The resulting multiplication result is activated again using the Softmax(x) activation function.

[0030] Step 6: Calculate the loss value L0 generated during this inference process by combining the output of the activation function in Step 5 and the label vectors of the 100 images used in this inference.

[0031] Step 7: Apply 10 positive square wave voltage pulses with a pulse width of 400ms and an amplitude of 5V to the memristors in 1 row and 1 column of the memristor array to increase the conductance of the memristor by 3nS; and perform the same operation as in steps 2 to 6 to obtain the loss value L1.

[0032] Step 8: If L1 < L0, save the current modification operation on the resistor in the memristor array. Otherwise, apply 20 reverse voltage pulses with a pulse width of 400ms and an amplitude of 5V to the memristor in row 1 and column 1 of the memristor array.

[0033] Step 9: Repeat steps 2 to 8 5000 times for the memristors corresponding to the weight parameter matrix of the second layer of the neural network, and then traverse all target memristors in the memristor array.

[0034] In this embodiment, the computer-trained neural network achieves a 92% recognition accuracy when identifying the MNIST dataset. After quantizing its network parameters into 3-bit values ​​and mapping them to memristor conductance values, and writing these values ​​into the memristor array, the recognition accuracy drops to 42%. Subsequently, the weight training method provided in this embodiment is used to adjust the conductance values ​​on the memristor array, and the recognition accuracy increases to 82% (e.g., ...). Figure 4 (As shown). This invention is applicable to image recognition and classification using memristor neural networks. The training samples are datasets used for classification tasks, and specific image datasets include the MNIST dataset, the CIFAR-10 (Canadian Institute for Advanced Research-10) dataset, etc.

[0035] As can be seen from the above embodiments, after the neural network weight parameters are written into the memristor array, the present invention attempts to modify the conductance value of the target memristor and determines whether to save the current conductance value modification and the direction of subsequent conductance value updates by comparing the changes in the loss value generated during the inference process before and after each conductance modification. The conductance values ​​of the relevant memristors on the memristor array are iteratively modified in turn, and the performance of the memristor neural network is finally improved in a successive approximation manner.

Claims

1.A method for training weights of a memristor neural network, characterized in that, The specific steps are as follows: Step 1, training a neural network in a computer, quantifying the network weight parameters of the neural network into the conductance values of the memristor, and writing the conductance values into the memristor array by voltage pulse; Step 2, encoding the training set samples into voltage vectors and sending them into the memristor array, measuring and calculating the loss value L0 corresponding to the target memristor at this time, and the loss value is the cross entropy of the target vector and the actual obtained vector; Step 3, increasing the conductance value of a single memristor in the memristor array by ΔG1 by applying a voltage pulse, and calculating the loss value L1 corresponding to the memristor at this time; Step 4, if L0 < L1, decrease the conductance value of the memristor by 2ΔG2 by applying a reverse voltage pulse, and retain the modification result of the conductance value of the memristor; otherwise, retain the modification result of the conductance value of the memristor in step 3; Step 5, repeating steps 2 to 4 for n times for the target memristor corresponding to the network weight parameters of the last layer of the neural network, until the recognition accuracy is improved to 80%, and the neural network weight training of the target memristor is completed; and traversing all target memristors in the memristor array; The ΔG1= , the current conductance state of the memristor is G1, the adjacent two conductance states are G0 and G2, and G0 , the current conductance state of the memristor is G4, the adjacent two conductance states are G3 and G5, and G3 G4 G5 . 2.The method of claim 1, wherein: The training samples in step 2 are data sets for classification and recognition tasks. 3.The method of claim 2, wherein: The data set for classification and recognition task is MNIST data set or CIFAR-10 data set. 4.The method of claim 1, wherein: In step 5, 2 ≤ n.