Control device and method for training neural network
By designing a control device for neural network training, using error acquisition module, binary module, trivalent module and weight update module, the problems of low training efficiency and high computing energy consumption caused by the irrational characteristics of new memory are solved, and training efficiency improvement of smaller computing energy consumption is achieved.
Patent Information
- Application Number
- CN202311181904.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-13
- Publication Date
- 2025-03-14
AI Technical Summary
The existing neural network training methods based on new memory cannot effectively overcome the irrational characteristics of new memory, resulting in low training efficiency and high computing energy consumption.
A control device is designed, including an error acquisition module, a binary module, a ternary module and a weight update module. By binarizing and ternary processing of the output signal and error signal, the range of weight updates is limited, the calculation energy consumption is reduced, and the update signal is obtained based on the output symbol signal, the error symbol signal and the input signal, indicating the update direction of the weight.
It effectively reduces the computing energy consumption of neural network training, improves training efficiency, and gives the correct update direction when the conductance value of the new memory is uncontrollable and drift will occur.
Smart Images

Figure CN119623540A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a control device and method for training a neural network. Background Art
[0002] At present, neural networks are usually trained by separating computing and storage. This method involves a large amount of data transmission, which will slow down the training speed of neural networks. With the development of new memories, such as resistive random access memory (RRAM), phase change memory (PCM) and magnetic-resistive random access memory (MRAM), they can also be used for neural network training. This new memory can realize computing and storage in one computing device. Therefore, the neural network training method based on new memory can reduce data transmission and improve the training speed of neural networks.
[0003] At present, a neural network training method based on a new type of memory calculates a weight update value during an iterative training process. If the weight update value is greater than a preset threshold, the weight of the next iteration is updated according to the weight update value. If the weight update value is less than or equal to the preset threshold, the weight of the next iteration is not updated.
[0004] The above method cannot overcome the irrational characteristics of the above-mentioned new memory with less computing energy consumption. For example, after receiving the same signal, the conductivity values of new memories with different initial conductance values show nonlinear changes and drift, resulting in low training efficiency. Summary of the invention
[0005] The embodiment of the present application provides a control device and method for training a neural network, which can overcome the irrational characteristics of a new type of memory with less computing energy consumption, thereby improving training efficiency. The technical solution is as follows.
[0006] In a first aspect, a control device for training a neural network is provided, the control device comprising: an error acquisition module, a binarization module, a ternary module and a weight update module, the error acquisition module is respectively connected to the binarization module and the ternary module, the binarization module and the ternary module are respectively connected to the weight update module, the error acquisition module is used to obtain the error signal of the i-th layer of the neural network based on the output signal obtained by processing the input signal at time T with the target signal and the storage unit array, the storage unit array is used to train the i-th layer of the neural network, i and T are both integers greater than 0; the binarization module is used to binarize the elements in the output vector indicated by the output signal based on the output threshold to obtain the output sign signal; the ternary module is used to ternary the elements in the error vector indicated by the error signal based on the error threshold to obtain the error sign signal; the weight update module is used to output an update signal based on the output sign signal, the error sign signal and the input signal of the i-th layer of the neural network, the update signal is used to indicate the adjustment direction of the weight of the i-th layer of the neural network to process the input signal at time T+1.
[0007] The control device performs binarization and ternary processing on the output signal and the error signal based on the output threshold and the error threshold to obtain the output sign signal and the error sign signal, which limits the range of weights that need to be updated, reduces the number of weight updates, and thus reduces the computational energy consumption of neural network training, and then obtains the update signal based on the output sign signal, the error sign signal and the input signal, the update signal indicates the update direction of the weight, even if the change of the conductance value of the new memory is uncontrollable and drift occurs, the device can also give the correct update direction of the conductance value of the new memory in the next iteration. Therefore, the device provided in the embodiment of the present application can overcome the non-ideal characteristics of the new memory with less computational energy consumption and improve training efficiency.
[0008] In some embodiments, when the network accuracy of the neural network reaches the target network accuracy, the output threshold is increased to increase the number of signals representing zero in the output symbol signal, so that when the weights are adjusted based on the output symbol signal, the number of adjusted weights is smaller, thereby avoiding adjusting the conductance value that has reached the target weight in the new memory.
[0009] In some embodiments, when the network accuracy of the neural network reaches the target network accuracy, the error threshold is increased to increase the signal representing zero in the error sign signal, so that when the weights are adjusted based on the error sign signal, the number of adjusted weights is smaller, thereby avoiding adjusting the conductance value that has reached the target weight in the new memory.
[0010] In some embodiments, the storage cell array includes M×N storage cells, the error acquisition module includes N first error acquisition units, the nth first error acquisition unit is used to process the output signal of the nth column, output the error signal of the nth column and the processed output signal of the nth column, wherein n is an integer greater than 0 and less than or equal to N; the nth first error acquisition unit includes: an integrator, a comparator, a sampling circuit, a counter and a ramp generator; wherein the integrator is connected to the comparator, and the ramp generator is connected to the comparator; the integrator is used to convert the output signal of the nth column in the storage cell array into a voltage; the comparator is used to compare the output of the integrator with the output of the ramp generator and output a pulse sequence; the comparator is connected to the sampling circuit, the sampling circuit is connected to the counter, the sampling circuit samples the pulse sequence and outputs the sampling sequence to the counter; the counter is used to subtract the target signal from the sampling sequence when the i-th layer of the neural network is the output layer, and output the error signal of the n-th column; the counter is also used to obtain the error signal of the n-th column based on back propagation when the i-th layer of the neural network is not the output layer, and output the error signal of the n-th column.
[0011] In some embodiments, the first error acquisition unit also includes a clock control circuit and an error controller, the error controller is connected to the clock control circuit and the sampling circuit respectively, the clock control circuit is connected to the ramp generator, and the clock control circuit is used to control the increasing rate of the output voltage of the ramp generator; the error controller is used for the clock frequency of the clock control circuit, and is also used to control the sampling frequency of the sampling circuit.
[0012] By controlling the clock frequency of the clock control circuit, the increasing rate of the output voltage of the ramp generator can be controlled, thereby controlling the pulse sequence output by the comparator, and then controlling the size of the error vector represented by the error signal, which is equivalent to adjusting the output threshold and the error threshold. By controlling the sampling frequency of the sampling circuit, the size of the output vector indicated by the sampling sequence output by the sampling circuit can be controlled, and then controlling the size of the error vector represented by the error signal can be equivalent to adjusting the output threshold and the error threshold.
[0013] By equivalently adjusting the output threshold and the error threshold, the update of the neural network weights can be controlled. Adjusting to a smaller threshold can increase the number of weight updates and ensure that the neural network converges quickly to a small loss function value, while adjusting to a larger threshold can avoid adjusting the conductance value that has reached the target weight in the new memory.
[0014] In some embodiments, the storage unit array includes M×N storage units, the error acquisition module includes N second error acquisition units, the nth second error acquisition unit is used to process the output signal of the nth column, and output the error signal of the nth column and the processed output signal of the nth column; the nth second error acquisition unit includes: an ADC and a counter, the ADC and the counter are connected, and the ADC is used to convert the output signal of the nth column in the storage unit array into a digital signal; the counter is used to subtract the target signal from the digital signal when the i-th layer of the neural network is the output layer, and output the error signal of the n-th column; the counter is also used to obtain the error signal of the n-th column based on back propagation when the i-th layer of the neural network is not the output layer, and output the error signal of the n-th column.
[0015] When the i-th layer of the neural network is not the output layer, the second error acquisition unit does not need to equivalently adjust the output threshold and the error threshold. When the i-th layer of the neural network is the output layer, the counter in the second error acquisition unit can adjust the size of the target signal and the size of the error signal to play the role of equivalently adjusting the error threshold.
[0016] When the second error acquisition unit is used to acquire the error signal, there is no need to adjust the output threshold and the error threshold by processing the output signal. Therefore, in the neural network training process, the counter 502 in the second error acquisition unit adjusts the error threshold by adjusting the size of the target signal, or the binarization module and the ternary module coordinated with the second error acquisition unit need to adjust the output threshold and the error threshold based on the threshold configuration signal output by the controller to control the number of weight updates. The first error acquisition unit can adjust the output threshold and the error threshold by processing the output signal. Therefore, there is no need to adjust the size of the target signal in the counter of the first error acquisition unit or the output threshold and the error threshold of the binarization module and the ternary module coordinated with the first error acquisition unit, and the weight update can also be controlled. In the actual training process, the first error acquisition unit or the second error acquisition unit can be selected to acquire the error signal according to actual needs.
[0017] In a second aspect, a processing unit for training a neural network is provided, the processing unit comprising a controller, a forward input module, an array driving module, a storage unit array and a control device, the control device being the control device provided by the first aspect or any optional embodiment of the first aspect, the controller being used to control the processing unit, the forward input module being used to convert an input vector into a voltage configuration signal, the array driving module being used to apply a voltage to the storage unit array according to the voltage configuration signal, the storage unit array being used to process a voltage corresponding to an input vector based on a weight, and output an output signal corresponding to an output vector.
[0018] In a third aspect, a chip for training a neural network is provided, the chip comprising a plurality of first processing units, the first processing units comprising a controller, a forward input module, an array driving module, a storage unit array and a control device, the control device being the control device provided by the first aspect or any optional embodiment of the first aspect, the controller being used to control the processing unit, the forward input module being used to convert an input vector into a voltage configuration signal, the array driving module being used to apply a voltage to the storage unit array according to the voltage configuration signal, the storage unit array being used to process the voltage corresponding to the input vector based on a weight, and output an output signal corresponding to the output vector.
[0019] In some embodiments, the above-mentioned chip also includes at least one second processing unit, which includes a controller, a forward input module, an array driving module, a storage unit array, a forward output module and an activation function module. The controller is used to control the processing unit, the forward input module is used to convert the input vector into a voltage configuration signal, the array driving module is used to apply voltage to the storage unit array according to the voltage configuration signal, the storage unit array is used to process the voltage corresponding to the input vector based on the weight, and output the output signal corresponding to the output vector, and the activation function module is used to process the output signal according to the activation function.
[0020] In a fourth aspect, a computing device is provided, which includes a processor, a memory and a chip, the memory is used to store at least one computer program, the at least one computer program is loaded and executed by the processor, and the chip includes the apparatus provided by the first aspect or any optional embodiment of the first aspect.
[0021] In a fifth aspect, a control method for training a neural network is provided, the method comprising: obtaining an error vector of the i-th layer of the neural network based on an output vector obtained by processing an input vector at time T by a target vector and a storage unit array, the storage unit array being used to train the i-th layer of the neural network, i and T being integers greater than 0; binarizing elements in the output vector based on an output threshold to obtain an output symbol vector; ternaryizing elements in the error vector based on an error threshold to obtain an error symbol vector; outputting an update vector based on the output symbol vector, the error symbol vector and the input vector of the i-th layer of the neural network, the update vector being used to indicate an adjustment direction of the weights of the i-th layer of the neural network to process the input vector at time T+1.
[0022] Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a structural schematic diagram of a neural network training device provided in an embodiment of the present application;
[0024] Figure 2 is a schematic diagram of the structure of another neural network training device provided in an embodiment of the present application;
[0025] Figure 3 is a schematic diagram of the structure of a control device for training a neural network provided in an embodiment of the present application;
[0026] Figure 4 is a structural schematic diagram of a first error acquisition unit provided in an embodiment of the present application;
[0027] Figure 5 is a structural schematic diagram of a second error acquisition unit provided in an embodiment of the present application;
[0028] Figure 6 is a method flow chart of a neural network training method provided in an embodiment of the present application;
[0029] Figure 7 It is a schematic diagram of the structure of a chip provided in an embodiment of the present application;
[0030] Figure 8 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0031] Fig. 9 It is a structural diagram of a smart terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0033] Figure 1 is a schematic diagram of the structure of a neural network training device provided in an embodiment of the present application. The neural network training device supports updating of weights. The neural network training device can be referred to as a processing unit supporting training. The processing unit can be implemented as an intellectual property core (IP core), see Figure 1, the neural network training device is applied to new memory, such as RRAM, PCM and MRAM, and the neural network training device includes a controller 101, a forward input module 102, an array driving module 103, a storage unit array 104 and a control device 105 for training a neural network. Among them, the controller 101 is connected to the forward input module 102, the array driving module 103 and the control device 105, and the array driving module 103 is connected to the storage unit array 104. The controller 101 is used to control the processing unit. The control process includes: outputting a control signal to the forward input module 102, the array driving module 103 and the control device 105, so that the neural network training device enters the forward reasoning state and starts training the neural network; outputting a configuration signal of an output threshold and an error threshold to the control device 105, and adjusting the output threshold and the error threshold in the control device 105; outputting a control signal to the forward input module 102, the array driving module 103 and the control device 105, so that the neural network training device enters the weight control state and adjusts the weight of the neural network; transmitting the signal of the corresponding module. The forward input module 102 is used to store the input vector; convert the input vector into a voltage configuration signal, and output the voltage configuration signal corresponding to the input vector. The array driver module 103 is used to apply a voltage for calculation or a voltage for weight update to the storage unit array 104 according to the voltage configuration signal. The storage unit array 104 is used to calculate the output vector based on the weight and the voltage applied by the array driver module 103, and output the output signal corresponding to the output vector. The control device 105 is used to calculate the update result according to the output signal, and output the update signal corresponding to the update result.
[0034] The following is an example of an iterative process for the i-th layer during the training of the neural network to illustrate the operation process of the above neural network training device. During the neural network training process, the controller 101 outputs a control signal to the forward input module 102, the array driving module 103 and the control device 105, so that the neural network training device enters the forward reasoning state, and outputs the configuration signal of the output threshold and the error threshold to the control device 105. The forward input module 102 that receives the control signal outputs the voltage configuration signal corresponding to the input vector to the array driving module 103 via the controller 101, and the array driving module 103 applies the corresponding voltage to the storage unit array 104 based on the voltage configuration signal. In the storage unit array 104, the conductance value of the storage unit represents the weight. The storage unit array 104 calculates the output vector according to the voltage applied by the array driving module 103, and outputs the output signal corresponding to the output vector to the control device 105 via the controller 101. The controller 101 outputs a control signal to the forward input module 102, the array driving module 103 and the control device 105, so that the neural network training device enters the weight update state. The control device 105 outputs an update signal to the array driving module 103 via the controller 101 according to the output signal. The array driving module 103 applies a corresponding voltage to the memory cell array 104 based on the update signal to adjust the weight stored in the memory cell.
[0035] Figure 2 is a schematic diagram of the structure of another neural network training device provided in an embodiment of the present application. The neural network training device does not support weight update. The neural network training device can be referred to as a processing unit that does not support training. Figure 2 The neural network training device includes a controller 201, a forward input module 202, an array driving module 203, a storage unit array 204, a forward output module 205 and an activation function module 206. The controller 201 is connected to the forward input module 202, the array driving module 203, the forward output module 205 and the activation function module 206, the array driving module 203 is connected to the storage unit array 204, the controller 201 is used to control the processing unit, the forward input module 202 is used to convert the input vector into a voltage configuration signal, the array driving module 203 is used to apply a voltage to the storage unit array 204 according to the voltage configuration signal, the storage unit array 204 is used to calculate the output vector based on the weight and the voltage applied by the array driving module 203, and output the output signal corresponding to the output vector, the forward output module 205 is used to output the output signal of the current layer to the next layer of the neural network, and the activation function module 206 is used to process the output signal according to the activation function.
[0036] Figure 1 and Figure 2The two neural network training devices shown can be tailored and added to suit different architectures and application scenarios, and the specific circuit implementations of each module within the device are not unique based on design changes.
[0037] Figure 3 1 is a schematic diagram of the structure of a control device for training a neural network provided in an embodiment of the present application. The control device is applied to a neural network training device. The control device includes: an error acquisition module 301, a binarization module 302, a ternary module 303 and a weight update module 304. The error acquisition module 301 is respectively connected to the binarization module 302 and the ternary module 303, and the binarization module 302 and the ternary module 303 are respectively connected to the weight update module 304. The control device provided in an embodiment of the present application performs a weight update operation on each training data.
[0038] The error acquisition module 301 is used to obtain the error signal of the i-th layer of the neural network based on the output signal obtained by processing the input signal at time T by the target signal and the storage unit array. The storage unit array is used to train the i-th layer of the neural network, and i and T are both integers greater than 0.
[0039] The error acquisition module 301 includes a plurality of error acquisition units, and the storage unit array is applied to a new type of memory, which can process the input signal based on the weight of the i-th layer of the neural network to obtain the output signal. The input signal is used to indicate the elements in the input vector, the output signal is used to indicate the elements in the output vector, the target signal is used to indicate the elements in the target vector, and the target vector refers to the output vector of the neural network when the network accuracy of the neural network reaches the target network accuracy, and the error signal is used to indicate the elements in the error vector.
[0040] The binarization module 302 is used to binarize the elements in the output vector indicated by the output signal based on the output threshold value to obtain an output symbol signal.
[0041] In some embodiments, the output threshold is not fixed, but changes dynamically with the training of the neural network. When the network accuracy of the neural network reaches the target network accuracy, the output threshold is increased. In various neural network training scenarios, the adjustment method of the output threshold during the training process can be set according to the characteristics of the task to achieve better training results. The output sign signal is used to indicate the output vector after binarization.
[0042] When the network accuracy of the neural network does not reach the target network accuracy, the weights need to be updated quickly. In order to enable fast updates, the weight update module 304 needs to be sensitive to the values of the input vector, output vector and error vector, so the threshold is set relatively small. When the network accuracy of the neural network reaches the target network accuracy, there is no need to update the weights significantly, so the threshold is increased to avoid unnecessary weight updates.
[0043] The ternary module 303 is used to ternary the elements in the error vector indicated by the error signal based on the error threshold to obtain an error sign signal.
[0044] In some embodiments, the error threshold is not fixed but changes dynamically with the training of the neural network. When the network accuracy of the neural network reaches the target network accuracy, the error threshold is increased and the error sign signal is used to indicate the ternary error vector.
[0045] The weight update module 304 is used to output an update signal based on the output sign signal, the error sign signal and the input signal of the i-th layer of the neural network, and the update signal is used to indicate the adjustment direction of the weight of the i-th layer of the neural network to process the input signal at time T+1.
[0046] In the process of training the neural network, the device performs binarization and ternary processing on the output signal and the error signal based on the output threshold and the error threshold to obtain the output sign signal and the error sign signal, which limits the range of weights that need to be updated, reduces the number of weight updates, and thus reduces the computational energy consumption of neural network training. Then, based on the output sign signal, the error sign signal and the input signal, an update signal is obtained, and the update signal indicates the update direction of the weight. Even if the change of the conductivity value of the new memory is uncontrollable and drift occurs, the device can give the correct update direction of the conductivity value of the new memory in the next iteration. Therefore, the device provided in the embodiment of the present application can overcome the non-ideal characteristics of the new memory with less computational energy consumption and improve training efficiency.
[0047] The error acquisition module 301 in the control device for training a neural network provided in the embodiment of the present application is described below. In the embodiment of the present application, the storage unit array of the neural network training device includes M×N storage units. Accordingly, the error acquisition module 301 includes N error acquisition units. The structures of the N error acquisition units are similar. The error acquisition unit is described below by taking the nth error acquisition unit among the N error acquisition units as an example. The nth error acquisition unit can be the first error acquisition unit or the second error acquisition unit. Figure 4 and Figure 5The first error acquisition unit and the second error acquisition unit are respectively introduced as follows:
[0048] Figure 4 : is a schematic diagram of the structure of a first error acquisition unit provided in an embodiment of the present application, the first error acquisition unit is used to process the output signal of the nth column, output the error signal of the nth column and the processed output signal of the nth column, wherein n is an integer greater than 0 and less than or equal to N, the output signal of the nth column is used to indicate the nth element of the output vector, and the error signal of the nth column is used to indicate the nth element of the error vector. Figure 4 The first error acquisition unit includes an integrator 401, a ramp generator 402, a comparator 403, a sampling circuit 404, and a counter 405, wherein the integrator 401 is connected to the comparator 403, the ramp generator 402 is connected to the comparator 403, the comparator 403 is connected to the sampling circuit 404, and the sampling circuit 404 is connected to the counter 405.
[0049] In the embodiment of the present application, between time t1 and time t2, the integrator 401 converts the output signal of the nth column in the storage cell array 104 into a voltage signal, and outputs it to the comparator 403. The ramp generator 402 generates a voltage signal that increases with time, and outputs the voltage signal to the comparator 403. The comparator 403 compares the voltage signal output by the integrator 401 with the voltage signal output by the ramp generator 402, and outputs a pulse sequence. The sampling circuit 404 samples the pulse sequence according to a preset sampling frequency. At the end of time t2, the sampling circuit 404 outputs the sampling sequence to the binarization module 302 and the counter 405. When the i-th layer of the neural network is the output layer, the counter 405 subtracts the target signal from the sampling sequence and outputs the error signal of the n-th column. When the i-th layer of the neural network is not the output layer, the counter 405 obtains the error signal of the n-th column based on back propagation and outputs the error signal of the n-th column.
[0050] Among them, when the voltage signal emitted by the integrator 401 is greater than or equal to the voltage signal emitted by the ramp generator 402, the pulse output by the comparator 403 is 1, and when the voltage signal emitted by the integrator 401 is less than the voltage signal emitted by the ramp generator 402, the pulse output by the comparator 403 is 0. The sampling sequence obtained according to the pulse sequence can be represented by a binary field, which is used to indicate the value of the nth element of the output vector indicated by the output signal of the nth column. The target signal can also be represented by a binary field, which is used to indicate the value of the nth element in the target vector. When the i-th layer of the neural network is the output layer, the target signal is stored in the counter 405 before this iteration. When the i-th layer of the neural network is not the output layer, the counter 405 may not store the target signal.
[0051] In some embodiments, the first error acquisition unit further includes a clock control circuit 406 and an error controller 407 . The error controller 407 is connected to the clock control circuit 406 and the sampling circuit 404 , respectively. The clock control circuit 406 is connected to the ramp generator 402 .
[0052] The clock control circuit 406 is used to control the increasing rate of the output voltage of the ramp generator 402, and the error controller 407 is used to control the clock frequency of the clock control circuit 406, thereby controlling the increasing rate of the output voltage of the ramp generator 402, and also used to control the sampling frequency of the sampling circuit 404. When it is necessary to make the output signal larger, the error controller 407 can make the sampling frequency of the sampling circuit 404 faster, or slow down the clock frequency of the clock control circuit 406, so as to slow down the increasing rate of the output voltage of the ramp generator 402, so as to increase the output signal corresponding to the pulse sequence output by the comparator 403. When it is necessary to make the output signal smaller, the error controller 407 can make the sampling frequency of the sampling circuit 404 slower, or speed up the clock frequency of the clock control circuit 406, so as to speed up the increasing rate of the output voltage of the ramp generator 402, so as to decrease the output signal corresponding to the pulse sequence output by the comparator 403.
[0053] The error controller 407 can control the increasing rate of the output voltage of the ramp generator 402 by controlling the clock frequency of the clock control circuit 406, thereby controlling the size of the output vector indicated by the increasing sequence output by the comparator 403, which is equivalent to adjusting the output threshold. By controlling the sampling frequency of the sampling circuit 404, the size of the output vector indicated by the sampling sequence output by the sampling circuit 404 can be controlled, which is equivalent to adjusting the output threshold. The error controller 407 can control the size of the output vector when the i-th layer of the neural network is not the output layer, which is equivalent to controlling the output threshold. The error controller 407 can also control the size of the error vector represented by the error signal by controlling the size of the output vector when the i-th layer of the neural network is the output layer. The counter 405 can also adjust the size of the error signal by adjusting the size of the target signal, which plays the role of equivalently adjusting the error threshold.
[0054] By equivalently adjusting the output threshold and the error threshold, the update of the neural network weights can be controlled. By equivalently adjusting to a smaller threshold, that is, enlarging the output vector and the error vector, the number of weight updates can be increased to ensure that the neural network converges quickly to a small loss function value. By equivalently adjusting to a larger threshold, that is, reducing the output vector and the error vector, it is possible to avoid adjusting the conductance value that has reached the target weight in the new memory.
[0055] In some embodiments, a plurality of first error acquisition units may share the ramp generator 402 and the clock control circuit 406 , and the memory cell array 104 and the first error acquisition units are connected via a source line (SL).
[0056] Figure 5 : is a structural schematic diagram of a second error acquisition unit provided in an embodiment of the present application, the second error acquisition unit is used to process the output signal of the nth column, output the error signal of the nth column and the processed output signal of the nth column, wherein n is an integer greater than 0 and less than or equal to N, the output signal of the nth column is used to indicate the nth element of the output vector, and the error signal of the nth column is used to indicate the nth element of the error vector. Figure 5 The second error acquisition unit includes an analog to digital converter (ADC) 501 and a counter 502. The ADC 501 and the counter 502 are connected. The ADC 501 is used to convert the output signal of the nth column in the storage unit array 104 into a digital signal, and output the converted output signal to the binarization module 302 and the counter 502. The counter 502 is used to subtract the target signal from the digital signal when the i-th layer of the neural network is the output layer, and output the error signal of the nth column. The counter is also used to obtain the error signal of the nth column based on back propagation when the i-th layer of the neural network is not the output layer, and output the error signal of the nth column. In some embodiments, the above-mentioned ADC 501 can be a single-slope ADC or other types of ADCs.
[0057] When the i-th layer of the neural network is not the output layer, the second error acquisition unit does not need to equivalently adjust the output threshold and the error threshold. When the i-th layer of the neural network is the output layer, the counter 502 in the second error acquisition unit can adjust the size of the target signal and the size of the error signal to play the role of equivalently adjusting the error threshold.
[0058] When the second error acquisition unit is used to acquire the error signal, there is no need to adjust the output threshold and the error threshold by processing the output signal. Therefore, in the neural network training process, the counter 502 in the second error acquisition unit adjusts the error threshold by adjusting the size of the target signal, or the binarization module 302 and the ternary module 303 coordinated with the second error acquisition unit need to adjust the output threshold and the error threshold based on the threshold configuration signal output by the controller 101 to control the number of weight updates. The first error acquisition unit can adjust the output threshold and the error threshold by processing the output signal. Therefore, there is no need to adjust the size of the target signal in the counter 405 of the first error acquisition unit or the output threshold and the error threshold of the binarization module 302 and the ternary module 303 coordinated with the first error acquisition unit, and the weight update can also be controlled. In the actual training process, the first error acquisition unit or the second error acquisition unit can be selected to acquire the error signal according to actual needs.
[0059] The binarization module 302 in the control device for training a neural network provided in the embodiment of the present application is described below. In the embodiment of the present application, the binarization module 302 compares the processed output signal output by the error acquisition module 301 with the output threshold. If the processed output signal is greater than or equal to the output threshold, the element of the output vector corresponding to the output signal is 1. If the processed output signal is less than the output threshold, the element of the output vector corresponding to the output signal is 0. After binarizing all output signals in this iteration, the binarization module 302 obtains an output symbol signal, and outputs the output symbol signal to the weight update module 304.
[0060] In the above comparison process, the processed output signal and the output threshold are both binary fields. Take the n1 high bits in the processed output signal. If the n1 high bits in the processed output signal contain at least one 1, the processed output signal is greater than or equal to the output threshold. If the n1 high bits in the processed output signal do not contain 1, the processed output signal is less than the output threshold, and n1 is an integer greater than zero.
[0061] By using the above method to compare the output signal and the output threshold, the output threshold can be further adjusted by controlling the number of high bits intercepted during the comparison process. By binarizing the output vector, the range of weights that need to be updated is limited, the number of weight updates is reduced, and thus the computational energy consumption of neural network training is reduced.
[0062] The following is an explanation of the ternary module 303 in the control device for training a neural network provided in the embodiment of the present application. In the embodiment of the present application, the ternary module 303 receives the error signal output by the error acquisition module 301, and compares the error signal with the error threshold. If the error signal is greater than or equal to the error threshold, the element of the error vector corresponding to the error signal is 1, if the error signal is less than or equal to the negative value of the error threshold, the element of the error vector corresponding to the error signal is -1, if the error signal is less than the error threshold and greater than the negative value of the error threshold, the element of the error vector corresponding to the error signal is 0. After the ternary module 303 ternary-values all error signals in this iteration, an error sign signal is obtained, and the error sign signal is output to the weight update module 304.
[0063] In the above comparison process, the error signal and the error threshold are both binary fields. Take the n2 high bits in the error signal. If only the last bit of the n2 high bits in the error signal is 1, the error signal is equal to the error threshold. If the n2 high bits in the error signal contain at least one 1 except the last bit, the error signal is greater than the error threshold. If the n2 high bits in the error signal do not contain 1, the error signal is less than the error threshold, and n2 is an integer greater than zero.
[0064] By using the above method to compare the error signal and the error threshold, the size of the error threshold can be further adjusted by controlling the number of high bits intercepted during the comparison process. By ternary processing the error vector, the range of weights that need to be updated is limited, the number of weight updates is reduced, and thus the computational energy consumption of neural network training is reduced. It can also filter out some smaller error values to prevent the weight update from being too sensitive, which is conducive to improving the convergence of the model.
[0065] The weight updating module 304 in the control device for training a neural network provided in the embodiment of the present application is described below. In the embodiment of the present application, the weight updating module 304 obtains a weight update symbol based on the output symbol signal output by the binarization module 302, the error symbol signal output by the ternary module 303, and the output symbol signal of the previous layer of the neural network. After obtaining the weight update symbol, the array driving module 103 applies a corresponding voltage to the storage unit array 104 to increase or decrease the weight.
[0066] Among them, the output symbol signal of the previous layer of the neural network can also be obtained by binarizing the input signal of this layer of the neural network.
[0067] In some embodiments, if the update signal is 1, the matrix driving module 103 at the row end applies a positive voltage to the corresponding storage unit, and the matrix driving module 103 at the column end applies a negative voltage to the corresponding storage unit, so that the weight of the storage unit increases; if the update signal is -1, the matrix driving module 103 at the column end applies a positive voltage to the corresponding storage unit, and the matrix driving module 103 at the row end applies a negative voltage to the corresponding storage unit, so that the weight of the storage unit decreases; if the update signal is 0, the matrix driving module 103 at the row end and the matrix driving module 103 at the column end apply the same direction voltage to the corresponding storage unit, so that the weight of the storage unit remains unchanged.
[0068] Since the device provided in the embodiment of the present application gives the direction of weight update rather than the specific update value of the weight, even if the change of the conductivity value of the new memory is uncontrollable and drift occurs, the device can give the correct update direction of the conductivity value of the new memory in the next iteration.
[0069] The control device for training a neural network provided by the embodiment of the present application performs binarization and ternary processing on the output signal and the error signal based on the output threshold and the error threshold in the process of training the neural network, obtains the output sign signal and the error sign signal, limits the range of weights that need to be updated, reduces the number of weight updates, and thus reduces the computational energy consumption of neural network training, and then obtains the update signal based on the output sign signal, the error sign signal and the input signal, the update signal indicates the update direction of the weight, even if the change of the conductivity value of the new memory is uncontrollable and drift occurs, the device can also give the correct update direction of the conductivity value of the new memory in the next iteration. Therefore, the device provided by the embodiment of the present application can overcome the non-ideal characteristics of the new memory with less computational energy consumption and improve training efficiency.
[0070] In addition, since the control device for training a neural network provided by the embodiment of the present application provides a variety of equivalent ways to adjust the threshold, the hardware overhead can be flexibly adjusted according to the needs of model training. Since the output threshold and error threshold can be adjusted according to the training situation, the network accuracy of the neural network trained by the device is high, and the device can be applied to the training of neural networks with larger weight matrices. Since the computing energy consumption of the device for training neural networks is small, the required hardware is small and the time consumption is short. In the chip architecture, a neural network training device that supports training and a neural network training device that does not support training can be flexibly combined to minimize the overall hardware of the chip.
[0071] The following uses a two-layer perceptron model as an example to illustrate the neural network training method corresponding to the control device for training the neural network. Figure 6is a method flow chart of a neural network training method provided in an embodiment of the present application, see Figure 6 , the method comprises the following steps:
[0072] 601. Obtain an output vector based on an input vector and a weight matrix corresponding to the conductance value of the storage unit array.
[0073] The two-layer perceptron model uses a rectified linear unit (ReLU) as an activation function, and uses the conductance value of a storage unit to represent the weight in the neural network. If the weight is a signed weight, the difference between the conductance values of two storage units represents the signed weight. In the forward reasoning stage, the calculation of the output vector is completed by the storage unit array 104 and its peripheral circuits, and the acquisition of the output vector is achieved by the following formulas (1), (2), and (3):
[0074]
[0075]
[0076] Y2=ReLU(Z) (3)
[0077] Among them, W1 is used to represent the weight matrix corresponding to the conductance value of the first layer of the neural network; X is used to represent the input vector; ReLU() is used to represent the activation function; Y1 is used to represent the output vector of the first layer of the neural network; Z is used to represent the weighted sum vector of the second layer of the neural network; W2 is used to represent the weight matrix corresponding to the conductance value of the second layer of the neural network; Y2 is used to represent the output vector of the second layer of the neural network. In some neural network training methods, the weighted sum vector of the last layer does not need to be calculated through the activation function, so formula (3) can be omitted.
[0078] 602. Obtain an error vector based on the output vector and the target vector.
[0079] The step of obtaining the error vector is completed by the error obtaining module 301 .
[0080] When the i-th layer of the neural network is the output layer, for each element in the output vector, the element in the output vector can be directly subtracted from the corresponding element in the target vector to obtain the corresponding element in the error vector, or the element in the output vector can be scaled and then the scaled element in the output vector can be subtracted from the corresponding element in the target vector to obtain the corresponding element in the error vector, wherein the step of scaling the element in the output vector is implemented by the error controller of the corresponding error acquisition unit in the error acquisition module through controlling the clock controller or the sampling circuit. The acquisition of the error vector is implemented by the following formula (4):
[0081] E=T-Y2 or E=TZ (4)
[0082] Among them, T is used to represent the target vector; E is used to represent the error vector; Y2 is used to represent the output vector of the second layer of the neural network; and Z is used to represent the weighted sum vector of the second layer of the neural network.
[0083] When the i-th layer of the neural network is not the output layer, the error vector is obtained through back propagation of the neural network training.
[0084] 603. Binarize the output vector.
[0085] Herein, this step 603 is completed by the above-mentioned binarization module 302 .
[0086] The binarization of the output vector is achieved by the following formulas (5) and (6):
[0087]
[0088]
[0089] Among them, sy1 and sy2 are respectively used to represent the elements of the binarized output vectors Y1 and Y2; y1 and y2 are respectively used to represent the elements of the output vectors Y1 and Y2; C1 and C2 are respectively used to represent the output thresholds of the first layer and the second layer of the neural network, which can be flexibly configured. In some embodiments, if the ReLU activation function is applied to the weighted and output vector Z, the value of C1 is typically the maximum value in the first layer output multiplied by 0.4, and the value of C2 is typically set to zero. If the ReLU activation function is not applied to the weighted and output vector Z, there is no C2, and the value of C1 is typically zero.
[0090] 604. Tri-value the error vector.
[0091] Herein, this step 604 is completed by the above-mentioned ternary module 303 .
[0092] The ternary value of the error vector is realized by the following formula (7):
[0093]
[0094] Among them, se is used to represent the elements of the ternary error vector E; e is used to represent the elements in the error vector E; Th is used to represent the error threshold of the second layer of the neural network.
[0095] 605. Obtain an update vector based on the binarized output vector, the binarized input vector, and the ternary error vector.
[0096] The step of obtaining the update vector is completed by the weight updating module 304 .
[0097] The update vector is obtained by the following formula (8):
[0098] ΔW2=SY1·(SY2 T ⊙SE T ) or ΔW2=SY1·SE T (8)
[0099] Among them, ΔW2 is used to represent the weight update direction of the second layer of the neural network; SY1 is used to represent the binarized input vector of the second layer of the neural network; SY2 is used to represent the binarized output vector of the second layer of the neural network; SE is used to represent the ternary error vector of the second layer of the neural network.
[0100] 606. Adjust the weight of the second layer of the neural network according to the update signal.
[0101] The step of adjusting the weight is completed by the array driving module 103 controlling the storage unit array 104 .
[0102] The control device for training a neural network provided in the embodiment of the present application can be applied to incremental learning scenarios. In the incremental learning process, the neural network is allowed to update the neural network by learning new data based on some old data that has been learned, so as to learn the knowledge related to the new data without forgetting the knowledge of the existing data. Therefore, the following dynamic threshold adjustment scheme can be set in the incremental learning scenario: in the early stage of incremental learning, a smaller threshold is set to ensure rapid learning of new data; as the incremental learning process proceeds, the threshold is gradually increased to avoid excessive learning of new data and forgetting the knowledge of existing data.
[0103] When incremental learning is implemented using the device provided in the embodiments of the present application, the weights of the layers in the neural network that need to be adjusted are first deployed to the storage unit array of the neural network training device that supports training, and the weights of the layers in the neural network that do not need to be adjusted are deployed to the storage unit array of the neural network training device that does not support training.
[0104] Then, in the early stage of incremental learning, a smaller output threshold and error threshold can be used for updating, so that the number of updated weights is larger, so as to achieve the purpose of rapid learning; when the network accuracy of the neural network reaches the target network accuracy, the output threshold and error threshold in the control device are increased to reduce the number of updated weights and avoid updating weights that have reached the target weights.
[0105] During the incremental learning process, the output threshold and the error threshold may not be changed. Instead, the sampling frequency of the sampling circuit or the voltage increment rate of the ramp generator may be controlled by the error controller in the first error acquisition unit, thereby adjusting the size of the output vector and the size of the error vector, which is equivalent to adjusting the output threshold and the error threshold. Alternatively, the size of the target vector may be adjusted by the counter in the first error acquisition unit or the counter in the second error acquisition unit, which is equivalent to adjusting the error threshold.
[0106] An embodiment of the present application provides a chip for training a neural network, the chip includes multiple first processing units, the first processing units include a control device, a controller, a forward input module, an array driving module and a storage unit array, the controller is used to control the processing unit, the forward input module is used to convert an input vector into a voltage configuration signal, the array driving module is used to apply a voltage to the storage unit array according to the voltage configuration signal, the storage unit array is used to calculate an output vector based on a weight and the voltage applied by the array driving module, and output an output signal corresponding to the output vector.
[0107] In some embodiments, the above-mentioned chip also includes at least one second processing unit, which includes a controller, a forward input module, an array driving module, a storage unit array, a forward output module and an activation function module. The controller is used to control the processing unit, the forward input module is used to convert the input vector into a voltage configuration signal, the array driving module is used to apply a voltage to the storage unit array according to the voltage configuration signal, the storage unit array is used to calculate the output vector based on the weight and the voltage applied by the array driving module, and output the output signal corresponding to the output vector, and the activation function module is used to process the output signal according to the activation function.
[0108] Figure 7 is a schematic diagram of the structure of a chip provided in an embodiment of the present application, see Figure 7 Considering that only some weights of neural network layers are usually updated in edge training applications, a hybrid chip based on a new memory storage and computing technology is proposed to implement training. Figure 1 The processing unit supporting training, i.e., the first processing unit, in some embodiments, further includes: Figure 2 A processing unit that does not support training is shown, namely the second processing unit. Figure 7 In the figure, the processing units with loop arrows are processing units that support training, and the processing units without loop signals are processing units that do not support training.
[0109] Different processing units can be combined into computing modules at different granularities, and a computing module can include one or more processing units. A computing module can include only processing units that support training, becoming a computing module that supports training; it can also include only processing units that do not support training, becoming a computing module that does not support training; it can also include both processing units that support training and processing units that do not support training, becoming a computing module that partially supports training. In some embodiments, the above-mentioned multiple computing modules are interconnected through an on-chip routing mechanism and communicate based on communication nodes.
[0110] An embodiment of the present application provides a computing device, which includes a processor, a memory and a chip, the memory is used to store at least one computer program, the at least one computer program is loaded and executed by the processor, and the chip includes the above-mentioned control device.
[0111] Figure 8 It is a structural diagram of a computing device provided in an embodiment of the present application. The computing device 800 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 801, one or more memories 802, and one or more chips 803, wherein the memory 802 stores at least one computer program, and the at least one computer program is loaded and executed by the processor 801, and the chip 803 includes the control device provided in the embodiment of the present application, and can train a neural network according to the technical solution provided in the embodiment of the present application. Of course, the computing device may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the computing device may also include other components for realizing the functions of the device, which will not be repeated here.
[0112] In the embodiments of the present application, the computing device can be configured as a terminal or a server, and the terminal or the server serves as an execution subject to implement the technical solution provided in the embodiments of the present application.
[0113] In some embodiments, the computing device may be implemented as a smart terminal device, for example, Fig. 9 It is a structural diagram of a smart terminal device provided in an embodiment of the present application. The smart terminal device 900 includes a microphone 901, a speaker 902, a screen 903, a mainboard 904 and a battery 905. The mainboard 904 includes a CPU, a memory, a flash memory and a chip for training a neural network. The smart terminal device includes a watch, a headset, a mobile phone, a voice assistant, AR / VR, a smart home (door locks, voice assistants, etc.) and other terminal devices with reasoning and learning functions. The smart terminal device receives input data through a microphone or a screen, and after the neural network is trained, the trained data is output through a speaker or a screen.
[0114] The product involved in the embodiment of the present application may be a chip or an IP core, and the IP core refers to an independent functional module in an integrated circuit. The binarization module, the ternary module, and the error acquisition module in the embodiment of the present application can all be implemented using registers, that is, the input vector of any layer in the neural network, the output threshold used by any binarization module, and the error threshold used by any ternary module are stored respectively through different registers.
[0115] It should be understood that when the above-mentioned control device trains a neural network, it only uses the division of the above-mentioned functional modules as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the control device can be divided into different functional modules to complete all or part of the functions described above.
[0116] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0117] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0118] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0119] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0120] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "plurality" means two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different.
[0121] In this application, the words "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the words "exemplary" or "for example" is intended to present the related concepts in a concrete way.
[0122] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0123] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, and will not be described in detail here.
[0124] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A control device for training a neural network, characterized in that: The control device comprises: an error acquisition module, a binarization module, a ternary module and a weight updating module, wherein the error acquisition module is connected to the binarization module and the ternary module respectively, and the binarization module and the ternary module are connected to the weight updating module respectively. The error acquisition module is used to obtain the error signal of the i-th layer of the neural network based on the target signal and the output signal obtained by the storage unit array processing the input signal at time T, wherein the storage unit array is used to train the i-th layer of the neural network, and i and T are both integers greater than 0; The binarization module is used to binarize the elements in the output vector indicated by the output signal based on the output threshold value to obtain an output symbol signal; The ternary module is used to ternary the elements in the error vector indicated by the error signal based on the error threshold to obtain an error sign signal; The weight updating module is used to output an update signal based on the output sign signal, the error sign signal and the input signal of the i-th layer of the neural network, wherein the update signal is used to indicate the adjustment direction of the weight of the i-th layer of the neural network so as to process the input signal at time T+1.
2. The control device according to claim 1, characterized in that: When the network accuracy of the neural network reaches the target network accuracy, the output threshold is increased.
3. The control device according to claim 1 or 2, characterized in that: When the network accuracy of the neural network reaches the target network accuracy, the error threshold is increased.
4. The control device according to any one of claims 1 to 3, characterized in that: The storage unit array includes M×N storage units, the error acquisition module includes N first error acquisition units, The nth first error acquisition unit is used to process the output signal of the nth column, and output the error signal of the nth column and the processed output signal of the nth column, wherein n is an integer greater than 0 and less than or equal to N; The nth first error acquisition unit includes: an integrator, a comparator, a sampling circuit, a counter and a ramp generator; Wherein, the integrator is connected to the comparator, and the ramp generator is connected to the comparator; The integrator is used to convert the output signal of the nth column in the storage cell array into a voltage; The comparator is used to compare the output of the integrator with the output of the ramp generator and output a pulse sequence; The comparator is connected to the sampling circuit, the sampling circuit is connected to the counter, the sampling circuit samples the pulse sequence and outputs the sampling sequence to the counter; The counter is used to subtract the target signal from the sampling sequence and output the error signal of the nth column when the i-th layer of the neural network is the output layer; The counter is also used to obtain the error signal of the nth column based on back propagation and output the error signal of the nth column when the i-th layer of the neural network is not the output layer.
5. The control device according to claim 4, characterized in that: The first error acquisition unit further includes a clock control circuit and an error controller, wherein the error controller is connected to the clock control circuit and the sampling circuit respectively, and the clock control circuit is connected to the ramp generator. The clock control circuit is used to control the increasing rate of the output voltage of the ramp generator; The error controller is used to control the clock frequency of the clock control circuit and is also used to control the sampling frequency of the sampling circuit.
6. The control device according to any one of claims 1 to 3, characterized in that: The storage unit array includes M×N storage units, the error acquisition module includes N second error acquisition units, The nth second error acquisition unit is used to process the output signal of the nth column, and output the error signal of the nth column and the processed output signal of the nth column, wherein n is an integer greater than 0 and less than or equal to N; The nth second error acquisition unit comprises: an ADC and a counter, wherein the ADC is connected to the counter, and the ADC is used to convert the output signal of the nth column in the storage unit array into a digital signal; The counter is used to subtract the target signal from the digital signal and output an error signal of the nth column when the i-th layer of the neural network is the output layer; The counter is also used to obtain the error signal of the nth column based on back propagation and output the error signal of the nth column when the i-th layer of the neural network is not the output layer.
7. A processing unit for training a neural network, characterized in that The processing unit includes a controller, a forward input module, an array driving module, a storage cell array and a control device according to any one of claims 1 to 6, wherein the controller is used to control the processing unit, the forward input module is used to convert an input vector into a voltage configuration signal, the array driving module is used to apply a voltage to the storage cell array according to the voltage configuration signal, and the storage cell array is used to process the voltage corresponding to the input vector based on a weight and output an output signal corresponding to an output vector.
8. A chip for training a neural network, characterized in that: The chip includes multiple first processing units, which include a controller, a forward input module, an array driving module, a storage unit array and a control device according to any one of claims 1 to 6, wherein the controller is used to control the processing unit, the forward input module is used to convert an input vector into a voltage configuration signal, the array driving module is used to apply a voltage to the storage unit array according to the voltage configuration signal, and the storage unit array is used to process the voltage corresponding to the input vector based on a weight, and output an output signal corresponding to an output vector.
9. The chip according to claim 8, characterized in that: The chip also includes at least one second processing unit, which includes a controller, a forward input module, an array driving module, a storage unit array, a forward output module and an activation function module. The controller is used to control the processing unit, the forward input module is used to convert the input vector into a voltage configuration signal, the array driving module is used to apply a voltage to the storage unit array according to the voltage configuration signal, the storage unit array is used to process the voltage corresponding to the input vector based on a weight, and output an output signal corresponding to the output vector, and the activation function module is used to process the output signal according to the activation function.
10. A computing device, characterized in that The computing device includes a processor, a memory and a chip, wherein the memory is used to store at least one computer program, and the at least one computer program is loaded and executed by the processor, and the chip includes the apparatus described in any one of claims 1 to 6.
11. A control method for training a neural network, characterized in that: The method comprises: Obtaining an error vector of the i-th layer of the neural network based on an output vector obtained by processing an input vector at time T by a target vector and a storage unit array, wherein the storage unit array is used to train the i-th layer of the neural network, and i and T are both integers greater than 0; Based on an output threshold, binarize the elements in the output vector to obtain an output symbol vector; Based on the error threshold, ternary-converting the elements in the error vector to obtain an error sign vector; Based on the output symbol vector, the error symbol vector and the input vector of the i-th layer of the neural network, an update vector is output, wherein the update vector is used to indicate the adjustment direction of the weights of the i-th layer of the neural network to process the input vector at time T+1.