Neural network training method and apparatus, device, and storage medium
By introducing a transmission gate into the CAM circuit and connecting it to the memory array, a control signal is generated to achieve bidirectional configuration of the data flow, which solves the problem that only forward calculation can be performed in the prior art and improves the efficiency of neural network training.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-06
- Publication Date
- 2026-03-24
AI Technical Summary
In the existing technology, AI accelerators based on new types of memory such as RRAM can only perform forward computation of neural networks and cannot support feedback computation, resulting in low training efficiency of neural network models.
By introducing a transmission gate into the CAM circuit and connecting it to the memory array, control signals are generated to achieve bidirectional configuration of data flow, supporting forward and backward propagation modes, and using a single set of input/output circuits for neural network training.
It realizes bidirectional configuration of data flow during neural network training, accelerates the computation of forward and backward propagation, and improves model training efficiency.
Smart Images

Figure CN117313806B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of model training, in particular to a neural network training method and device, equipment and storage medium. BACKGROUND
[0002] The neural network weight parameters are mapped in the non-volatile memory array, by applying different input signals to the memory array, and by using the principles of Kirchhoff's law and Ohm's law, efficient dot product calculation can be realized. This new computing paradigm can greatly accelerate model calculation, reduce data transmission overhead, and reduce computing energy consumption. However, in the current computing architecture based on RRAM and other new non-volatile memories, the input and output end composed of peripheral circuits cannot achieve bidirectional configuration of data, so it can only accelerate the forward calculation of the neural network, greatly limiting the application scenarios of the memory computing technology. In addition, due to the limitation of this hardware architecture that can only perform forward propagation calculation, when online learning is performed, only the forward calculation during the training process can be accelerated, and the back propagation and weight update calculation need to be performed on other computing platforms. This calculation mode limits the improvement of system computing energy efficiency, resulting in low training efficiency of the neural network model.
[0003] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY
[0004] The main purpose of the present application is to provide a neural network training method, device, equipment and storage medium, which aims to solve the technical problem that the existing AI accelerator using RRAM and other new memories does not support feedback calculation of the neural network during the neural network training process, resulting in low training efficiency of the neural network model.
[0005] To achieve the above purpose, the present application provides a neural network training method, which is applied to a neural network training system, the neural network training system comprising a CAM circuit and a memory array, and the neural network training method comprising the following steps:
[0006] Obtain the training phase information of the neural network to be trained, determine the memory computing mode according to the training phase information, and the memory computing mode comprises a forward propagation mode and a backward propagation mode;
[0007] Generate a control signal of the CAM circuit according to the memory computing mode;
[0008] Control the data flow direction of the target data in the memory array during the training process of the neural network to be trained based on the control signal.
[0009] Optionally, the CAM circuit comprises a transmission gate connected with the memory array.
[0010] The step of controlling the data flow direction of the target data in the memory array during the training of the neural network to be trained based on the control signal comprises:
[0011] Controlling the on-off state of the transmission gate in the CAM circuit based on the control signal.
[0012] Controlling the data flow direction of the target data in the memory array during the training of the neural network to be trained based on the on-off state.
[0013] Optionally, the control signal comprises a forward propagation signal and a backward propagation signal.
[0014] The step of controlling the data flow direction of the target data in the memory array during the training of the neural network to be trained based on the control signal comprises:
[0015] When the control signal is the forward propagation signal, the data flow direction of the target data in the memory array during the training of the neural network to be trained is a feedforward direction to perform feedforward calculation of the neural network to be trained.
[0016] When the control signal is the backward propagation signal, the data flow direction of the target data in the memory array during the training of the neural network to be trained is a feedback direction to perform feedback calculation of the neural network to be trained.
[0017] Optionally, the step of performing feedback calculation of the neural network to be trained comprises:
[0018] Determining an error term of the feedback calculation.
[0019] Determining a voltage vector corresponding to the feedback calculation according to the error term.
[0020] Performing feedback calculation of the neural network to be trained based on the voltage vector and the data flow direction of the memory array in the feedback direction.
[0021] Optionally, the forward propagation mode and the backward propagation mode share a set of input and output circuits.
[0022] Optionally, the memory array comprises a resistive random access memory, a phase change memory, a magnetic memory or a ferroelectric memory.
[0023] Optionally, the neural network training system comprises two sets of input and output circuits, and the input and output circuits are respectively used for performing feedforward calculation and feedback calculation of neural network training.
[0024] In addition, to achieve the above object, the present application also provides a neural network training device, which comprises:
[0025] The acquisition module is configured to acquire training phase information of the neural network to be trained, and determine a memory computing mode according to the training phase information, wherein the memory computing mode comprises a forward propagation mode and a backward propagation mode.
[0026] The generation module is configured to generate a control signal of the CAM circuit according to the memory computing mode.
[0027] The data flow control module is configured to control a data flow direction of target data in the memory array during the training of the neural network to be trained based on the control signal.
[0028] In addition, to achieve the above object, the present application also provides a neural network training device, which comprises a memory, a processor, and a neural network training program stored in the memory and executable on the processor, wherein the neural network training program is configured to implement the steps of the neural network training method as described above.
[0029] In addition, to achieve the above object, the present application also provides a storage medium, wherein the storage medium stores a neural network training program, and the neural network training program is executable on a processor to implement the steps of the neural network training method as described above.
[0030] The neural network training method of the present application is applied to a neural network training system comprising a CAM circuit and a memory array, and comprises the following steps: acquiring training phase information of a neural network to be trained, determining a memory computing mode according to the training phase information, wherein the memory computing mode comprises a forward propagation mode and a backward propagation mode; generating a control signal of the CAM circuit according to the memory computing mode; and controlling a data flow direction of target data in the memory array during the training of the neural network to be trained based on the control signal. According to the above method, the control signal of the CAM circuit is generated according to the memory computing mode, and the data flow direction of the target data in the memory array during the training of the neural network to be trained is controlled based on the control signal, so that the bidirectional configuration of the data flow during the training of the neural network can be realized, the calculation acceleration of the forward propagation and the backward propagation of the neural network can be completed, and the model training efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0031] Figure 1 is a structural schematic diagram of a neural network training device of a hardware running environment related to an embodiment scheme of the present application;
[0032] Figure 2 is a flowchart of a first embodiment of the neural network training method of the present application;
[0033] Figure 3 This is a schematic diagram of the data flow direction for accelerated neural network computation in the first embodiment of the neural network training method of the present invention;
[0034] Figure 4 This is a schematic diagram of the neural network feedback calculation data flow in the first embodiment of the neural network training method of the present invention;
[0035] Figure 5 This is a schematic diagram of a configurable data flow direction integrated computing architecture in the first embodiment of the neural network training method of the present invention.
[0036] Figure 6 This is a CAM circuit diagram of the first embodiment of the neural network training method of the present invention;
[0037] Figures 7-8 This is a schematic diagram of the data flow in the first embodiment of the neural network training method of the present invention;
[0038] Figure 9 This is a flowchart illustrating the second embodiment of the neural network training method of the present invention;
[0039] Figure 10 This is a schematic diagram of two sets of input / output circuits in the second embodiment of the neural network training method of the present invention;
[0040] Figure 11 This is a structural block diagram of the first embodiment of the neural network training device of the present invention.
[0041] Explanation of icon numbers:
[0042]
[0043]
[0044] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0045] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0046] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a neural network training device in the hardware operating environment involved in the embodiments of the present invention.
[0047] like Figure 1As shown, the neural network training device can include a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display, an input unit such as a keyboard, and can also include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a wireless fidelity (WI-FI) interface). The memory 1005 can be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk memory. The memory 1005 can also be a storage device independent of the aforementioned processor 1001.
[0048] Those skilled in the art can understand that Figure 1 The structure shown in the figure does not constitute a limitation on the neural network training device, and can include more or fewer components than the figure, or combine certain components, or different component arrangements.
[0049] As Figure 1 As shown, the memory 1005 as a storage medium can include an operating system, a network communication module, a user interface module, and a neural network training program.
[0050] In Figure 1 In the neural network training device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the neural network training device of the present application can be arranged in the neural network training device, and the neural network training device calls the neural network training program stored in the memory 1005 through the processor 1001, and executes the neural network training method provided by the embodiments of the present application.
[0051] Based on the above neural network training device, the embodiments of the present application provide a neural network training method, which is described with reference to Figure 2 , Figure 2 The flowchart of the first embodiment of the neural network training method of the present application is shown.
[0052] In this embodiment, the neural network training method is applied to a neural network training system, and the neural network training system includes a CAM circuit and a memory array. The neural network training method includes the following steps:
[0053] Step S10: Obtain the training phase information of the neural network to be trained, and determine the memory computing mode according to the training phase information, wherein the memory computing mode includes a forward propagation mode and a backward propagation mode.
[0054] It should be noted that the execution subject of the embodiment can be a computing service device with data processing, network communication and program running functions, such as a mobile phone, a tablet computer, a personal computer, etc., or an electronic device or a neural network training system capable of realizing the above functions. The neural network training system will be taken as an example to describe the embodiment and the following embodiments.
[0055] It should be understood that the calculation of the neural network is mainly a parameter-intensive operation dominated by matrix-vector multiplication, which runs through the forward propagation, backward propagation and weight update stages. For reference Figure 3 , Figure 3 Figure 1 is a schematic diagram of the neural network acceleration computing data flow direction of the first embodiment of the neural network training method of the present application; at present, the direction of data flow in the memory-computing integrated architecture based on RRAM new memory is from the input peripheral circuit to the output peripheral circuit through the RRAM new memory array, as shown in Figure 3 . That is, the input vector is mapped into a voltage vector, the input RRAM cross array is input, and the operation result of matrix-vector multiplication can be obtained at the output end. The physical principle of this calculation process is Ohm's law and Kirchhoff's law. However, since the direction of data flow can only realize feedforward calculation, Figure 3 the architecture obviously cannot calculate other calculations of the neural network, which limits the application scenarios and potential of the memory-computing integration technology.
[0056] Therefore, in order to tap the potential of the RRAM computing unit, the embodiment proposes a thought that the direction of data flow can be reversed to complete the feedback calculation of the neural network. For reference Figure 4 , Figure 4 Figure 2 is a schematic diagram of the neural network feedback calculation data flow direction of the first embodiment of the neural network training method of the present application; the residual error in the backward propagation calculation process is mapped through the voltage vector by inputting the signal at the other end of the array, and the residual error of the previous layer can be obtained at the other end. Based on this idea, the embodiment proposes a smart gating switch circuit with a custom acceleration mode (CAM), that is, the CAM circuit, which can share a set of input and output circuits through a controller, for reference Figure 5 , Figure 5 Figure 3 is a schematic diagram of the memory-computing integrated architecture with configurable data flow direction of the first embodiment of the neural network training method of the present application; Figure 5G11-Gij matrix in the CAM circuit is the memory array, and the memory array is peripherally provided with a CAM circuit for configuring a data flow direction.
[0057] It should be noted that the forward propagation mode and the backward propagation mode correspond to feedforward calculation and feedback calculation of the neural network to be trained respectively. The forward propagation mode and the backward propagation mode share a set of input and output circuits. If the training stage information is that the neural network to be trained needs to perform feedback calculation, the memory calculation mode is the backward propagation mode, and if the training stage information is that the neural network to be trained needs to perform feedforward calculation, the memory calculation mode is the forward propagation mode.
[0058] Step S20: generating a control signal of the CAM circuit according to the memory calculation mode.
[0059] It should be noted that the CAM circuit includes a plurality of transmission gates connected with the memory array, and by controlling the on-off state of the transmission gates in the CAM circuit, the data flow direction of the data flow in the memory array during the neural network model training process can be realized. The control signal of the CAM circuit according to the memory calculation mode can be a forward propagation signal generated when the memory calculation mode is the forward propagation mode, the forward propagation signal being used to control the forward propagation of the data flow in the memory array to realize the feedforward calculation of the neural network model. When the memory calculation mode is the backward propagation mode, a backward propagation signal is generated, the backward propagation signal being used to control the backward propagation of the data flow in the memory array to realize the feedback calculation of the neural network model.
[0060] Step S30: controlling the data flow direction of the target data in the memory array during the training process of the neural network to be trained based on the control signal.
[0061] It should be noted that the target data can be data in the training process of the neural network to be trained, and in the feedforward calculation, the target data can be a voltage vector corresponding to sample data; and in the feedback calculation, the target data can be a voltage vector corresponding to an error term. The control of the data flow direction of the target data in the memory array during the training process of the neural network to be trained based on the control signal can be to control the on-off state of the transmission gates in the CAM circuit according to the control signal, and to control the data flow direction of the target data in the memory array during the training process of the neural network to be trained according to the on-off state of the transmission gates.
[0062] In specific implementation, reference can be made to Figure 6 , Figure 6 a CAM circuit diagram of the first embodiment of the neural network training method of the present application; in Figure 6In the shown circuit diagram, the Controller accepts control signals to control the RRAM memory computing unit (i.e. memory array), for example, CAM=“1” can be defined as feedforward mode, and CAM=“0” can be defined as backpropagation mode. Based on this, when CAM=“1” in the control signal, Figure 6 the transmission gate T B1 , T B2 , …, T Bk , …, T Bi , T S1 , T S2 , …, T Sm , …, T Sj are closed, and the transmission gate and are open, at this time, the data flow direction on the memory array is as shown by the arrows in Figure 7 , Figure 7 is a data flow direction schematic diagram of the first embodiment of the neural network training method of the present application. When CAM=“0”, Figure 6 the transmission gate T B1 , T B2 , …, T Bk , …, T Bi , T S1 , T S2 , …, T Sm , …, T Sj are open, and the transmission gate and are closed, at this time, the data flow direction on the memory array is as shown by the arrows in Figure 8 , Figure 8 is a data flow direction schematic diagram of the first embodiment of the neural network training method of the present application
[0063] Further, the memory cells of the memory array are not limited to a crossbar array of resistive random access memory (RRAM), magnetoresistive random access memory (MRAM), phase change random access memory (PCRAM), ferroelectric RAM (FeFET), and the like. The neural network training method proposed in the embodiments can also achieve the same effect. The application object of the neural network training method proposed in the embodiments is not limited to the deep neural networks (DNN) mentioned in the description, and can be applied to various neural networks such as multilayer perceptron (MLP), convolutional neural network (CNN), long short-term memory (LSTM) neural network, recurrent neural network (RNN), reinforcement learning (Reinforcement Learning) network, and Transformer. These neural networks can be used in various application scenarios such as image recognition, speech recognition, natural language processing, and autonomous driving.
[0064] The embodiment obtains training phase information of a neural network to be trained, determines a memory computing mode according to the training phase information, the memory computing mode including a forward propagation mode and a backward propagation mode, generates a control signal of a CAM circuit according to the memory computing mode, and controls a data flow direction of target data in a memory array during a training process of the neural network to be trained based on the control signal. The above-mentioned method of the embodiment generates a control signal of a CAM circuit according to a memory computing mode, controls a data flow direction of target data in a memory array during a training process of a neural network to be trained based on the control signal, can realize bidirectional configuration of data flow during a neural network training process, complete calculation acceleration of forward propagation and backward propagation of a neural network, and improve model training efficiency.
[0065] The embodiment introduces an innovative circuit design scheme in a memory array composed of new type memories such as resistive random access memory (RRAM), and is based on the data calculation mode in the neural network training process, and is fully adapted to hardware, and a gating switch circuit (i.e., CAM circuit) is introduced to bidirectionally configure the data flow. The circuit can be instructed by a user or a computer to specify whether the data flow direction is forward propagation or backward propagation. In the circuit design, the gating switch circuit is composed of a transmission gate with limited energy consumption and area overhead, and in addition to realizing the bidirectional configuration of the data flow, the peripheral circuit is also multiplexed, and only one set of input and output circuit can realize the forward and backward propagation calculation of the neural network. This ingenious design greatly improves the computing energy efficiency. This implementation brings more possibilities to the application scenarios of AI accelerators based on new type memories such as RRAM. In addition to small computing power computing platforms on the edge side and the edge side, it also provides a candidate for the construction scheme of large computing power platforms.
[0066] Reference Figure 9 , Figure 9 The flowchart of the second embodiment of the neural network training method of the present application is shown.
[0067] Based on the first embodiment, in the embodiment, the control signal includes a forward propagation signal and a backward propagation signal, and the step S30 includes:
[0068] Step S301: When the control signal is a forward propagation signal, the data flow direction of the target data in the neural network training process in the memory array is a feedforward direction, so as to perform feedforward calculation of the neural network to be trained.
[0069] Step S302: When the control signal is a backward propagation signal, the data flow direction of the target data in the neural network training process in the memory array is a feedback direction, so as to perform feedback calculation of the neural network to be trained.
[0070] It should be noted that the feedforward direction can be the data flow direction of the feedforward calculation process of the neural network to be trained. For details, please refer to Figure 7 . The feedback direction can be the data flow direction of the feedback calculation process of the neural network to be trained. For details, please refer to Figure 8 . The step of performing feedback calculation of the neural network to be trained includes:
[0071] determining an error term of feedback calculation;
[0072] determining a voltage vector corresponding to the feedback calculation according to the error term;
[0073] performing feedback computation of the to-be-trained neural network based on the voltage vector and data flow direction of the memory array according to the feedback direction.
[0074] It should be noted that the determining the voltage vector corresponding to the feedback computation according to the error term can be mapping the error term to the voltage vector. The error term for determining the feedback computation can specifically include: calculating the forward propagation process of the neural network to obtain the activation value of each layer:
[0075] a (0)
[0076] In the embodiment, a (l) is used to represent the activation value of the lth layer, and x is used to represent the input sample.
[0077] For each layer l from 1 to L, the following steps are performed:
[0078] Calculate the weighted input:
[0079] z (l) (1-1) a (l-1) (l-1)
[0080] Calculate the activation value:
[0081] a (1) (1)
[0082] wherein g(z (l) ) is an activation function, and a nonlinear function such as Sigmoid, ReLU is usually used. z (l) is used to represent the weighted input of the lth layer, W (1 is used to represent the weight matrix of the lth to l+1 layer, and b (l) is used to represent the bias vector of the lth layer.
[0083] Calculate the error of the output layer (gradient of the loss function with respect to the output activation value):
[0084]
[0085] wherein is the gradient of the loss function J with respect to the output activation value a(L), ⊙ represents element-wise multiplication, g'(z (L) ) is the derivative of the activation function of the output layer.
[0086] Backpropagation of Error: starting from the output layer L, the error is propagated forward layer by layer, and for each hidden layer l=L-1 to 2, the error term δ (1) is calculated:
[0087] δ (1) = (W (l) ) T δ (l+1) ⊙g′(z (l) )
[0088] where δ (l) is used to represent the error term of the l-th layer.
[0089] In specific implementations, the weights and biases can be updated using gradient descent or other optimization algorithms, and repeated iterations until the loss function converges or reaches a predetermined training round. Through the backpropagation algorithm, the deep neural network can learn how to adjust the weights and biases to minimize the loss function, thereby achieving better prediction and classification performance. The calculation of weights and biases is as follows:
[0090]
[0091]
[0092] where α is the learning rate, used to control the step size of weight and bias update. W (l) is used to represent the weight matrix of the l-th to 1+1-th layer, b (l) is used to represent the bias vector of the l-th layer.
[0093] Further, to realize the bidirectional configuration of the data stream, there is a relatively uneconomical implementation method, that is, using two sets of input and output circuits to configure through the CAM circuit module, as shown in Figure 10 , Figure 10 is a schematic diagram of two sets of input and output circuits of the second embodiment of the neural network training method of the application; but this method has huge overhead because of two sets of peripheral circuits.
[0094] In the embodiment, when the control signal is a forward propagation signal, the data flow direction of the target data in the memory array during the training process of the neural network to be trained is in a feedforward direction, so as to perform feedforward calculation of the neural network to be trained. When the control signal is a backpropagation signal, the data flow direction of the target data in the memory array during the training process of the neural network to be trained is in a feedback direction, so as to perform feedback calculation of the neural network to be trained. The embodiment can realize bidirectional configuration of the calculation data stream, can realize backpropagation acceleration calculation of the neural network, and greatly expands the application scenarios of the current storage-computing integrated system based on the new type of memory.
[0095] Referring to Figure 11 , Figure 11 is a structural block diagram of the first embodiment of the neural network training device of the application.
[0096] As Figure 11As shown, the neural network training device provided by the embodiment of the present application comprises:
[0097] The acquisition module 10 is configured to acquire training phase information of a neural network to be trained, determine a memory computing mode according to the training phase information, and the memory computing mode comprises a forward propagation mode and a backward propagation mode.
[0098] The generation module 20 is configured to generate a control signal of the CAM circuit according to the memory computing mode.
[0099] The data flow control module 30 is configured to control a data flow direction of target data in the memory array during the training of the neural network to be trained based on the control signal.
[0100] In the embodiment, the training phase information of the neural network to be trained is acquired, the memory computing mode is determined according to the training phase information, the control signal of the CAM circuit is generated according to the memory computing mode, and the data flow direction of the target data in the memory array during the training of the neural network to be trained is controlled based on the control signal. In the above manner, the control signal of the CAM circuit is generated according to the memory computing mode, the data flow direction of the target data in the memory array during the training of the neural network to be trained is controlled based on the control signal, the bidirectional configuration of the data flow during the training of the neural network is realized, the calculation acceleration of the forward propagation and the backward propagation of the neural network is completed, and the model training efficiency is improved.
[0101] It should be noted that the above-described workflow is merely illustrative and does not limit the protection scope of the present application. In actual application, a person skilled in the art can select part or all of the above-described workflow to achieve the purpose of the embodiment of the present application, and the present application is not limited in this regard.
[0102] In addition, technical details not described in detail in the embodiment can be referred to the neural network training method provided by any embodiment of the present application, and will not be described herein.
[0103] Based on the first embodiment of the neural network training device described above, a second embodiment of the neural network training device is provided.
[0104] In the embodiment, the CAM circuit comprises a transmission gate connected with the memory array, and the data flow control module 30 is further configured to control a switching state of the transmission gate in the CAM circuit based on the control signal.
[0105] The data flow direction of the target data in the memory array during the training of the neural network to be trained is controlled according to the switching state.
[0106] Furthermore, the control signal includes a forward propagation signal and a backward propagation signal; the data flow control module 30 is also used to ensure that, when the control signal is a forward propagation signal, the data flow direction of the target data in the memory array during the training process of the neural network to be trained is a feedforward direction, so as to perform feedforward calculation of the neural network to be trained.
[0107] Step S302: When the control signal is a backpropagation signal, the data flow direction of the target data in the memory array during the training process of the neural network to be trained is the feedback direction, so as to perform feedback calculation of the neural network to be trained.
[0108] Furthermore, the data flow control module 30 is also used to determine the error term of the feedback calculation;
[0109] The voltage vector corresponding to the feedback calculation is determined based on the error term;
[0110] The feedback calculation of the neural network to be trained is performed based on the voltage vector and the data flow direction of the memory array according to the feedback direction.
[0111] Furthermore, the forward propagation mode and the backward propagation mode share a set of input and output circuits.
[0112] Furthermore, the memory array includes resistive random access memory, phase change memory, magnetic random access memory, or ferroelectric memory.
[0113] Furthermore, the neural network training system includes two sets of input / output circuits, which are used for feedforward calculations and feedback calculations for neural network training, respectively.
[0114] Other embodiments or specific implementations of the neural network training device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0115] Furthermore, embodiments of the present invention also propose a storage medium storing a neural network training program, which, when executed by a processor, implements the steps of the neural network training method described above.
[0116] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0117] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0118] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several signals to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0119] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A neural network training method, characterized in that, The neural network training method is applied to a neural network training system, which includes a CAM circuit and a memory array. The neural network training method includes the following steps: Obtain training stage information of the neural network to be trained, and determine the memory computing mode based on the training stage information. The memory computing mode includes forward propagation mode and backward propagation mode. The control signals for the CAM circuit are generated according to the memory computing mode. The control signal is used to control the data flow direction of the target data in the memory array during the training process of the neural network to be trained; The CAM circuit includes a transmission gate, which is connected to the memory array; The step of controlling the data flow direction of the target data in the memory array during the training process of the neural network to be trained based on the control signal includes: The switching state of the transmission gate in the CAM circuit is controlled based on the control signal; The switch state controls the flow of target data in the memory array during the training process of the neural network to be trained.
2. The neural network training method as described in claim 1, characterized in that, The control signals include forward propagation signals and reverse propagation signals; The step of controlling the data flow direction of the target data in the memory array during the training process of the neural network to be trained based on the control signal includes: When the control signal is a forward propagation signal, the data flow direction of the target data in the memory array during the training process of the neural network to be trained is the feedforward direction, so as to perform feedforward calculation of the neural network to be trained; When the control signal is a backpropagation signal, the data flow direction of the target data in the memory array during the training process of the neural network to be trained is the feedback direction, so as to perform feedback calculation of the neural network to be trained.
3. The neural network training method as described in claim 2, characterized in that, The step of performing feedback calculations on the neural network to be trained includes: Determine the error term in the feedback calculation; The voltage vector corresponding to the feedback calculation is determined based on the error term; The feedback calculation of the neural network to be trained is performed based on the voltage vector and the data flow direction of the memory array according to the feedback direction.
4. The neural network training method according to any one of claims 1-3, characterized in that, The forward propagation mode and the backward propagation mode share a set of input and output circuits.
5. The neural network training method according to any one of claims 1-3, characterized in that, The memory array includes resistive random access memory, phase change memory, magnetic random access memory, or ferroelectric memory.
6. The neural network training method according to any one of claims 1-3, characterized in that, The neural network training system includes two sets of input / output circuits, which are used for feedforward calculations and feedback calculations for neural network training, respectively.
7. A neural network training device, characterized in that, The neural network training device includes: The acquisition module is used to acquire training stage information of the neural network to be trained, and determine the memory computing mode based on the training stage information. The memory computing mode includes forward propagation mode and backward propagation mode. The generation module is used to generate control signals for the CAM circuit according to the memory computing mode; A data flow control module is used to control the data flow direction of the target data in the memory array during the training process of the neural network to be trained based on the control signal. The CAM circuit includes a transmission gate, which is connected to the memory array; The data flow control module is also used to control the opening and closing state of the transmission gate in the CAM circuit based on the control signal; The switch state controls the flow of target data in the memory array during the training process of the neural network to be trained.
8. A neural network training device, characterized in that, The device includes: a memory, a processor, and a neural network training program stored in the memory and executable on the processor, the neural network training program being configured to implement the steps of the neural network training method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium stores a neural network training program, which, when executed by a processor, implements the steps of the neural network training method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Neural network training method and device
CN113496267A
Neural network method and device, electronic equipment and storage medium
CN114118397A