Adam algorithm acceleration system and method
By using the fast square root reciprocating algorithm in the Adam algorithm acceleration system to replace division operation, the throughput and resource utilization of the Adam algorithm on the FPGA side is improved, and the problem of high resource consumption when deploying the Adam algorithm on the FPGA side is solved.
Patent Information
- Application Number
- CN202210601059.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-30
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-05-30
AI Technical Summary
When deploying the Adam algorithm on the FPGA side, it involves square, square and division operations, resulting in large resource consumption and slow operation speed, resulting in the on-chip training system using GD and SGD optimizers, with a low throughput rate.
A Adam algorithm acceleration system was designed, including a first-order moment estimation subsystem, a second-order moment square root estimation subsystem and an update step calculation subsystem. The fast square root reciprocity algorithm is used to replace division by multiplication, addition, and shift operations, and the calculation and update are calculated. Step to avoid division operations.
Effectively save hardware resources, reduce power consumption, significantly improve the throughput of the circuit, and improve the performance of the Adam algorithm training neural network in hardware.
Smart Images

Figure CN115034373B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of machine learning and circuit design, and in particular to an Adam algorithm acceleration system and method. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section.
[0003] Due to the high computational complexity of neural network training, the most mainstream hardware acceleration methods currently only accelerate the reasoning of neural networks, and use GPUs and other devices to complete the training part in advance. In recent years, with the development of technologies such as edge computing, on-chip training has become an important research field. On-chip training is to train network parameters on the hardware side, which can achieve performance optimization of edge devices. The essence of training a neural network is to repeat the forward and backward propagation of the network and continuously find suitable parameters. The direction of updating parameters is the direction that minimizes the loss function. The loss function is used to measure the difference between the true value and the result obtained by the forward propagation of the network. Therefore, the task of the optimization algorithm is to calculate the gradient of the loss function and update the parameters according to this value. Common optimization algorithms include gradient descent (Stochastic Gradient Descent, SGD), stochastic gradient descent with momentum (Momentum-SGD), Adagrad, Adadelta and adaptive moment estimation (Adaptive Moment Estimation, Adam). The Adam algorithm combines the advantages of the Momentum and Adadelta algorithms, considers both the first-order moment estimation and the second-order moment estimation during the iteration process, and dynamically adjusts the learning rate of each parameter. Currently, the Adam algorithm has been widely used due to its good performance and fast convergence speed.
[0004] With the continuous development of the field of neural networks, the computational complexity required by algorithms is getting higher and higher. Deploying neural networks to hardware (FPGA) for acceleration has gradually become a new development trend. Hardware (FPGA) is different from software. Its unique parallel computing method can greatly improve the running speed of the algorithm, but at the same time, limited resource configuration and loss of precision have also become obstacles to hardware acceleration. The Adam algorithm involves square, square root, and division operations. These calculations consume a lot of computing resources on the FPGA side and seriously reduce the running speed. At present, due to the shortcomings of ADAM, GD and SGD are used as optimizers in on-chip training systems. Whether in terms of resource consumption or throughput, the effect of Adam optimizer deployed on the FPGA side is worse than that of SGD and GD optimizers. Therefore, a low-resource-occupancy, high-throughput Adam algorithm acceleration solution is currently needed to greatly improve the performance of on-chip training systems. Summary of the invention
[0005] The embodiment of the present invention provides an Adam algorithm acceleration system for realizing Adam algorithm acceleration when training a neural network in hardware to improve throughput. The system includes: a first-order moment estimation subsystem, a second-order moment square root estimation subsystem and an update step calculation subsystem, wherein:
[0006] The first-order moment estimation subsystem is used to calculate the first-order moment of this round based on the first-order moment of the previous round and the gradient of this round;
[0007] The second-order moment square root estimation subsystem is used to calculate the second-order moment square root of this round based on the second-order moment square root of the previous round and the gradient of this round;
[0008] The update step calculation subsystem includes:
[0009] A square root reciprocal calculation module is used to calculate the square root reciprocal according to the square root of the second-order moment of this round by using a fast square root reciprocal algorithm;
[0010] A first multiplier, for multiplying the first-order moment of this round by the inverse square root;
[0011] The second multiplier is used to multiply the output of the first multiplier by the inverse square root to obtain the current round update step, and the current round update step is used to train the neural network in hardware and update the network parameters.
[0012] The embodiment of the present invention further provides an Adam algorithm acceleration method for accelerating the Adam algorithm when training a neural network in hardware to improve throughput. The method includes:
[0013] Calculate the first-order moment of this round based on the first-order moment of the previous round and the gradient of this round;
[0014] Calculate the square root of the second-order moment of this round based on the square root of the second-order moment of the previous round and the gradient of this round;
[0015] A square root reciprocal calculation module is used to calculate the square root reciprocal according to the square root of the second-order moment of this round by using a fast square root reciprocal algorithm;
[0016] Multiply the first moment of this round by the inverse square root;
[0017] The output of the first multiplier is multiplied by the inverse of the square root to obtain a current round of update steps, which are used to train the neural network in hardware and update network parameters.
[0018] In the embodiment of the present invention, the first-order moment estimation subsystem is used to calculate the first-order moment of this round according to the first-order moment of the previous round and the gradient of this round; the second-order moment square root estimation subsystem is used to calculate the square root of the second-order moment of this round according to the square root of the second-order moment of the previous round and the gradient of this round; the update step calculation subsystem includes: a square root inverse calculation module, which is used to use a fast square root inverse algorithm to calculate the square root inverse according to the square root of the second-order moment of this round; a first multiplier is used to multiply the first-order moment of this round with the square root inverse; the second multiplier is used to multiply the output of the first multiplier with the square root inverse to obtain the update step of this round, and the update step of this round is used to train the neural network in hardware and update the network parameters. Compared with the prior art, the scheme of the present invention adopts a fast square root inverse algorithm when calculating the update step, calculates the square root inverse, multiplies the first-order moment of this round by the square root inverse, multiplies the output of the first multiplier by the square root inverse, and obtains the update step of this round. No division operation is required, and only multiplication, addition, and shift operations need to be used to obtain the result of the division operation, thereby effectively saving hardware resources, reducing power consumption, and greatly improving the throughput of the circuit. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0020] Figure 1 Schematic diagram of the Adam algorithm acceleration system in an embodiment of the present invention Figure 1 ;
[0021] Figure 2 is a schematic diagram of a first-order moment estimation subsystem in an embodiment of the present invention;
[0022] Figure 3 In the embodiment of the present invention, Figure 2 The corresponding circuit implementation;
[0023] Figure 4 Schematic diagram of the Adam algorithm acceleration system in an embodiment of the present invention Figure 2 ;
[0024] Figure 5 Schematic diagram of a square root reciprocal calculation module in an embodiment of the present invention;
[0025] Figure 6 Schematic diagram of a square root reciprocal calculation module in an embodiment of the present invention;
[0026] Figure 7Schematic diagram of a Newton iterative calculation module in an embodiment of the present invention;
[0027] Figure 8 The circuit implementation of the update step calculation subsystem in the embodiment of the present invention;
[0028] Fig. 9 Flow chart of the Adam algorithm acceleration method in an embodiment of the present invention. DETAILED DESCRIPTION
[0029] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0030] Figure 1 Schematic diagram of the Adam algorithm acceleration system in an embodiment of the present invention Figure 1 , including: a first-order moment estimation subsystem 101, a second-order moment square root estimation subsystem 102 and an update step calculation subsystem 103, wherein,
[0031] The first-order moment estimation subsystem 101 is used to estimate the first-order moment m of the previous round according to the t-1 With the current round gradient g t , calculate the first-order moment m of this round t ;
[0032] The second-order moment square root estimation subsystem 102 is used to estimate the second-order moment square root vr of the previous round according to the second-order moment square root vr t-1 With the current round gradient g t , calculate the square root of the second-order moment vr t ;
[0033] Update step calculation subsystem 103 The update step calculation subsystem includes:
[0034] The square root inverse calculation module 1031 is used to use a fast square root inverse algorithm to calculate the square root vr of the second-order moment of this round. t , calculate the inverse square root;
[0035] The first multiplier 1032 is used to multiply the first-order moment m of this round t Multiply by the reciprocal square root;
[0036] The second multiplier 1033 is used to multiply the output of the first multiplier by the inverse square root to obtain the current round update step, which is used to train the neural network in hardware and update the network parameters.
[0037] Among them, the second-order moment estimate is v t , square root of the second moment
[0038] Figure 2 Schematic diagram of a first-order moment estimation subsystem in an embodiment of the present invention. In one embodiment, the first-order moment estimation subsystem includes:
[0039] A first shift register 201, configured to perform a right shift operation on the first-order moment of the previous round according to a first right shift number, to obtain a first-order moment after right shift, wherein the first right shift number is determined according to a first-order exponential attenuation factor;
[0040] The second shift register 202 is used to right-shift the gradient of this round according to the first right-shift number to obtain the gradient after right-shift;
[0041] A first inverter 203, used for inverting the first-order moment after right shifting to obtain an inverted first-order moment;
[0042] A first adder 204 is used to perform addition calculation on the first-order moment of the previous round and the inverted first-order moment to obtain a first sum;
[0043] The second adder 205 is used to perform addition calculation on the first sum and the right-shifted gradient to obtain the first-order moment of this round.
[0044] In one embodiment, the first-order exponential decay factor β1=1-2 -m , second-order exponential decay factor β2 = 1-2 -n , learning rate β1 = 2 -k , where m, n, and k are natural numbers greater than 0.
[0045] In the existing Adam algorithm, β1 is usually set to 0.99 and β2 is usually set to 0.999. This value cannot convert multiplication into shift, and other operations such as multiplication and division require high resource overhead. t =β1·m t-1 +(1-β1)·g t The multiplication operation in is converted to a fixed-point shift calculation: m t ←m t-1 -m t-1 >>m+g t >>m, for example, when m=3, m t ←m t-1 -m t-1 >>3+g t >>3(β1=1-2 -3 ), through conversion, the calculation accuracy remains unchanged, the calculation speed is improved, and the resource overhead required for calculation is reduced.
[0046] Figure 3 In the embodiment of the present invention, Figure 2 The corresponding circuit is realized, where the first-order exponential decay factor β1 = 1-2-3 For example, the first right shift number is 3.
[0047] Figure 4 Schematic diagram of the Adam algorithm acceleration system in an embodiment of the present invention Figure 2 In one embodiment, it further includes a parameter updating module 401, wherein the parameter updating module 401 includes:
[0048] The hyperparameter processing module 4011 is used to process the first parameter 1-β1 according to the first-order exponential decay factor β1 and the second-order exponential decay factor β2. t 、Second parameter 1-β2 t Take an approximation; use the formula Determine the second right shift number, where y is the second right shift and lr is the learning rate;
[0049] The third shift register 4012 is used for performing a right shift operation on the output of the second multiplier according to the second right shift bit number to obtain a scaled current round update step;
[0050] The network parameter updating module 4013 is used to update the network parameters according to the first parameter, the second parameter, the current round update step and the learning rate.
[0051] When approximation is taken, t is taken as 1. Since the prior art does not perform approximation, each round of calculation requires calculation of a new first parameter and a new second parameter. At the same time, the obtained value cannot realize multiplication operation simplification to shift operation, so the calculation complexity is higher. The present invention reduces multiplication calculation without significantly affecting the optimization performance, thereby reducing the consumption of computing resources and improving the calculation speed.
[0052] When determining the second right shift number, for example, the learning rate lr = 2 -6 , first-order exponential decay factor first-order exponential decay factor β1 = 1-2 -3 , second-order exponential decay factor β2 = 1-2 -10 When , substituting into the above formula, the second right shift is 8. That is, here the update step Convert to (Here y = 8). Through the conversion, the calculation accuracy remains unchanged, the calculation speed is improved, and the resource overhead required for the calculation is reduced. However, the selection of hyperparameters in the existing algorithm cannot achieve this optimization of converting multiplication to shift, and the calculation is slower and consumes more resources.
[0053] In an embodiment of the present invention, the update step calculation subsystem uses the inverse square root method and splits the division, decomposing the division operation into two multiplication operations, thereby avoiding the division operation that requires a large amount of computing resources and running time in the circuit. The prior art directly uses division, and the division calculation consumes a lot of computing resources and takes a lot of computing time in the FPGA and chip. The system improvement of the present invention greatly improves the speed.
[0054] Figure 5 Schematic diagram of a square root reciprocal calculation module in an embodiment of the present invention. In one embodiment, the square root reciprocal calculation module includes:
[0055] A square root reciprocal estimate calculation module 501 is used to perform type conversion processing on the square root of the second-order moment of this round to obtain a square root reciprocal estimate;
[0056] The Newton iterative calculation module 502 is used to perform Newton iterative calculation on the first estimate of the reciprocal square root to obtain the reciprocal square root.
[0057] Figure 6 Schematic diagram of a square root reciprocal calculation module in an embodiment of the present invention. In one embodiment, the square root reciprocal first estimation calculation module includes:
[0058] Fixed-point and floating-point converter 601 is used to convert the square root of the second-order moment vr t Convert from fixed-point number form to a 32-bit floating-point number in the preset standard form, recorded as the second-order moment square root floating-point number fvr t ;
[0059] The fourth shift register 602 is used to convert the second-order moment square root floating point number fvr t Shift right one position;
[0060] A second inverter 603, used for negating the output of the fourth shift register;
[0061] The third adder 604 converts the output of the second inverter into Add to the preset 32-bit number;
[0062] The floating point number and fixed point number converter 605 is used to convert the output sum of the third adder from a floating point number to a 32-bit fixed point number, and the result is recorded as the first inverse square root estimate isq1.
[0063] In one embodiment, the preset 32-bit number is 0x5f3759df;
[0064] The preset standard format is the IEEE 754 standard format.
[0065] Figure 7This is a schematic diagram of a Newton iterative calculation module in an embodiment of the present invention. In one embodiment, the Newton iterative calculation module includes:
[0066] The fifth shift register 701 is used to convert the square root of the second-order moment vr t Perform a right shift operation;
[0067] The third multiplier 702 is used to multiply the first estimate of the inverse square root isq1 by the output of the fifth shift register Perform multiplication calculations;
[0068] a fourth multiplier 703, configured to perform multiplication calculation on the first inverse square root estimate isq1 and the output of the third multiplier;
[0069] A third inverter 704, used to invert the output of the fourth multiplier;
[0070] A fourth adder 705, configured to perform addition calculation on the output of the third inverter and 1.5;
[0071] The fifth multiplier 706 is used to multiply the output of the fourth adder and the first estimate of the inverse square root to obtain the inverse square root isq2, which is
[0072] The square root reciprocal isq2 is expressed as isq2 = isq1 (1.5-0.5 vr t ·isq1·isq1), where 0.5·vr t The calculation is done by vr t Shift right one bit to achieve; finally calculate You can get
[0073] based on Figure 4-Figure 7 , Figure 8 This is a circuit implementation of the update step calculation subsystem in an embodiment of the present invention.
[0074] The embodiment of the present invention further proposes an Adam algorithm acceleration method, which is similar to the principle of the Adam algorithm acceleration system and will not be described in detail here.
[0075] Fig. 9 The flowchart of the Adam algorithm acceleration method in an embodiment of the present invention includes:
[0076] Step 901, calculate the first-order moment of this round according to the first-order moment of the previous round and the gradient of this round;
[0077] Step 902, calculating the square root of the second-order moment of this round according to the square root of the second-order moment of the previous round and the gradient of this round;
[0078] Step 903, a square root reciprocal calculation module is used to calculate the square root reciprocal according to the square root of the second-order moment of this round by using a fast square root reciprocal algorithm;
[0079] Step 904, multiply the first-order moment of this round by the inverse square root;
[0080] Step 905, multiplying the output of the first multiplier by the inverse square root to obtain the current round update step, which is used to train the neural network in hardware and update the network parameters.
[0081] In one embodiment, calculating the first-order moment of this round according to the first-order moment of the previous round and the gradient of this round includes:
[0082] According to a first right-shift number, the first-order moment of the previous round is right-shifted to obtain a first-order moment after right-shifting, wherein the first right-shift number is determined according to a first-order exponential attenuation factor;
[0083] According to the first right shift bit, right shift the current round of gradient to obtain the right-shifted gradient;
[0084] Negate the first-order moment after right shift to obtain the negated first-order moment;
[0085] Add the first-order moment of the previous round and the negated first-order moment to obtain the first sum;
[0086] Add the first sum and the right-shifted gradient to obtain the first-order moment of this round.
[0087] In one embodiment, the method further comprises:
[0088] Get the first parameter 1-β1 t 、Second parameter 1-β2 t , where β1 is the first-order exponential decay factor and β2 is the second-order exponential decay factor; the first parameter and the second parameter are approximated; the formula is used Determine the second right shift number, where y is the second right shift and lr is the learning rate;
[0089] According to the second right shift bit number, the output of the second multiplier is right shifted to obtain the scaled update step of this round;
[0090] Update the network parameters according to the first parameter, the second parameter, the update step of this round and the learning rate.
[0091] In one embodiment, the first-order exponential decay factor β1=1-2 -m , second-order exponential decay factor β2 = 1-2 -n , learning rate β1 = 2 -k , where m, n, and k are natural numbers greater than 0.
[0092] In one embodiment, calculating the inverse square root according to the square root of the second-order moment of this round includes:
[0093] Perform type conversion on the square root of the second-order moment of this round to obtain the penultimate estimate of the square root;
[0094] Perform Newton iteration on the first estimate of the reciprocal square root to obtain the reciprocal square root.
[0095] In one embodiment, performing type conversion processing on the square root of the second-order moment of this round to obtain the penultimate estimate of the square root includes:
[0096] Convert the square root of the second-order moment of this round from a fixed-point number to a 32-bit floating-point number in a preset standard form, and record it as the square root of the second-order moment floating-point number;
[0097] Shift the second-order moment square root floating point number right by one position;
[0098] Take the opposite of the output of the previous step;
[0099] Add the output of the previous step to the preset 32-bit number;
[0100] Convert the output of the previous step from floating point to 32-bit fixed point and record the result as the penultimate estimate of the square root.
[0101] In one embodiment, the preset 32-bit number is 0x5f3759df;
[0102] The preset standard format is the IEEE 754 standard format.
[0103] In one embodiment, performing Newton iteration calculation on the first estimate of the reciprocal square root to obtain the reciprocal square root includes:
[0104] Shift the square root of the second-order moment of this round right by one position;
[0105] Multiply the penultimate estimate of the square root by the output of the previous step;
[0106] Multiply the penultimate estimate of the square root by the output of the previous step;
[0107] Invert the output of the previous step;
[0108] The output of the previous step is added to 1.5;
[0109] The inverse square root is obtained by multiplying the output of the previous step by the first estimate of the inverse square root.
[0110] In summary, the system and method proposed in the embodiments of the present invention have the following beneficial effects:
[0111] First, when calculating the update step, there is no need to perform a division operation. Instead, you only need to use multiplication, addition, and shift operations to get the result of the division operation.
[0112] Second, the hyperparameters of the Adam algorithm, such as the learning rate, first-order exponential decay factor, and second-order exponential decay factor, are optimized to convert multiplication operations into fixed-point shift operations as much as possible. Compared with the existing hardware implementation of the Adam algorithm, the solution of the present invention effectively saves hardware resources, reduces power consumption, and greatly improves the throughput of the circuit.
[0113] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. An Adam algorithm acceleration system, It is characterized in that include: First-order moment estimation subsystem, second-order moment square root estimation subsystem and update step calculation subsystem, where: The first-order moment estimation subsystem is used to calculate the first-order moment of this round based on the first-order moment of the previous round and the gradient of this round; The second-order moment square root estimation subsystem is used to calculate the second-order moment square root of this round based on the second-order moment square root of the previous round and the gradient of this round; The update step calculation subsystem includes: A square root reciprocal calculation module is used to calculate the square root reciprocal according to the square root of the second-order moment of this round by using a fast square root reciprocal algorithm; A first multiplier, for multiplying the first-order moment of this round by the inverse square root; a second multiplier, used to multiply the output of the first multiplier by the inverse square root to obtain a current round of update steps, wherein the current round of update steps is used to train the neural network in hardware and update network parameters; It also includes a parameter updating module, the parameter updating module including: The hyperparameter processing module is used to calculate the first-order exponential decay factor β 1 and a second-order exponential decay factor β 2 , for the first parameter Second parameter Take an approximation; make an approximation on the first parameter and the second parameter; use the formula Determine the second right shift number, where y is the second right shift and lr is the learning rate; a third shift register, used for performing a right shift operation on the output of the second multiplier according to the second right shift bit number, to obtain a scaled current round update step; The network parameter updating module is used to update the network parameters according to the first parameter, the second parameter, the current round update step and the learning rate.
2. The system according to claim 1, It is characterized in that The first-order moment estimation subsystem includes: A first shift register, used for performing a right shift operation on the first-order moment of the previous round according to a first right shift number to obtain the first-order moment after right shift, wherein the first right shift number is determined according to a first-order exponential attenuation factor; The second shift register is used to right-shift the gradient of this round according to the first right-shift bit number to obtain the gradient after right-shift; A first inverter is used to invert the first-order moment after right shift to obtain an inverted first-order moment; A first adder, used for performing addition calculation on the first-order moment of the previous round and the inverted first-order moment to obtain a first sum; The second adder is used to perform addition calculation on the first sum and the right-shifted gradient to obtain the first-order moment of this round.
3. The system according to claim 1, It is characterized in that First-order exponential decay factor β 1 =1-2 -m , second-order exponential decay factor β 2 =1-2 -n , learning rate β 1 =2 -k , where m, n, and k are natural numbers greater than 0.
4. The system according to claim 1, It is characterized in that The square root reciprocal calculation module includes: A square root reciprocal estimation calculation module is used to perform type conversion processing on the square root of the second-order moment of this round to obtain a square root reciprocal estimation; The Newton iteration calculation module is used to perform Newton iteration calculation on the first estimate of the reciprocal square root to obtain the reciprocal square root.
5. The system according to claim 1, It is characterized in that The square root penultimate estimation calculation module includes: A fixed-point number and floating-point number converter is used to convert the square root of the second-order moment of this round from a fixed-point number to a 32-bit floating-point number in a preset standard form, recorded as a second-order moment square root floating-point number; A fourth shift register is used to shift the second-order moment square root floating point number right by one position; A second inverter, used for obtaining the inverse of the output of the fourth shift register; a third adder, used for adding the output of the second inverter to a preset 32-bit number; The floating point number and fixed point number converter is used for converting the output of the third adder from a floating point number to a 32-bit fixed point number, and the result is recorded as the reciprocal estimate of the square root.
6. The system according to claim 5, It is characterized in that The preset 32-bit number is 0x5f3759df; The preset standard format is the IEEE 754 standard format.
7. The system of claim 1, It is characterized in that Newton iteration calculation module includes: A fifth shift register, used for performing a right shift operation on the square root of the second-order moment of this round; a third multiplier, configured to multiply the first estimate of the reciprocal square root by the output of the fifth shift register; a fourth multiplier, configured to multiply the first estimate of the reciprocal square root by an output of the third multiplier; a third inverter, used for inverting the output of the fourth multiplier; a fourth adder, used for performing addition calculation on the output of the third inverter and 1.5; A fifth multiplier is used to multiply the output of the fourth adder by the first estimate of the inverse square root to obtain the inverse square root. 8.A method to accelerate the Adam algorithm. It is characterized in that include: Calculate the first-order moment of this round based on the first-order moment of the previous round and the gradient of this round; Calculate the square root of the second-order moment of this round based on the square root of the second-order moment of the previous round and the gradient of this round; A square root reciprocal calculation module is used to calculate the square root reciprocal according to the square root of the second-order moment of this round by using a fast square root reciprocal algorithm; Multiply the first moment of this round by the inverse square root to obtain the first product; The first product is multiplied by the inverse of the square root to obtain a current round of update steps, wherein the current round of update steps is used to train the neural network in hardware and update network parameters; Also includes: Get the first parameter Second parameter Among them, β 1 is the first-order exponential decay factor, β 2 is the second-order exponential decay factor; the first parameter and the second parameter are approximated; the formula is used Determine the second right shift number, where y is the second right shift and lr is the learning rate; According to the second right shift bit number, the output of the second multiplier is right shifted to obtain the scaled update step of this round; Update the network parameters according to the first parameter, the second parameter, the update step of this round and the learning rate.
