Memory and training method for memory-based neural network-like
By obtaining the memory's conversion function and influencing factors, a training plan is determined. Combining computer simulation and software-aided simulation of non-ideal conditions, the neural network is trained, solving the problem of decision inaccuracy caused by the non-ideal characteristics of the memory and improving the decision accuracy of the neural network within the memory.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MACRONIX INTERNATIONAL CO LTD
- Filing Date
- 2021-08-04
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies, when implementing neural networks using memory, fail to effectively consider the non-ideal characteristics of memory, resulting in insufficient decision-making accuracy.
By obtaining the memory's conversion function, determining the training plan based on ideal conditions and influencing factors, and combining computer simulation and software-aided simulation of non-ideal conditions, the neural network is trained, and the resistance value of the memory cell is adjusted to achieve weight programming.
It improves the decision-making accuracy of in-memory neural networks, reduces errors caused by memory characteristics, and enhances the accuracy of computation results.
Smart Images

Figure CN115688899B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a memory and a training method for a memory-based neural network. Background Technology
[0002] Neural networks are mathematical models that can be used for machine learning. In the past, neural networks were built into mathematical models in software on computer devices, and the processor performed calculations based on these models. With increasing demands for processing speed, using high-speed memory to implement neural networks has become a research focus. This approach is called computing in memory. While computing in memory has many advantages, due to the characteristics of memory, such as its susceptibility to temperature and the number of read / write operations, the relationship between the input and output of a memory cell is often not ideally linear. How to reduce the adverse effects of non-ideal memory on the accuracy of decisions made based on the results of computing in memory is an important issue.
[0003] Public content
[0004] An embodiment of the present invention discloses a training method for a memory-based neural network. The training method includes: obtaining one or more transformation functions of a memory corresponding to one or more influence factors; determining a training plan based on an ideal condition and the one or more influence factors; training the neural network according to the training plan and the one or more transformation functions to obtain multiple weights of the trained neural network; and programming the memory according to these weights.
[0005] Another embodiment of the present invention discloses a memory. The memory includes a plurality of memory cells for representing a plurality of synapses of a class of neural networks. Each memory cell includes a resistor. The resistance values of these resistors are determined by: obtaining one or more transformation functions corresponding to one or more influencing factors for these memory cells; determining a training plan based on an ideal condition and the one or more influencing factors; training the class of neural networks according to the training plan and the one or more transformation functions to obtain a plurality of weights for the synapses of the trained class of neural networks; and determining the resistance values of the resistors of these memory cells according to these weights.
[0006] To provide a better understanding of the above and other aspects of the present invention, specific embodiments are described below in conjunction with the accompanying drawings: Attached Figure Description
[0007] Figure 1 This is a schematic diagram of the operational memory.
[0008] Figure 2This is a flowchart of a training method according to an embodiment of the present invention.
[0009] Figure 3 This is a schematic diagram of the transformation function.
[0010] Figure 4 This is a flowchart for determining a training plan according to an embodiment of the present invention.
[0011] Explanation of reference numerals in the attached figures
[0012] 10: Operational Memory
[0013] C11~C33: Storage Units
[0014] WL1~WL3: Word lines
[0015] BL1~BL3: Bit lines
[0016] S201~S207, S401~S407: Steps Detailed Implementation
[0017] Please refer to Figure 1 , Figure 1 This is a schematic diagram of the operational memory. The operational memory 10 includes multiple word lines WL1-WL3, multiple bit lines BL1-BL3, and multiple memory cells C11-C33. Each memory cell C11-C33 is coupled to a corresponding word line and a corresponding bit line. Each memory cell C11-C33 may include a variable resistor with resistance values R11-R33, respectively. In one embodiment, the variable resistor can be implemented using a transistor. The operational memory 10 can implement a type of neural network sum-of-products operation through in-memory operations. The operating principle of the operational memory 10 is detailed below.
[0018] Storage cells C11–C33 can be used to represent synapses in a neural network. The resistance values R11–R33 or conductance values (i.e., the reciprocals of the resistance values) of the variable resistors in storage cells C11–C33 can be used to represent the weights of the synapses. The input voltages V1–V3 of word lines WL1–WL3 can be used to represent the input data. The output currents I1–I3 of bit lines BL1–BL3 are respectively:
[0019] I1=V1*1 / R11+V2*1 / R21+V3*1 / R31,
[0020] 12=V1*1 / R12+V2*1 / R22+V3*1 / R32,
[0021] I3=V1*1 / R13+V2*1 / R23+V3*1 / R33.
[0022] Currents I1 to I3 represent the results of the input data after processing by a neural network. Currents I1 to I3 can be fed into a decision circuit (not shown) for further processing to generate a decision.
[0023] It should be noted that, Figure 1 The examples provided are simplified for ease of explanation. In practical applications, the number of storage units in the computational memory is usually very large, and the architecture of the computational memory will also vary depending on the neural network to be implemented.
[0024] To improve decision-making accuracy, it is usually necessary to train a neural network. For example, training data is input into the neural network for computation, a decision is generated based on the computation result, the decision is compared with the ground truth corresponding to the training data, and the weights in the neural network are adjusted based on the comparison result. Currently, there are two training methods for memory-based neural networks: (1) training using a computer device and software based on an ideal mathematical model of the neural network, and (2) training on memory. However, method (1) does not take into account the non-ideal characteristics of memory, and method (2) does not take into account the ideal mathematical model. Neural networks trained in both methods will result in insufficient accuracy of subsequent decisions when running on memory. To solve the above problems, this invention proposes a training method for memory-based neural networks.
[0025] Please refer to Figure 2 , Figure 2 This is a flowchart of a training method according to an embodiment of the present invention. This training method can be applied to memory-based neural networks.
[0026] In step S201, one or more transformation functions corresponding to one or more influencing factors are obtained for a memory corresponding to a type of neural network. The memory corresponding to the type of neural network indicates that the memory is used as hardware to implement that type of neural network. The transformation function represents the relationship between the input and output of the memory's storage cells corresponding to the influencing factors. Influencing factors may include different temperatures, different read / write cycles, different input voltages, variations during each read operation, memory retention capability, and write error, etc. Memory retention capability refers to the time data is stored in the storage cell. Write error refers to the difference between the actual value written during programming and the ideal value. For example, influencing factors may include a temperature of 40 degrees Celsius, a temperature of 50 degrees Celsius, 5,000 read / write cycles, 10,000 read / write cycles, etc. In real-world scenarios, the components included in the storage cells, such as transistors and variable resistors, are often non-ideal. This non-ideality causes the ratio of the storage cell's input voltage to output current to be affected by the influencing factors rather than being a constant value.
[0027] Please refer to Figure 3 , Figure 3 This displays the relationship between the input voltage and output current of a memory cell corresponding to a specific temperature. Figure 3 In the diagram, the horizontal axis represents the input voltage of the memory cell, and the vertical axis represents the output current of the memory cell. Multiple curves represent different conversion functions, corresponding to various resistor values to be programmed for the memory cell. Ideally, specific weights correspond to specific resistor values; if the weights remain constant, the resistor values should not change. That is, ideally, the ratio between input voltage and output current should be constant, meaning the conversion function should be a straight line. However, in real-world (non-ideal) conditions, the ratio of input voltage to output current changes with the input voltage. Therefore, from... Figure 3 As can be seen, the transformation function in actual situations is not a straight line.
[0028] It should be noted that the conversion function can be obtained through actual testing, based on historical records, or by any other means. This invention is not limited to this.
[0029] In step S203, a training plan is determined based on one or more influencing factors and an ideal state. The ideal state represents a scenario where the memory is unaffected by any influencing factors and perfectly conforms to the ideal mathematical model of a neural network. In other words, under ideal conditions, for each memory cell, the ratio of the input voltage to the output current corresponding to a specific resistance value is a constant. In one embodiment, determining the training plan may include steps S401 to S407, such as... Figure 4As shown. In step S401, an ideal or non-ideal situation is determined. If the situation is determined to be ideal, step S403 is executed; if the situation is determined to be non-ideal, step S405 is executed. In step S403, the number of training iterations is determined, and the training plan is updated. In step S405, an influencing factor is determined. That is, after selecting one influencing factor from among many, step S403 is executed to determine the number of training iterations for that training factor. In step S407, it is determined whether the training plan configuration is complete. If the determination is no, return to step S401; if the determination is yes, the process ends. To make it easier to understand, a practical example is given below. First, steps S401 and S403 are executed to add the ideal scenario and five iterations to the training plan. Then, the process returns to step S401 to determine the non-ideal scenario, and steps S405 and S403 are executed to determine the influencing factor as a temperature of 40 degrees Celsius and ten iterations, adding these to the training plan. Next, the process returns to step S401 to determine the non-ideal situation again, and steps S405 and S403 are executed to determine the influencing factor as ten thousand read / write operations and seven iterations, adding these to the training plan. The process then ends. Thus, the training plan is: [(ideal scenario, five iterations); (temperature 40 degrees Celsius, ten iterations); (ten thousand read / write operations, seven iterations)]. In one embodiment, the content of the training plan can be further scheduled. For example, the scheduled training plan in the aforementioned example could be: [(Ideal condition, quadratic); (40 degrees Celsius, 5 times); (Ideal condition, 1 time); (10,000 read / write operations, 3 times); (Ideal condition, 1 time); (10,000 read / write operations, 4 times); (Ideal condition, 1 time); (40 degrees Celsius, 5 times)]. That is, training for ideal conditions and different influencing factors can be interleaved, and training for the same influencing factor does not need to be completed consecutively. Interleaving training for different influencing factors prevents the neural network from being overly affected by specific factors, thus allowing multiple influencing factors to contribute more evenly to the neural network. The actual training plan can adaptively configure the frequency and number of training iterations of each influencing factor according to the actual characteristics of the memory. For example, when the memory is sensitive to temperature, increasing the frequency and number of training iterations of the temperature influencing factor in the training plan can make the trained neural network better able to cope with the effects of temperature changes.
[0030] In step S205, the neural network is trained using a computer device and software simulation according to a training plan and a transformation function associated with the training plan, to obtain multiple weights of the trained neural network. Simulation refers to the execution of mathematical model calculations of the neural network by the processor of the computer device, and the use of software to simulate non-ideal conditions. The use of software to simulate non-ideal conditions means that each time training corresponding to an influencing factor is performed, for each synapse in the neural network, the output value output to that synapse is adjusted according to the transformation function corresponding to the influencing factor, the weight corresponding to that synapse, and the input value input to that synapse. In one embodiment, the training of the neural network can be performed sequentially according to the training plan. In another embodiment, the training of the neural network can be performed in any order according to the training plan. Generally, a single training process includes: inputting training data into the neural network; calculating one or more decision parameters using the neural network based on the training data; generating a decision based on the decision parameters; calculating a score based on the decision and a solution corresponding to the training data; and adjusting one or more weights of the neural network based on the score. Since many prior art techniques already exist for details of the training process, they will not be described further here.
[0031] In step S207, the storage units of the programmed memory are obtained according to the weights to obtain the memory (operation memory) used to implement the neural network.
[0032] It should be noted that the training method of this invention can be applied to any suitable memory type. For example, phase-change memory (PCM) and ferroelectric random access memory (FeRAM) are both suitable for the training method proposed in this invention.
[0033] Furthermore, based on the above training method, the present invention also proposes a memory. The memory has multiple storage cells. Each storage cell includes a resistor. These storage cells represent multiple synapses of a neural network. The resistance values of these resistors in the storage cells are determined according to multiple weights obtained through the above training method.
[0034] Please refer to Table 1. In Table 1, ACci represents the correctness of the decision obtained by performing calculations based on the trained neural network under ideal conditions simulated by a computer device, and ACCn represents the correctness of the decision obtained by performing calculations based on the memory used to implement the trained neural network. As can be seen from Table 1, in the five tests, the difference between the correctness under ideal conditions and the correctness of calculations within memory was within 2%. This indicates that the training method proposed in this invention can effectively improve the problem of reduced correctness of subsequent decisions caused by the inherent characteristics of memory when implementing a neural network using memory.
[0035] Table 1
[0036] ACCi ACCn |ACCi-ACCn| / ACCi Test 1 0.8756 0.8818 0.71% Test 2 0.8668 0.8735 0.77% Test 3 0.8683 0.8745 1.55% Test 4 0.8731 0.8651 0.78% Test 5 0.8585 0.8529 0.65%
[0037] In summary, although the present invention has been disclosed above with reference to embodiments, it is not intended to limit the invention. Those skilled in the art to which this invention pertains can make various modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of this invention shall be determined by the appended claims.
Claims
1. A training method for memory-based neural networks, comprising: Obtain one or more transformation functions corresponding to one or more influence factors from a memory; A training plan is determined based on an ideal situation and one or more influencing factors. According to the training plan and the one or more transformation functions, the neural network of this type is trained to obtain multiple weights of the trained neural network of this type. as well as The memory is programmed according to these weights; The one or more influencing factors include temperature, number of read / write operations, input voltage, changes in each read operation, memory retention capability, and write error. According to the training plan and the one or more transformation functions, the neural network is trained to obtain multiple weights of the trained neural network. When training is performed on the determined influencing factor, the multiple outputs of these synapses are adjusted according to the one or more transformation functions corresponding to the determined influencing factor, the multiple inputs of the multiple synapses of the neural network, and the multiple weights of these synapses to be trained.
2. The training method according to claim 1, wherein determining a training plan based on an ideal condition and the one or more influencing factors comprises: Determine the first number of training sessions for this ideal condition and update the training plan accordingly; Select at least one of the one or more influence factors, determine a second number of training iterations corresponding to each of the selected one or more influence factors, and update the training plan.
3. The training method according to claim 2, wherein in the training plan, training corresponding to the ideal situation is interspersed among training corresponding to the one or more influencing factors.
4. A memory, comprising: Multiple storage cells, representing multiple synapses in a neural network, each storage cell including a resistor whose resistance value is determined as follows: Obtain one or more transformation functions corresponding to one or more influence factors for these storage units; A training plan is determined based on an ideal situation and one or more influencing factors. According to the training plan and the one or more transformation functions, the neural network is trained to obtain multiple weights of these synapses of the trained neural network. as well as The resistance values of these resistors in these memory cells are determined based on these weights; The one or more influencing factors include temperature, number of read / write operations, input voltage, changes in each read operation, memory retention capability, and write error. According to the training plan and the one or more transformation functions, the neural network is trained to obtain multiple weights of the trained neural network. When training is performed on the determined influencing factor, the multiple outputs of these synapses are adjusted according to the one or more transformation functions corresponding to the determined influencing factor, the multiple inputs of the multiple synapses of the neural network, and the multiple weights of these synapses to be trained.
5. The memory of claim 4, wherein determining a training plan based on an ideal condition and the one or more influencing factors comprises: Determine the first number of training sessions for this ideal condition and update the training plan accordingly; Select at least one of the one or more influence factors, determine a second number of training iterations corresponding to each of the selected one or more influence factors, and update the training plan.
6. The memory of claim 5, wherein in the training plan, training corresponding to the ideal condition is interspersed among training corresponding to the one or more influencing factors.
Citation Information
Patent Citations
Memristor-based neural network training method and memristor-based neural network training device
CN110796241A
System and method using neural networks for analog-to-information processors
US10970441B1