A mapping method of recurrent neural network weight matrix to memristor array
By cutting and encoding the weight matrix of the recurrent neural network, the problem of large weight matrix is solved, the requirements for the array area and energy consumption are reduced, and the recognition accuracy is maintained.
Patent Information
- Application Number
- CN202111487036.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-12-07
AI Technical Summary
The weight matrix of the recurrent neural network is large and difficult to effectively map to existing non-volatile storage arrays, resulting in high requirements for the array area and high energy consumption.
By obtaining the weight matrix of the hidden layer of the recurrent neural network, arranging it row by row into a 3-row matrix array, cutting it according to the forward propagation function, and encoding it as the conductance value of the memristor array, reducing the requirements for the array area while maintaining the recognition accuracy. .
It greatly reduces the array area requirements when mapping the recurrent neural network to the memristor array, reduces energy consumption, and due to its robustness, the loss of recognition accuracy is small.
Smart Images

Figure CN114186667B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial neural networks, and more specifically, relates to a method for mapping a recurrent neural network weight matrix to a memristor array. Background Art
[0002] Artificial neural network algorithms have been widely used in image recognition, speech recognition and other fields. However, during its operation, a large number of matrix-vector multiplications need to be performed repeatedly, and for this purpose, a large amount of data needs to be frequently transferred between the computer's memory and the operator, which brings very serious problems of high energy consumption and high latency.
[0003] However, new non-volatile memories represented by memristors have excellent characteristics such as low power consumption, high speed, high integration, and adjustable multi-value conductivity, and can be used to simulate the electrical behavior of biological synapses. The memristor loop network accelerator, which is composed of memristors and other auxiliary electronic components and peripheral circuits, can realize matrix-vector multiplication in one step by using Ohm's law and Kirchhoff's current law. This bypasses the "von Neumann bottleneck" and greatly improves the operating speed and energy efficiency of artificial neural networks.
[0004] Recurrent Neural Network (RNN) is a common neural network algorithm, which is characterized by recursive synapses in its hidden layer neurons that feed back the hidden layer output of the current time step to the next time step as the input of the hidden layer, so that the network has the ability to process time series information. Long Short-Term Memory (LSTM) neural network is a type of RNN. Its hidden layer neurons have a complex gated unit structure, which can selectively forget and remember information flow, thereby better solving the serious gradient vanishing problem in traditional RNN and has been widely used in the field of time series information processing. However, due to its complex structure and huge weight matrix size, LSTM neural network is difficult to map weights to existing memristor arrays. For this reason, it is inevitable to simplify the structure and scale of LSTM neural network.
[0005] The Gated Recurrent Unit (GRU) neural network is a simplified version of the LSTM neural network. It reduces the number of synapses in the hidden layer of the LSTM by 25% by merging the gated units in the hidden layer of the LSTM. However, the weight matrix of the simplified GRU neural network is still large and difficult to map (the mapping area is relatively large) to the existing non-volatile storage array. Summary of the invention
[0006] In view of the defects of the prior art, the purpose of the present invention is to provide a method for mapping a recurrent neural network weight matrix to a memristor array, which can effectively reduce the requirements for array area when the recurrent neural network uses a memristor array to accelerate the training or inference process.
[0007] To achieve the above object, in a first aspect, the present invention provides a method for mapping a recurrent neural network weight matrix to a memristor array, comprising the following steps:
[0008] (1) Obtain all weight matrices in the hidden layer of the target recurrent neural network, wherein the weight matrices are a fully connected matrix, a recursive matrix, and a bias matrix;
[0009] (2) arranging each weight matrix into a 3-row matrix array by row, and each column element matrix in the matrix array is located in the same gating unit;
[0010] (3) trimming the element matrix in the matrix array according to the forward propagation function of the hidden layer of the target recurrent neural network, wherein the trimmed element matrix does not affect the back propagation of other element matrices, and the trimmed element matrix enables the coefficients of each gated unit in the target recurrent neural network to obtain a calculation result;
[0011] (4) Encoding each element matrix in the trimmed and trained matrix array into the conductance of the corresponding device in the memristor array.
[0012] The method for mapping the recurrent neural network weight matrix to the memristor array provided by the present invention can greatly reduce the requirements for the array area when mapping various recurrent neural networks to the memristor array; at the same time, since the network structure and information flow direction have not changed, the weight update of other matrices will not be affected; in addition, due to the strong robustness of the neural network algorithm, the recognition accuracy loss caused by weight matrix cutting is relatively small.
[0013] In one embodiment, step (3) further comprises:
[0014] The element matrices in the matrix array are trimmed according to the priority requirements for the area of the memristor array and the recognition accuracy of the application scenario oriented by the target recurrent neural network.
[0015] In one of the embodiments, when the recognition accuracy priority of the application scenario facing the target recurrent neural network is higher than the priority of the area of the memristor array, the cropped element matrix is a partial element matrix in the matrix array except for the corresponding bias matrix;
[0016] When the priority of the area of the memristor array is higher than the priority of the recognition accuracy of the application scenario oriented by the target recurrent neural network, the cropped element matrix is all the element matrices in the matrix array except the corresponding bias matrix.
[0017] In one of the embodiments, the recognition accuracy of the application scenario targeted by the target recurrent neural network is obtained by testing on a handwritten font recognition dataset.
[0018] In one embodiment, step (4) specifically includes:
[0019] Normalizing each element matrix in the cut and trained matrix array, and dividing the memristor array into two parts by row, one part is a positive array, and the other part is a negative array;
[0020] Each element matrix in the normalized matrix array is encoded as the conductance value of the corresponding device in the positive array and the negative array.
[0021] In one of the embodiments, the target recurrent neural network is a neural network that relies on the results of the gating unit to process timing information, and the target recurrent neural network includes an LSTM neural network, a GRU neural network or an MGU neural network.
[0022] In one embodiment, the memristor array includes a memory array composed of a 1T1R structure in which transistors and memristors are connected in series, a memory array composed of a 1S1R structure in which gate transistors and memristors are connected in series, or a memory array composed of self-gating memristors.
[0023] In a second aspect, the present invention provides a mapping system of a recurrent neural network weight matrix to a memristor array, comprising:
[0024] A weight matrix acquisition module is used to obtain all weight matrices in the hidden layer of the target recurrent neural network, wherein the weight matrices are a fully connected matrix, a recursive matrix, and a bias matrix;
[0025] A weight matrix arrangement module, used for arranging each weight matrix into a 3-row matrix array by row, and each column element matrix in the matrix array is located in the same gating unit;
[0026] A cutting module, used for cutting the element matrix in the matrix array according to the forward propagation function of the hidden layer of the target recurrent neural network, wherein the cut element matrix does not affect the back propagation of other element matrices, and the cut element matrix enables the coefficients of each gate unit in the target recurrent neural network to obtain a calculation result;
[0027] The encoding module is used to encode each element matrix in the cut and trained matrix array into the conductance of the corresponding device in the memristor array.
[0028] In a third aspect, the present invention provides a mapping device for a recurrent neural network weight matrix to a memristor array, comprising:
[0029] a memory having a computer program stored thereon;
[0030] A processor is used to execute the computer program in the memory to implement the steps of the mapping method as described above.
[0031] In a fourth aspect, the present invention provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the mapping method described above.
[0032] The mapping system, device and storage medium of the recurrent neural network weight matrix to the memristor array provided by the present invention can greatly reduce the requirements for the array area when mapping various recurrent neural networks to the memristor array; at the same time, since the network structure and information flow direction have not changed, the weight update of other matrices will not be affected; in addition, due to the strong robustness of the neural network algorithm, the recognition accuracy loss caused by weight matrix cutting is relatively small. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a schematic diagram of the structure of the RNN recurrent neural network;
[0034] Figure 2 This is a schematic diagram of the structure of the hidden layer of the LSTM neural network;
[0035] Figure 3 It is a schematic diagram of the structure of a traditional memristor recurrent neural network accelerator;
[0036] Figure 4 This is a schematic diagram of the structure of a traditional memristor LSTM neural network accelerator;
[0037] Figure 5 It is a schematic diagram of the structure of a traditional memristor GRU neural network accelerator;
[0038] Figure 6 It is a flow chart of a method for mapping a ring neural network weight matrix to a memristor array provided by an embodiment of the present invention;
[0039] Figure 7 1 is a schematic diagram of a fully connected matrix of a reset gate and an update gate of a GRU neural network cut out in accordance with the first embodiment of the present invention;
[0040] Figure 8 1 is a schematic diagram of a recursive matrix of a reset gate and an update gate of a GRU neural network according to a second embodiment of the present invention;
[0041] Fig. 9 It is a schematic diagram of the third embodiment of the present invention, which only retains the bias matrix of the reset gate and the update gate of the GRU neural network;
[0042] Fig.10 It is a schematic diagram of comparative training effects of using embodiments 1 to 3 of the present invention and the traditional GRU mapping method under handwriting recognition data sets of different time series lengths; wherein, the smaller the cross entropy loss, the better the training effect.
[0043] Fig.11 It is a schematic diagram of comparing the inference effects of Embodiments 1 to 3 of the present invention and the traditional GRU mapping method under different array device read errors; wherein, the smaller the cross entropy loss, the smaller the inference error.
[0044] Fig.12 This is a system architecture diagram for mapping a ring neural network weight matrix to a memristor array provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0046] It should be noted that the method for mapping the recurrent neural network weight matrix to the memristor array provided by the present invention is to ignore a part of the matrix when using the traditional memristor recurrent neural network accelerator to perform matrix-vector multiplication, that is, only map a part of the matrix to the memristor array, while ensuring that the network structure remains unchanged. Under the premise of basically not losing the network recognition accuracy, the requirement for the area of the memristor array during weight matrix mapping is reduced, and energy consumption is reduced at the same time.
[0047] In order to more clearly illustrate the present invention, several typical neural network structures and memristor neural network accelerator structures are described below:
[0048] Figure 1 This is the structure diagram of the RNN recurrent neural network. Like the Multilayer Perceptron (MLP), the neurons in the hidden layer of the RNN recurrent neural network need to be connected to each neuron in the previous and next layers through synapses to form a fully connected weight matrix W. In addition, unlike the MLP, the hidden layer of the RNN recurrent neural network has another layer of recursive weight matrix U, which can feed back the output of the hidden layer at this time step to the next time step as input. The forward propagation function of the hidden layer of the RNN is:
[0049] h t =tanh(W x t+Uh t-1 +b、)
[0050] Among them, h t is the output vector of the hidden layer at this time step; x t is the input vector of the fully connected matrix W at this time step; h t-1 is the hidden layer output from the previous time step and serves as the input vector of the recursive matrix U at this time step; b is the bias matrix.
[0051] Figure 2 This is a schematic diagram of the structure of the hidden layer of the LSTM neural network. The LSTM neural network is a type of RNN recurrent neural network. It introduces gate units and memory units such as input gate i, forget gate f, output gate o, and cell state c in the hidden layer neurons to selectively forget and output the information from the previous time step. The forward propagation function of its hidden layer is:
[0052] a t =tanh(W a x t +U a h t-1 +b a )
[0053] i t =sigmoid(W i x t +U i h t-1 +b i )
[0054] f t =sigmoid(W f x t +U f h t-1 +b f )
[0055] o t =sigmoid(W o x t +U o h t-1 +b o )
[0056] c t =tanh(i t ⊙a t +f t ⊙c t-1 )
[0057] h t =o t ⊙c t
[0058] Among them, ⊙ represents the smart product of vector elements; a t Enter the intermediate vector for t time steps; i t is the input gate coefficient for time step t; f t is the forget gate coefficient at time step t; o t is the output gate coefficient of time step t; c t is the cell state coefficient at time step t; W a / i / f / o Represents the fully connected matrices of the four gating units; U a / i / f / o Represents the recursive matrix of four gate control units respectively; b a / i / f / o Represent the bias matrices of the four gating units respectively.
[0059] Figure 3 This is a schematic diagram of the structure of a traditional memristor recurrent neural network accelerator. Figure 3 It can be seen that the memristor recurrent neural network accelerator mainly includes a memristor array, a DAC unit, an ADC unit, an activation function unit, a vector element intelligent product unit and a vector adder unit. It mainly simulates the weight change of synapses in the neural network through the conductance change of each device in the memristor array.
[0060] Among them, the memristor array adopts a cross array with memristors as core components, and its form includes but is not limited to a memory array composed of a 1T1R structure in which transistors and memristors are connected in series, or a memory array composed of a 1S1R structure in which gate tubes and memristors are connected in series, or a memory array composed of self-gated memristors. Of course, the above-mentioned memristors can also be replaced by other non-volatile memories with multi-value adjustable conductivity characteristics, including but not limited to phase change memory, magnetic memory, flash memory, etc.
[0061] The above-mentioned memristor recurrent neural network accelerator implements the matrix-vector multiplication operation mode as follows: the input vector of the neural network is encoded into the input voltage of the row line of the memristor array through the DAC unit (digital-to-analog converter); the weight matrix of the neural network is correspondingly encoded as the conductance of the device in the memristor array; according to Ohm's law and Kirchhoff's current law, the current output by the column line of the array is the result vector of the matrix-vector multiplication, which becomes a digital signal after being processed by the DAC unit (analog-to-digital converter); then, the result vector is processed by the activation function unit, the vector element intelligent product unit, the vector adder unit and other circuits to obtain the hidden layer output vector, and is transmitted to the peripheral data cache unit as the input of the hidden layer in the next time step. In addition, each weight matrix (such as the fully connected matrix W, the recursive matrix U, and the bias matrix b) requires a region of the memristor array for encoding, and the size of the region depends on the size of the weight matrix and the weight mapping method.
[0062] It should be noted that the selection of activation function units in the accelerator, as well as the setting of vector element intelligent product units and vector adder units, are mainly determined by the forward propagation function of the hidden layer of the neural network to be cut. For details, please refer to Figure 4 (corresponding to LSTM neural network) and Figure 5 (Corresponding to GRU neural network) The selection of activation function units in the accelerator, and the setting method of vector element smart product units and vector adder units.
[0063] Figure 4 This is a schematic diagram of the structure of a traditional memristor LSTM neural network accelerator. Each fully connected matrix (W a , W i , W f , W 。 ), the recursive matrix (U a , U i , U f , U o ) and the bias matrix (b a , b i , b f , b o ) are mapped to the device conductance of a region of the memristor array. The input vector x t and the hidden layer output h of the previous time step t-1 The output of the hidden layer is obtained by multiplying the voltage and the conductivity and then processing it through the peripheral circuit or computer. t , completing the forward propagation of the network. In addition, the output h of the hidden layer will be processed and encoded, and then input into the register of the peripheral circuit, and encoded as the voltage amplitude and input into the row line of the array in the next time step.
[0064] Figure 5 This is a schematic diagram of the structure of a traditional memristor GRU neural network accelerator. Through parameter reuse, the required memristor array area is reduced by 25% compared to the LSTM neural network of the same size. In addition, the mapping method and operation method of the memristor GRU neural network accelerator are the same as those of the memristor LSTM neural network accelerator. The forward propagation function of the GRU hidden layer is as follows:
[0065] r t =sigmoid(W r x t +U r h t-1 +b r )
[0066] z t =sigmoid(W zx t +U z h t- 1+b z )
[0067] g t =tanh(W g x t +U g (r t ⊙h t-1 )+b g )
[0068] h t =(1-z t )⊙h t-1 +z t ⊙g t
[0069] Among them, r t is the reset gate coefficient for time step t; z t is the update gate coefficient of time step t; g t is the output intermediate vector of time step t; W r / z / g are the fully connected matrices of the three gating units; U r / z / g are the recursive matrices of the three gate control units respectively; b r / z / g They are the bias matrices of the three gating units respectively.
[0070] According to the several typical neural network structures and their corresponding memristor neural network accelerator structures provided above, the traditional memristor neural network accelerator maps all weight matrices in the hidden layer of the neural network to the device conductance of a region of the memristor array, which has high requirements for the area of the memristor array. To this end, the present invention provides a method for mapping the weight matrix of a recurrent neural network to a memristor array, which can reduce the requirements for the area of the memristor array when mapping the weight matrix, while reducing energy consumption.
[0071] See also Figure 6 , Figure 6 is a flow chart of a method for mapping a recurrent neural network weight matrix to a memristor array provided by an embodiment of the present invention, Figure 6 It can be seen that the mapping method includes steps S10 to S40, which are described in detail as follows:
[0072] S10, obtaining all weight matrices in the hidden layer of the target recurrent neural network, where the weight matrices are a fully connected matrix, a recursive matrix, and a bias matrix.
[0073] The target recurrent neural network is a recurrent neural network to be subjected to matrix-vector multiplication operations, and has recursive synapses at the hidden layer neurons, which can feed back the hidden layer output of the current time step to the hidden layer input of the next time step. Specifically, the target recurrent neural network can be an LSTM neural network, a GRU neural network or an MGU neural network, and any neural network that relies on the results of the gating unit to process time series information is applicable to this solution.
[0074] S20, arranging the weight matrices into a 3-row matrix array by row, and each column element matrix in the matrix array is located in the same gating unit.
[0075] It should be noted that Figure 3 to Figure 5 It can be seen that the traditional memristor neural network accelerator uses the network input vector as the input voltage of the row line of the memristor array, and encodes the network weight matrix into the conductance of each device in the memristor array. According to Ohm's law and Kirchhoff's current law, the current output by the array column line is the result vector of matrix-vector multiplication, that is, each column element matrix of the memristor array corresponds to the same gate unit. Figure 5 Taking the memristor GRU neural network accelerator in as an example, each column element matrix of the memristor array corresponds to the gate control unit r t 、z t and g t .
[0076] The purpose of the present invention is to reduce the requirements for the area of the memristor array when mapping the weight matrix by cutting a part of the matrix when performing matrix-vector multiplication using a traditional memristor recurrent neural network accelerator. Therefore, in this embodiment, the weight matrix obtained in step S10 needs to be arranged in a matrix array according to the weight matrix mapping method of the traditional memristor matrix, that is, the obtained weight matrices are arranged in rows into a 3-row matrix array, and each column element matrix in the matrix array is located in the same gate unit; then the corresponding element matrix in the matrix array is cut, and the cut and trained matrix array is encoded as the conductance of the corresponding device in the memristor array, thereby performing matrix-vector multiplication. In this way, there is no need to modify the peripheral data processing units (activation function unit, vector element intelligent product unit and vector adder unit) in the traditional memristor neural network accelerator, and the forward propagation process of the network can be performed as usual.
[0077] S30, the element matrix in the matrix array is trimmed according to the forward propagation function of the hidden layer of the target neural network. The trimmed element matrix does not affect the back propagation of other element matrices, and the trimmed element matrix does not make the coefficients of the gated units in the target recurrent neural network unable to obtain calculation results. In other words, the trimmed element matrix does not change the input-output relationship and internal information flow of the hidden layer of the network (does not destroy the overall structure of the network).
[0078] In step S30, Figure 5 Taking the memristor GRU neural network accelerator in as an example, according to the forward propagation function of the hidden layer of the GRU neural network, the pruned element matrix cannot be located in the gate unit g t The element matrix in cannot be r t or t All element matrices in the gate control unit are not affected by the overall structure of the network. Therefore, in order not to affect the overall structure of the network, except for the matrix array located in the gate control unit g t The element matrix in cannot be cut, and cannot be cut at the same time r t or t Except for all element matrices in the gated unit, other cutting methods are possible. The specific cutting can be selected according to the area requirements of the memristor array and the priority requirements for the recognition accuracy of the application scenarios facing the network. The recognition accuracy of the application scenarios facing the network can be obtained by testing on the handwriting recognition (MNIST) data set. Of course, it can also be tested on other data sets, and this embodiment is not limited.
[0079] S40, encoding each element matrix in the cut and trained matrix array into the conductance of the corresponding device in the memristor array.
[0080] Specifically, step S40 includes:
[0081] (1) The memristor array is divided into two parts by row, one part is defined as a positive array, whose input voltage is positive; the other part is defined as a negative array, whose input voltage is negative.
[0082] (2) Normalize each element matrix in the cropped and trained matrix array.
[0083] (3) Encode each element matrix in the normalized matrix array into the device conductance values of the positive array and the negative array. The "1" element in the normalized element matrix is represented by writing the corresponding device in the positive array to its maximum conductance value and the corresponding device in the negative array to its minimum conductance value; the "-1" element in the normalized element matrix is represented by writing the corresponding device in the positive array to its minimum conductance value and the corresponding device in the negative array to its maximum conductance value; the other elements are encoded into the device conductance values of the two arrays in a similar manner.
[0084] (4) Writing the encoded device conductance value into the array. The specific steps include:
[0085] (a) Determine whether the absolute value of the difference between the current conductance of the device and the target conductance is less than the target value. If so, end the encoding of the device and proceed to the next device; if so, proceed to step (b).
[0086] (b) Determine whether the difference between the current conductance of the device and the target conductance is positive or negative. If it is positive, a negative voltage pulse is applied to the device; if it is negative, a positive voltage pulse is applied to the device. The selection of the voltage pulse amplitude absolute value, pulse width, waveform and other characteristics depends on the performance of the device in the specific memristor array.
[0087] (c) Repeat step (a) until the conductance writing of the relevant devices in the billion-resistance array is completed.
[0088] The method for mapping the recurrent neural network weight matrix to the memristor array provided in this embodiment can significantly reduce the requirements for the array area when mapping various recurrent neural networks to the memristor array; at the same time, since the network structure and information flow have not changed, the weight update of other matrices will not be affected; in addition, due to the strong robustness of the neural network algorithm, the loss of recognition accuracy caused by weight matrix cutting is relatively small.
[0089] To explain this scheme more clearly, the following example is given:
[0090] Figure 7 is a schematic diagram of the first embodiment of the present invention. In this embodiment, when mapping the weight matrix to the memristor array, the fully connected matrix W of the reset gate and update gate of the hidden layer of the GRU neural network is r and W z Only a part of the weight matrix is mapped to the memristor array. t The encoded voltage vector will only be input to the g In the array area, the hidden layer outputs h t-1 The voltage vector encoded by the unit vector 1 will be input into the array from the row line as usual, without affecting the current output by the column line to obtain the gating parameter r of the network. t and z t Therefore, the peripheral circuit can perform the forward propagation process of the network as usual without modification.
[0091] Figure 8 , 9 The following are schematic diagrams of the second and third embodiments of the present invention respectively. In the second embodiment, the recursive matrix U of the reset gate and update gate of the hidden layer of the GRU neural network is r and U z In the third embodiment, the fully connected matrix W r and W z and the recursive matrix U r and U z All are cropped, leaving only the bias matrix b r and b z Similar to the first embodiment, the gate parameters r in the second and third embodiments are t and zt The calculation process is not affected by the trimmed matrix. The above embodiments only use the weight trimming of the GRU network as an example to explain the basic principle of the present invention. In fact, the weight trimming of neural networks such as LSTM networks and MGU networks that rely on the gated unit structure to process timing information can also be performed in a similar manner to reduce the requirements for the array area, which will not be repeated here.
[0092] Fig.10 and Fig.11 is a diagram showing the effect of using embodiments 1 to 3 of the present invention and the traditional GRU mapping method. Fig.10 and 11 It can be seen that the mapping method of Example 1 (corresponding to GRU1 in the figure) improves the learning and processing capabilities of the network long time series data set compared to the traditional GRU mapping method (corresponding to GRU in the figure), but the tolerance to non-ideal devices is deteriorated; the mapping method of Example 2 (corresponding to GRU2 in the figure) reduces the requirements for device performance while maintaining the network learning ability; the mapping method of Example 3 (corresponding to GRU3 in the figure) achieves the maximum area optimization effect, but its requirements for device performance are also the highest.
[0093] It can be seen that when trimming the weight matrix of the recurrent neural network, it should not affect the back propagation of other matrices, and it should not make the gated unit coefficients unable to obtain the calculation results, that is, it should not destroy the overall structure of the network. The decision should be based on the device performance in the memristor array and the recognition rate required by the application. If only part of the matrix except the bias matrix in the gated unit is trimmed, the performance requirements for the number of memristor unit conductance states and read errors in the selected array area are relatively low; if only the bias matrix in the gated unit is retained during trimming, the performance requirements for the number of memristor unit conductance states and read errors in the selected array area are higher to ensure better recognition effect of the network.
[0094] Fig.12 A system architecture diagram for mapping a recurrent neural network weight matrix to a memristor array according to an embodiment of the present invention is shown in FIG. Fig.12 As shown, the mapping system includes a weight matrix acquisition module 100 , a weight matrix arrangement module 200 , a cropping module 300 and an encoding module 400 .
[0095] Among them, the weight matrix acquisition module 100 is used to obtain all weight matrices in the hidden layer of the target recurrent neural network, and the weight matrices are fully connected matrices, recursive matrices and bias matrices.
[0096] The weight matrix arrangement module 200 is used to arrange the weight matrices into a 3-row matrix array by row, and each column element matrix in the matrix array is located in the same gating unit.
[0097] The trimming module 300 is used to trim the element matrix in the matrix array according to the forward propagation function of the hidden layer of the target recurrent neural network. The trimmed element matrix does not affect the back propagation of other element matrices, and the trimmed element matrix enables the coefficients of each gate unit in the target recurrent neural network to obtain the calculation results.
[0098] The encoding module 400 is used to encode each element matrix in the cut and trained matrix array into the conductance of the corresponding device in the memristor array.
[0099] Specifically, the functions of each module provided in this embodiment can be found in the detailed description in the aforementioned method embodiment, and will not be repeated here.
[0100] In addition, the present invention also provides a mapping device for a recurrent neural network weight matrix to a memristor array, comprising: a memory on which a computer program is stored; a processor for executing the computer program in the memory to implement the steps of the above-mentioned mapping method. The present invention also provides a storage medium on which a computer program is stored, and when the program is executed by the processor, the steps of the above-mentioned mapping method are implemented.
[0101] The device and storage medium provided in this embodiment and the method in the aforementioned embodiment are two aspects based on the same inventive concept. The method implementation process has been described in detail above, so those skilled in the art can clearly understand the structure and implementation process of the device and storage medium in this embodiment based on the aforementioned description. For the sake of brevity of the specification, they will not be repeated here.
[0102] The mapping system, device and storage medium of the recurrent neural network weight matrix to the memristor array provided in this embodiment can greatly reduce the requirements for the array area when mapping various recurrent neural networks to the memristor array; at the same time, since the network structure and information flow have not changed, the weight update of other matrices will not be affected; in addition, due to the strong robustness of the neural network algorithm, the loss of recognition accuracy caused by weight matrix cutting is relatively small.
[0103] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for mapping a recurrent neural network weight matrix to a memristor array, characterized in that: The steps include: (1) Obtain all weight matrices in the hidden layer of the target recurrent neural network, wherein the weight matrices are a fully connected matrix, a recursive matrix, and a bias matrix; (2) arranging each weight matrix into a 3-row matrix array by row, and each column element matrix in the matrix array is located in the same gating unit; (3) trimming the element matrix in the matrix array according to the forward propagation function of the hidden layer of the target recurrent neural network, wherein the trimmed element matrix does not affect the back propagation of other element matrices, and the trimmed element matrix enables the coefficients of each gated unit in the target recurrent neural network to obtain a calculation result; (4) Encoding each element matrix in the trimmed and trained matrix array into the conductance of the corresponding device in the memristor array.
2. The method for mapping a recurrent neural network weight matrix to a memristor array according to claim 1, characterized in that: Step (3) also includes: The element matrices in the matrix array are trimmed according to the priority requirements for the area of the memristor array and the recognition accuracy of the application scenario oriented by the target recurrent neural network.
3. The method for mapping a recurrent neural network weight matrix to a memristor array according to claim 2, characterized in that: When the recognition accuracy priority of the application scenario facing the target recurrent neural network is higher than the priority of the area of the memristor array, the cropped element matrix is a partial element matrix in the matrix array except for the corresponding bias matrix; When the priority of the area of the memristor array is higher than the priority of the recognition accuracy of the application scenario oriented by the target recurrent neural network, the cropped element matrix is all the element matrices in the matrix array except the corresponding bias matrix.
4. The method for mapping a recurrent neural network weight matrix to a memristor array according to claim 1 or 2, characterized in that: The recognition accuracy of the application scenario targeted by the target recurrent neural network is obtained by testing on a handwritten font recognition dataset.
5. The method for mapping a recurrent neural network weight matrix to a memristor array according to claim 1 or 2, characterized in that: Step (4) specifically includes: Normalizing each element matrix in the cut and trained matrix array, and dividing the memristor array into two parts by row, one part is a positive array, and the other part is a negative array; Each element matrix in the normalized matrix array is correspondingly encoded as the device conductance value in the positive array and the negative array.
6. The method for mapping a recurrent neural network weight matrix to a memristor array according to claim 1 or 2, characterized in that: The target recurrent neural network is a neural network that relies on the results of the gating unit to process time series information, and the target recurrent neural network includes an LSTM neural network, a GRU neural network or an MGU neural network.
7. The method for mapping a recurrent neural network weight matrix to a memristor array according to claim 1 or 2, characterized in that: The memristor array includes a memory array composed of a 1T1R structure in which transistors and memristors are connected in series, a memory array composed of a 1S1R structure in which gate tubes and memristors are connected in series, or a memory array composed of self-gated memristors.
8. A system for mapping a recurrent neural network weight matrix to a memristor array, characterized in that: include: A weight matrix acquisition module is used to obtain all weight matrices in the hidden layer of the target recurrent neural network, wherein the weight matrices are a fully connected matrix, a recursive matrix, and a bias matrix; A weight matrix arrangement module, used for arranging each weight matrix into a 3-row matrix array by row, and each column element matrix in the matrix array is located in the same gating unit; A cutting module, used for cutting the element matrix in the matrix array according to the forward propagation function of the hidden layer of the target recurrent neural network, wherein the cut element matrix does not affect the back propagation of other element matrices, and the cut element matrix enables the coefficients of each gate unit in the target recurrent neural network to obtain a calculation result; The encoding module is used to encode each element matrix in the cut and trained matrix array into the conductance of the corresponding device in the memristor array.
9. A mapping device for a recurrent neural network weight matrix to a memristor array, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the mapping method according to any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the mapping method according to any one of claims 1 to 7 are implemented.
