An FPGA-based A3C deep reinforcement learning algorithm accelerator
By designing a computationally parallel and pipelined A3C deep learning algorithm accelerator on the FPGA platform, the efficiency problem of the A3C algorithm on the hardware platform in the existing technology is solved, a distributed and asynchronous learning framework is implemented, and the execution speed and energy efficiency of the algorithm are improved. .
Patent Information
- Application Number
- CN202310730296.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-19
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-06-19
AI Technical Summary
It is difficult to efficiently implement the acceleration of A3C deep reinforcement learning algorithms on hardware platforms with existing technologies, especially in distributed asynchronous learning frameworks. Existing FPGA-based accelerators are mainly aimed at single-agent algorithms, and there are few studies on the acceleration of distributed DRL algorithms. .
Design an FPGA-based A3C deep reinforcement learning algorithm accelerator, adopt the acceleration strategy of computing parallelism and pipeline design, implement the distributed learning framework of the A3C algorithm through multi-module deployment, and update the parameters of the agent in the parameter update unit Control and implement the asynchronous learning framework of the A3C algorithm. The accelerator includes a storage module, forward calculation module, reverse calculation module, gradient calculation module and RMSProp parameter update module, using parallel computing units and multi-level storage space to improve computing efficiency.
It achieves fast access to weight data with minimal storage overhead, improves the execution speed and training efficiency of the A3C algorithm, has high energy efficiency compared to general-purpose processors, and the accelerator has high resource utilization and low power consumption.
Smart Images

Figure CN116739054B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep reinforcement learning of artificial intelligence, and in particular to an A3C deep reinforcement learning algorithm accelerator based on FPGA. Background Art
[0002] The A3C (Asynchronous Advantage Actor-Critic, A3C) algorithm is a typical deep reinforcement learning (DRL) algorithm. By adopting distributed learning and asynchronous training, it can effectively break the correlation of training data and improve the training efficiency and training results of the agent. The A3C algorithm constructs a central agent (Central Agent) as a distributed agent template, and copies the template N times to form N local agents (Local Agent), which are placed in N independent environments for interaction. Each agent can be regarded as an independent Actor-Critic (AC) agent. Under the distributed framework, each agent can interact with the environment according to the AC algorithm process without interfering with each other to obtain experience values and complete the calculation of the gradient value of the neural network parameters. Due to the introduction of the distributed asynchronous learning framework, the algorithm complexity and computational complexity of the A3C algorithm are relatively large. Therefore, how to implement the A3C algorithm with high performance and low power consumption on the existing hardware platform has certain research significance and practical value.
[0003] The hardware implementation platforms of the A3C algorithm are mainly divided into four types: general-purpose processors CPU, graphics processors GPU, application-specific integrated circuits ASIC, and field-programmable logic gate arrays FPGA. CPUs are limited by serial execution mode and limited data bandwidth, and cannot meet the requirements of A3C algorithm operations in terms of power consumption and latency. Therefore, the hardware acceleration of the A3C algorithm is generally based on GPU, ASIC, and FPGA platforms. Since the A3C algorithm uses small batches of samples for calculation during training, the utilization rate is low when using GPU to execute the algorithm's calculation tasks, making the A3C algorithm not easy to be accelerated by GPU. FPGA has the advantages of programmability, reconfigurability, high parallelism, and low power consumption. Compared with the fixed hardware structure of GPU and ASIC, FPGA can design hardware structures that adapt to various deep reinforcement learning algorithms. At the same time, compared with CPU and GPU, FPGA can obtain higher performance at unit power consumption, and has better energy efficiency and acceleration ratio. Most of the existing FPGA-based deep reinforcement learning algorithm accelerators are aimed at single-agent DRL algorithms represented by DQN (Deep Q Network, DQN), and there is little research on distributed DRL algorithm acceleration. Therefore, it is worthwhile to study the FPGA accelerator for distributed deep reinforcement learning algorithms, improve the execution speed of the algorithm and shorten its training cycle while realizing its distributed asynchronous learning framework. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide an FPGA-based A3C deep reinforcement learning algorithm accelerator, which adopts an acceleration strategy of computational parallelism and pipeline design, and implements all computational steps of the A3C deep reinforcement learning agent through multi-module deployment; divides the storage area into multiple independent spaces, and deploys multiple PEs in the computing unit to implement the distributed learning framework of the A3C algorithm; and controls the parameter update sequence of the agent in the parameter update unit to implement the asynchronous learning framework of the A3C algorithm.
[0005] The present invention adopts the following technical solutions to solve the above technical problems:
[0006] According to the present invention, an FPGA-based A3C deep reinforcement learning algorithm accelerator includes a host computer for providing an interactive environment and an FPGA accelerator for computing acceleration. The FPGA accelerator includes a storage module, a forward computing module, a reverse computing module, a reverse input computing module, a gradient computing module, and an RMSProp parameter updating module.
[0007] The forward calculation module includes N parallel calculation FPE modules, and the FPE module includes a first matrix calculation unit, a ReLU activation unit, and a Softmax activation unit; wherein,
[0008] When computing shared layers:
[0009] A first matrix calculation unit is used to read the input feature map x and the network parameter θ from the storage module, perform a matrix multiplication operation on x and the network parameter θ, and then output the operation result A to the ReLU activation unit and the storage module;
[0010] A ReLU activation unit, used for performing an activation operation on the operation result A output by the first matrix calculation unit and then outputting a feature map y to a storage module cache;
[0011] When calculating the output layer:
[0012] The first matrix calculation unit is used to read y and the network parameter θ from the storage module, perform linear multiplication and summation on y and the network parameter θ, and obtain a Critic network output value v to output to the storage module;
[0013] The Softmax activation unit is used to process the calculation results of the shared layer read in parallel, the calculation results of the shared layer refer to y, obtain a set of Actor network output values π and output them to the storage module;
[0014] The reverse input calculation module is used to calculate the reverse input feature map x' and output it to the storage module according to the calculation results of the A3C agent network output layer in the storage module. The calculation results of the A3C agent network output layer are the Actor network output value π and the Critic network output value v. x' includes the Actor network reverse input map y' π And the reverse input graph y' of the Critic network v ;
[0015] The reverse computing module includes N parallel computing BPE modules, where:
[0016] The BPE module is used to process the forward input node data X, the reverse input feature map x' and the network parameter θ to obtain the reverse output feature map y' and output it to the storage module; wherein the forward input node data X refers to the operation result A output by the first matrix calculation unit without the Relu activation operation;
[0017] The gradient calculation module includes N parallel computing GPE modules, among which,
[0018] The GPE module reads the forward input node data X and the reverse input node data X' from the storage module, where X' refers to the reverse input feature map x' or the reverse output feature map y'. The GPE module processes X and X' and outputs a set of network parameter gradient values dθ to the RMSProp parameter update module and the storage module.
[0019] The RMSProp parameter update module includes a gradient aggregation unit and a parameter update unit, where:
[0020] A gradient aggregation unit, used to aggregate and calculate dθ according to the historical gradient values read from the storage module, and output the aggregated gradient values to the parameter updating unit;
[0021] The parameter updating unit is used to update the historical network parameters read from the storage module according to the aggregated gradient value, obtain new network parameters and output them to the storage module.
[0022] As a further optimization scheme of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the first matrix calculation unit includes a multiplier and an adder, the ReLU activation unit includes a 0 value comparator, and the Softmax activation unit includes an exponential operator, a divider and an adder.
[0023] As a further optimization solution of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the calculation process of the forward calculation module is as follows:
[0024] When calculating the shared layer, the first matrix calculation unit and the ReLU calculation unit are used. At this time, the calculation process of the forward calculation module includes the following steps:
[0025] Step 11: read the input feature map x and the network parameter θ from the storage module to the first matrix calculation unit;
[0026] Step 12: Send the input feature map x and network parameter θ into the multiplication-addition tree structure of the first matrix calculation unit. x and θ will be added to the bias after multiplication and summation.
[0027] Step 13, the output result of the first matrix calculation unit is sent to the ReLU activation unit as input data, and the input data is compared with 0. When the input data is less than 0, the output is 0; when the input data is greater than or equal to 0, the data is output and the size of the input data is kept unchanged, and the output data is cached in the storage module. After a preset clock cycle, all output calculations are completed;
[0028] When calculating the output layer, the first matrix calculation unit and the Softmax activation unit are used. At this time, the calculation process of the forward calculation module includes the following steps:
[0029] Step 21, read y and network parameter θ from the storage module to the first matrix calculation unit, and read y to the Softmax activation unit;
[0030] Step 22, the multiplication-addition tree structure of the first matrix calculation unit completes the linear multiplication and summation of y and the network parameter θ by multiplication and addition, and obtains a Critic network output value v;
[0031] Step 23, the Softmax activation unit uses the calculation results of the shared layer read in parallel as input data, converts the input data into a serial arrangement, and obtains a serial sequence. The calculation result of the shared layer refers to y;
[0032] Step 24: Send the serial sequence obtained in step 23 to the exponential operator to obtain the exponential output, and then calculate a set of Actor network outputs π through the accumulator and the divider.
[0033] As a further optimization solution of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the reverse input calculation module includes a multiplier, an adder and a selector; the calculation process of the reverse input calculation module includes the following steps:
[0034] When calculating the reverse input graph of the Actor network, the calculation process of the reverse input calculation module includes the following steps:
[0035] Step 31: Read the output result π of the l Actor network layer from the storage module to the reverse input calculation module, where π is recorded as z1~z l , z i is the output result of the i-th Actor network layer, z j is the output result of the j-th Actor network layer, 1≤i≤l, 1≤j≤l;
[0036] Step 32: Use floating point numbers to calculate IP check z1~z l After negation, logarithm, multiplication and addition, we get 1-lnz i 、-z i z j With z i (1-z i )result;
[0037] Step 33: 1-lnz obtained in step 32 i 、-z i z j With z i (1-z i) The result is sent to the multiplication-addition tree structure, and the calculation result output by the multiplication-addition tree structure is multiplied by the hyperparameter c and the time error δ, and then the sum is obtained to obtain the reverse input graph y' of the Actor network π ;
[0038] When calculating the reverse input graph of the Critic network, the calculation process of the reverse input calculation module includes the following steps:
[0039] Step 41: Read the first to third network parameters θ of the Critic network layer from the storage module w1 ~θ w3 to the reverse input calculation module.
[0040] Step 42: Use the floating point calculation IP core to invert and double the time error δ and then send it to the multiplier to multiply it with the network parameter matrix to obtain the reverse input graph y' of the Critic network. v .
[0041] As a further optimization scheme of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the BPE module includes a positive and negative cache unit, a weight input control unit and a second matrix calculation unit, wherein the positive and negative cache unit includes a selector and a register to record the positive and negative of the forward input node data; the weight input control unit includes a selector to complete the derivation operation of the ReLU activation function according to the positive and negative of the forward input node data; the second matrix calculation unit includes a multiplier and an adder, and the second matrix calculation unit is used to complete the matrix multiplication operation between the reverse input feature map x' and the output of the weight input control unit, and output the reverse output feature map y' to the storage module.
[0042] As a further optimization solution of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the calculation process of the reverse calculation module includes the following steps:
[0043] Step 51, read the network parameter θ, the forward input node data X and the reverse input feature map x' from the storage module to the reverse calculation module, and use the positive and negative cache units to record the positive and negative of the forward input node data of this layer; the forward input node data X refers to the output result A of the first matrix calculation unit without the Relu activation operation;
[0044] Step 52, the weight input control unit uses the positive and negative values stored in the positive and negative buffer units in step 51 to complete the derivation operation of the Relu function. When the positive and negative values are 0, the weight input is 0; when the positive and negative values are 1, the weight input is the network parameter read in step 51;
[0045] Step 53: Send the output of the weighted input control unit and the reverse input feature map x' to the multiplication-accumulation structure of the second matrix calculation unit, and complete the calculation of the reverse output feature map y' after a certain clock cycle.
[0046] As a further optimization scheme of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, each GPE module includes a positive and negative cache unit, an input control unit and n parallel multipliers; the positive and negative cache unit includes a selector and a register, the input of the positive and negative cache unit is the positive input node data X, and the positive and negative cache unit is used to record the positive and negative of the positive input node data; the input control unit includes a selector, the input of the input control unit is 0 and the positive input node data X, and is used to complete the derivation operation of the ReLU activation function according to the positive and negative of the forward calculation result; n parallel multipliers are used to complete the reverse input node data X', X' refers to the multiplication operation between the reverse input feature map x' or the reverse output feature map y' and the output of the input control unit, and output a set of network parameter gradient values dθ to the RMSProp parameter update module;
[0047] The calculation process of the gradient calculation module is as follows:
[0048] Step 61, read the forward input node data X and the reverse input node data X' into the gradient calculation module;
[0049] Step 62: Use the positive and negative buffer units and the input control unit to control the multiplication of the reverse input node data X' and the forward input node data X to obtain the gradient calculation result. After a certain clock cycle, the calculation of all gradient values can be completed.
[0050] As a further optimization scheme of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the RMSProp parameter update module includes a gradient aggregation unit and a parameter update unit; the gradient aggregation unit includes a plurality of adder arrays with a parallelism of N, and the input of the gradient aggregation unit is the network parameter gradient value dθ transmitted from the gradient calculation module, which is used to complete the gradient aggregation calculation of each GPE module in the gradient calculation module, and after the calculation is completed, the aggregated gradient value is output to the parameter update unit; the parameter update unit includes a multiplier, an adder and a register, and the parameter update unit reads the historical network parameters from the storage module, and uses the calculation results of the gradient aggregation unit to perform parameter update calculation, and then outputs the new network parameters to the storage module.
[0051] As a further optimization solution of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the calculation process of the RMSProp parameter update module is as follows:
[0052] Step 71, read the gradient value dθ from the gradient calculation module, and read the historical gradient dθ' from the storage module into the gradient aggregation unit;
[0053] Step 72: sum the read gradient values, and then send the calculation result to the storage module. After a certain clock cycle, the gradient aggregation calculation is completed.
[0054] Step 73, when the gradient aggregation calculation is completed, the control signal is read and transmitted to the first-in-first-out memory FIFO. When the parameter update unit is idle, the selector reads out the control signal of the FIFO read port, and simultaneously accesses the central agent parameter memory and the gradient value buffer of the agent corresponding to the control signal, performs gradient update calculation, and transmits the updated network parameter value to the storage module.
[0055] As a further optimization scheme of the FPGA-based A3C deep reinforcement learning algorithm accelerator described in the present invention, the storage module includes an on-chip BRAM, the on-chip BRAM includes an agent data storage unit and a reverse calculation module cache unit, the agent data storage unit includes a central agent cache and N local agent caches, and the central agent cache is used to store the central network parameter θ c , and the storage of each local agent is divided into parameter θ cache, parameter g cache, gradient value cache and forward calculation cache; among them, the parameter θ cache is used to store the local agent deep neural network parameter θ; the parameter g cache stores the RMPProp parameter g maintained by the local agent; the gradient value cache is used to store the gradient value calculation results of the local agent; the forward calculation cache is used to store the input and output of each layer of the deep neural network of the local agent during the reasoning calculation process; the reverse calculation module cache unit allocates an intermediate result cache area for each BPE, which is used to store the intermediate calculation results generated by the deep neural network propagation in the reverse calculation.
[0056] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0057] (1) The present invention proposes an A3C deep reinforcement learning algorithm FPGA accelerator architecture, which implements the distributed framework of the A3C algorithm by deploying independent storage and computing modules, and implements the asynchronous framework of the A3C algorithm by designing a control module for the parameter update calculation process.
[0058] (2) The present invention proposes a heterogeneous computing structure deployment method, which can achieve access to weight data in the shortest clock cycle with minimal storage overhead, and has higher weight storage access efficiency.
[0059] (3) The accelerator of the present invention has the characteristic of high energy efficiency compared with general-purpose processors. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is the A3C agent network structure diagram.
[0061] Figure 2 This is the hardware architecture diagram of the FPGA-based A3C deep reinforcement learning algorithm accelerator.
[0062] Figure 3 It is a storage module structure diagram.
[0063] Figure 4 It is a schematic diagram of the interaction between the accelerator and the environment.
[0064] Figure 5 This is the structure diagram of the forward computing module FPE.
[0065] Figure 6 This is the structure diagram of the reverse input calculation module.
[0066] Figure 7 This is the BPE structure diagram of the reverse computing module.
[0067] Figure 8 This is the structure diagram of the gradient calculation module GPE.
[0068] Fig. 9 This is the structure diagram of the RMSProp parameter update module.
[0069] Fig.10 This is a schematic diagram of gradient polymerization flow control. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0071] like Figure 1 The A3C agent network consists of a shared layer, an Actor output layer, and a Critic output layer. The Actor network uses the Softmax function as the output layer activation function to obtain the policy output π(s; θ1), and the Critic network uses a linear layer to obtain a value output v(s; θ2). In terms of the activation function of the shared layer, the ReLu function is usually used as the activation function.
[0072] like Figure 2, the FPGA-based A3C deep reinforcement learning algorithm accelerator described in this embodiment includes: a forward calculation module, a reverse calculation module, a reverse input calculation module, a gradient calculation module, an RMSProp parameter update module and a storage module. Among them, the host computer is used to provide an interactive environment; the FPGA accelerator is used to complete the calculation acceleration of the agent reasoning and training, including: a storage module for storing the input, output, network parameters and intermediate results of all modules; a forward calculation module for completing the forward reasoning calculation of the neural network; a reverse input calculation module for completing the calculation of the reverse input graph; a reverse calculation module for completing the back propagation calculation of the neural network; a gradient calculation module for calculating the gradient of each layer of network parameters; and an RMSProp parameter update module for completing the RMSProp parameter update process in the A3C algorithm.
[0073] The forward computing module includes N parallel computing FPE modules (Forward PE, FPE), each FPE module includes a first matrix calculation unit, a ReLU activation unit and a Softmax activation unit; the first matrix calculation unit is composed of a multiplier and an adder, and its input is the input feature map x and the network parameter θ read from the storage module, which is used to complete the matrix multiplication operation of the two in the shared fully connected layer or the output layer. When calculating the shared fully connected layer: the first matrix calculation unit is used to perform a matrix multiplication operation on the input feature map x and the network parameter θ, and output the operation result A to the ReLU activation unit; when calculating the output layer: the first matrix calculation unit is used to sum the linear multiplication of the input feature map x and the network parameter θ, and obtain a Critic network output value v to output to the storage module; the ReLU activation unit is composed of a 0-value comparator, which is used to activate the operation result output by the first matrix calculation unit and then output the feature map y to the storage module cache; the Softmax activation unit is composed of a divider, an exponential operator and an accumulator, which is used to process the output of the last shared fully connected layer when calculating the Actor network layer and output a set of Actor network output values π to the storage module;
[0074] The reverse input calculation module consists of a multiplier, an adder, and a selector. Its input is the calculation result of the A3C agent network output layer read from the storage module, that is, the Actor network output value π and the Critic network output value v, which is used to complete the calculation of the reverse input graph of the output layer, that is, the gradient of the loss function to the network output layer. This module has two calculation modes, where mode one is used to complete the calculation of the Actor network reverse input graph, and mode two is used to complete the calculation of the Critic network reverse input graph. After the calculation is completed, the reverse input feature map x' is output to the storage module;
[0075] The reverse calculation module includes N parallel computing BPE modules (Backward PE, BPE), each BPE module includes a positive and negative cache unit, a weight input control unit and a second matrix calculation unit, which are used to complete the calculation of the reverse output graph of the shared fully connected layer; the positive and negative cache unit is composed of a selector and a register, and its input is the forward input node data X (the forward input node data X refers to the output result A of the first matrix calculation unit without the Relu activation operation), which is used to record the positive and negative of the forward input node data; the weight input control unit is composed of a selector, which is used to complete the derivative operation of the ReLU activation function according to the positive and negative of the forward input node data; the second matrix calculation unit is composed of a multiplier and an adder, which is used to complete the matrix multiplication operation of the reverse input feature map x' and the output of the weight input control unit;
[0076] The gradient calculation module includes N parallel computing GPE modules (Gradient PE, GPE), each GPE module includes a positive and negative cache unit, an input control unit and n parallel multipliers; the positive and negative cache unit is composed of a selector and a register, and its input is the network layer forward input node data X (the forward input node data X refers to the output result A of the first matrix calculation unit without the Relu activation operation), which is used to record the positive and negative of the forward input node data; the input control unit is composed of a selector, and the input of the input control unit is 0 and the forward input node data X, which is used to complete the derivative operation of the ReLU activation function according to the positive and negative of the forward calculation result; n parallel multipliers are used to complete the multiplication operation between the reverse input node data X' (the reverse input node data X' refers to the reverse input feature map x' or the reverse output feature map y') and the output of the input control unit, and output a set of network parameter gradient values dθ to the RMSProp parameter update module;
[0077] The RMSProp parameter update module includes a gradient aggregation unit and a parameter update unit; the gradient aggregation unit is composed of multiple adder arrays with a parallel degree of N, and its input is the network parameter gradient value dθ transmitted from the gradient calculation module and the historical gradient value dθ' read from the storage module, which is used to complete the gradient aggregation calculation of each GPE in the gradient calculation module; the parameter update unit is composed of a multiplier, an adder and a register, which reads the historical network parameters from the storage module, and uses the calculation results of the gradient aggregation unit to perform parameter update calculations, and then outputs the new network parameters to the storage module.
[0078] like Figure 3 The storage module includes an on-chip BRAM, which includes an agent data storage unit and a reverse calculation module cache unit. The agent data storage unit includes a central agent cache and N local agent caches. The central agent cache is used to store the central network parameters θ c, and the storage of each local agent can be divided into parameter θ cache, parameter g cache, gradient value cache and forward calculation cache. The parameter θ cache is used to store the local agent deep neural network parameter θ; the parameter g cache stores the RMPProp parameter g maintained by the local agent; the gradient value cache is used to store the gradient value calculation results of the local agent; the forward calculation cache is used to store the input and output of each layer of the deep neural network of the local agent during the reasoning calculation process. The reverse calculation module cache unit allocates an intermediate result cache area for each BPE to store the intermediate calculation results generated by the deep neural network propagation in the reverse calculation.
[0079] The operation mode of this embodiment is as follows: Figure 4 , the environmental state value s at time t in any environment t It will be extracted by the host computer program and transmitted to the storage module of the FPGA accelerator through the UDP protocol, and then the forward computing module will input s t Mapping to strategy output π(s t ;θ) and value output v(s t ; θ), and feeds back the policy output to the environment corresponding to the thread to complete the interaction. When t reaches the inference upper limit step T max , the reverse input calculation module will read the forward calculation results from the storage module, calculate the reverse calculation input graphs of the Actor network and the Critic network respectively, and then the reverse calculation module will calculate the reverse input from the output layer to the input layer layer by layer. At the same time, when the reverse calculation is transmitted to each layer, the gradient calculation module obtains the gradient value dθ of the layer parameter. In addition, when the reverse calculation module is running, it will use the derivative results of the activation function of each layer of the neural network as control information and share it with the gradient calculation module for input control. When all gradient calculations are completed, the RMSProp parameter update module completes the parameter update calculation of the central agent. Finally, by repeating the above reasoning training process until the cumulative rewards that the agents in the N environments can obtain rise to the maximum and tend to be stable, the training of the A3C deep reinforcement learning agent is completed.
[0080] During parameter update calculation, in order to meet the asynchronous parameter update mode of the A3C algorithm, this embodiment records the order in which all agents complete the gradient calculation in the RMSPorp parameter update module, and controls each agent in the RMSProp parameter update module to complete the parameter update calculation with the central agent network parameters in this order, so as to prevent errors caused by the local agent accessing and updating the central agent network parameters at the same time. The updated parameters will not only overwrite the original central network parameters, but also be copied to the corresponding local agent network parameter storage in the storage module for update, so as to carry out subsequent interaction.
[0081] In this embodiment, the A3C agent deep neural network includes 4 shared fully connected layers, one Actor output layer and one Critic output layer. The specific network model parameters are shown in Table 1.
[0082] Table 1 A3C agent deep neural network structure
[0083]
[0084] In the A3C agent deep neural network model in this embodiment, the first layer of full connection is the output of 128 nodes, the second layer of full connection is the output of 256 nodes, the third layer of full connection is the output of 64 nodes, and the fourth layer of full connection is the output of 4 nodes. The activation function of the four shared fully connected layers is the Relu function; the input of the Actor output layer is the output of the shared fully connected layer 4, and the Softmax activation function is used to output the probability; the output node of the Critic output layer is 1, and there is no activation function.
[0085] The forward computing module consists of N parallel computing FPE modules, such as Figure 5 As shown, each FPE module includes a first matrix calculation unit, a ReLU activation unit and a Softmax activation unit, which mainly complete the multiplication and accumulation operation of the input feature map and the network parameters, the ReLU activation calculation, the Softmax output calculation of the Actor network and the linear output calculation of the Critic network. In the above FPE structure, the first matrix calculation unit can realize the simultaneous calculation of multiple input nodes through parallel multiplication and addition calculations, thereby improving the parallelism of the forward propagation calculation of the neural network and shortening the calculation cycle. In terms of control, in order to reduce the calculation waiting time of each output node, after all the data input of the first output node is completed, the parameters and input node data required for the calculation of the second output node can be read in the next clock cycle immediately to realize the pipeline control of the calculation between the output nodes and improve the calculation efficiency. Since the Softmax activation unit only works when the output layer is calculated, the enable signal is used to turn off the module when the neural network shared layer is calculated to reduce power consumption. In terms of the control of the forward calculation module, the control between each FPE is independent of each other and does not interfere with each other, ensuring that different local agents can perform reasoning calculations at the same time to realize the A3C distributed reasoning framework.
[0086] When calculating the shared layer, the first matrix calculation unit and the ReLU calculation unit are needed. When the number of input nodes is m and the number of output nodes is l, the first matrix calculation unit needs to read n input node data x1~x1 in each clock cycle. n, after [m / n] clock cycles, all input node data are read in. These data will be multiplied and summed with the network parameters and then added to the bias, and then sent to the ReLU activation unit. The activation result y1 is obtained by comparing it with 0. After y1 is obtained, the input node data x1~x1 can be used in the subsequent [m / n] clock cycles. m Re-read and calculate y2. Repeat the above calculation operation l times to complete the calculation of all output nodes. When the number of input nodes m is greater than the multiplier parallelism n, the partial sum of the first n weights and the input graph can be calculated first, and the partial sum and subsequent partial sum results can be accumulated until all input nodes are calculated. The result is then added to the bias, and the calculation result of an output node y1 is obtained after the activation function is calculated.
[0087] When calculating the output layer, the Softmax activation unit and the first matrix calculation unit are needed to complete the network output value calculation at the same time. When the network output layer calculation starts, the input feature map data will be read into the first matrix calculation unit and the Softmax activation unit at the same time. Among them, the first matrix calculation unit completes the linear multiplication and summation of the input feature map of the Critic network and the network parameter value by multiplication and addition, and obtains an output value v; while the Softmax activation unit converts the input node data read in parallel into a serial arrangement, obtains the exponential output through the exponential operator, and then calculates a set of Actor network outputs π through the accumulator and divider. The output value will be transmitted back to the host computer as the basis for action selection to interact with the environment.
[0088] The calculation process of the forward calculation module includes the following steps:
[0089] When calculating the shared layer, the first matrix calculation unit and the ReLU calculation unit need to be used. At this time, the calculation process of the forward calculation module includes the following steps:
[0090] Step 11: read the input feature map x and the network parameter θ from the storage module to the first matrix calculation unit;
[0091] Step 12: Send the input feature map x and network parameter θ into the multiplication-addition tree structure of the first matrix calculation unit. x and θ will be added to the bias after multiplication and summation.
[0092] Step 13, the output result of the first matrix calculation unit is sent to the ReLU activation unit as input data, and the input data is compared with 0. When the input data is less than 0, the output is 0; when the input data is greater than or equal to 0, the data is output and the size of the input data is kept unchanged, and the output data is cached in the storage module. After a preset clock cycle, all output calculations are completed;
[0093] When calculating the output layer, the first matrix calculation unit and the Softmax activation unit are needed. At this time, the calculation process of the forward calculation module includes the following steps:
[0094] Step 21, read y and network parameter θ from the storage module to the first matrix calculation unit, and read y to the Softmax activation unit;
[0095] Step 22, the multiplication-addition tree structure of the first matrix calculation unit completes the linear multiplication and summation of y and the network parameter θ by multiplication and addition, and obtains a Critic network output value v;
[0096] Step 23, the Softmax activation unit uses the calculation results of the shared layer read in parallel as input data, converts the input data into a serial arrangement, and obtains a serial sequence. The calculation result of the shared layer refers to y;
[0097] Step 24: Send the serial sequence obtained in step 23 to the exponential operator to obtain the exponential output, and then calculate a set of Actor network outputs π through the accumulator and the divider.
[0098]
[0099] The reverse input calculation module consists of a multiplier, an adder, and a selector, such as Figure 6 As shown in Figure 1, the reverse input calculation module has two calculation modes, which are used to calculate the reverse input feature map of the Actor network and the Critic network respectively. In mode 1, the calculation result of the Softmax layer is Z = (z1, z2, ..., z i ,…,z l ), which is read continuously from the storage module, and 1-lnz, -z are calculated simultaneously i z j With z i (1-z i ) result, and then use the multiplication-addition tree structure to calculate the matrix multiplication in Formula 1. Finally, the first matrix multiplication result of Formula 1 and the second calculation result are multiplied by c and δ respectively, and then summed to obtain the reverse input graph of the Actor network. In mode two, it is only necessary to read in the inverse of mode one δ, expand it by two times, and then multiply it with the weight matrix to obtain the reverse input graph of the Critic network. In order to save computing resources, this embodiment reuses some multipliers of mode one in subsequent calculations and mode two, respectively, to reduce computing resource overhead and improve resource utilization.
[0100] The calculation process of the reverse input calculation module includes the following steps:
[0101] When calculating the reverse input graph of the Actor network, the calculation process of the reverse input calculation module includes the following steps:
[0102] Step 31: Read the output result π of the l Actor network layer from the storage module to the reverse input calculation module, where π is recorded as z1~z l , z i is the output result of the i-th Actor network layer, z j is the output result of the j-th Actor network layer, 1≤i≤l, 1≤j≤l;
[0103] Step 32: Use floating point numbers to calculate IP check z1~z l After negation, logarithm, multiplication and addition, we get 1-lnz i 、-z i z j With z i (1-z i )result;
[0104] Step 33: 1-lnz obtained in step 32 i 、-z i z j With z i (1-z i ) The result is sent to the multiplication-addition tree structure, and the calculation result output by the multiplication-addition tree structure is multiplied by the hyperparameter c and the time error δ, and then the sum is obtained to obtain the reverse input graph y' of the Actor network π ;
[0105] When calculating the reverse input graph of the Critic network, the calculation process of the reverse input calculation module includes the following steps:
[0106] Step 41: Read the first to third network parameters θ of the Critic network layer from the storage module w1 ~θ w3 to the reverse input calculation module.
[0107] Step 42: Use the floating point calculation IP core to invert and double the time error δ and then send it to the multiplier to multiply it with the network parameter matrix to obtain the reverse input graph y' of the Critic network. v .
[0108] The reverse computing module consists of N parallel computing BPEs, such as Figure 7As shown, each BPE includes a positive and negative cache unit, a weight input control unit and a second matrix calculation unit, which are mainly used to complete the activation function derivation operation and the matrix multiplication operation of the input feature map, the activation function derivative and the weight parameter. In the above BPE structure, the second matrix calculation unit can realize the simultaneous calculation of multiple output nodes through parallel multiplication and accumulation calculations, thereby improving the parallelism of the neural network back propagation calculation and shortening the calculation cycle. In terms of control, in order to calculate the read waiting time of each input node, after all the data inputs of the first n output nodes are calculated, the parameters and input node data required for the calculation of the subsequent n output nodes can be read in immediately in the next clock cycle to realize the pipeline control of the calculation between the output nodes and improve the calculation efficiency. In terms of the control of the reverse calculation unit, the control between each BPE is independent of each other and does not interfere with each other, ensuring that different local agents can perform reverse calculations at the same time to realize the A3C distributed training framework.
[0109] When calculating the derivative of the Relu activation function, the forward calculation result will be read from the storage module to participate in the gradient calculation. When the gradient calculation module is calculating the weight gradient of the L+1 layer, the output data of the L layer will be read from the storage module. At this time, the positive and negative cache units will record the positive and negative output of the L layer, which will be used for the reverse calculation module to calculate the activation function derivative module control of the L layer. When the reverse calculation starts, the network parameters will be read from the storage module, first input to the activation function derivative module, and according to the control signal given by the positive and negative cache units, if the positive and negative control signals are 1, the network parameters will be directly transmitted to the multiplier-accumulator for calculation. If the positive and negative control signals are 0, the weights will be reset to 0 and then transmitted to the multiplier-adder for calculation.
[0110] When calculating the matrix multiplication of the reverse input feature graph and the network parameters, the second matrix calculation unit is used for calculation. When the number of input nodes is l and the number of output nodes is m, the reverse calculation module multiplies the reverse input graph data x'1 with the data θ in the weight storage address a in the first clock cycle. w1 ~θ wn Read in, and in the second clock cycle, the reverse input graph data x'2 and the data θ in the weight storage address a+[m / n] are combined. w1+m ~θ wn+m Read in and multiply, and accumulate with the result of the first cycle until the weight data of address a+l×[m / n] is read out, and the reverse calculation results y'1~y' of the first n items can be obtained. n At this point, initialize the weight address to a+1, and repeat the above calculation to complete the calculation of all outputs in the reverse calculation.
[0111] The calculation process of the reverse calculation module includes the following steps:
[0112] Step 51, read the network parameters θ, the forward input node data X (the forward input node data X refers to the output result A of the first matrix calculation unit without the Relu activation operation) and the reverse input feature map x' from the storage module to the reverse calculation module, and use the positive and negative cache units to record the positive and negative of the forward input node data of this layer;
[0113] Step 52, the weight input control unit uses the positive and negative values stored in the positive and negative buffer units in step 51 to complete the derivation operation of the Relu function. When the positive and negative values are 0, the weight input is 0; when the positive and negative values are 1, the weight input is the network parameter read in step 51;
[0114] Step 53: Send the output of the weighted input control unit and the reverse input feature map x' to the multiplication-accumulation structure of the second matrix calculation unit, and complete the calculation of the reverse output feature map y' after a certain clock cycle.
[0115] The gradient calculation module consists of N parallel computing GPE modules, such as Figure 8 As shown, each GPE module includes a positive and negative cache unit, an input control unit and n parallel multipliers, which are mainly used to calculate the gradient value Δθ of each layer parameter. The above GPE structure can realize the parallel calculation of multiple parameter gradient values, improve the speed of back propagation calculation, and at the same time, continuously input the data required for calculation in each clock cycle, realize the pipeline control of the gradient calculation unit, and avoid data waiting time.
[0116] When calculating the gradient of each layer, the forward input node data X1~Xn are read in at the same time in the first clock cycle, and multiplied with the first reverse input node data X1' to obtain Δθ1~Δθ n There are n gradient results in total. In the second clock cycle, X1' can be kept unchanged and X n+1 ~X 2n By reading it, we can get the subsequent n parameter gradient values Δθ n+1 ~Δθ 2n When all m input nodes are read and calculated, the second reverse input node data X2' and X1~X n Perform multiplication calculation and repeat the above process until all gradient values of the neural network parameters of this layer are calculated.
[0117] The calculation process of the gradient calculation module includes the following steps:
[0118] Step 61, read the forward input node data X (the forward input node data X refers to the output result A of the first matrix calculation unit without the Relu activation operation) and the reverse input node data X' (the reverse input node data X' refers to the reverse input feature map x' or the reverse output feature map y') into the gradient calculation module;
[0119] Step 62, using the positive and negative buffer units and the input control unit to control the multiplication of the reverse input node data X' and the forward input node data X to obtain the gradient calculation result. After a certain clock cycle, the calculation of all gradient values can be completed.
[0120] The RMSProp parameter update module consists of a gradient aggregation unit and a parameter update unit, such as Fig. 9 As shown, it is mainly used to complete the asynchronous update of the parameters of the central agent neural network. In terms of the data flow control of the gradient aggregation unit in the above PE structure, in order to reduce the waiting time of the gradient aggregation calculation, this embodiment designs a multi-level pipeline to achieve the continuity of the gradient aggregation calculation, such as Fig.10 As shown in the figure, by accessing and reading the historical gradient value in each clock cycle, the calculation speed of gradient aggregation is improved. In terms of parameter update, the parameter update unit realizes continuous update of parameter values through 7-level pipeline control, reducing the data waiting cycle.
[0121] When calculating gradient aggregation, the gradient value dθ will be passed from the gradient calculation module to the gradient aggregation unit. At this time, the gradient aggregation unit will read the historical gradient dθ' value of the agent from the storage module, and send the result back to the storage module after summation calculation. Repeat the above calculation process and repeatedly read the updated dθ' value until 2(T max -1) The sum of the group parameter gradient values can complete the gradient aggregation calculation of the agent.
[0122] When calculating parameter updates, when any agent completes the gradient aggregation calculation, the corresponding agent number i will be passed into the FIFO as a control signal. When the parameter update unit is idle, the selector will read the agent number i from the FIFO read port and simultaneously access the central agent parameter memory and the gradient value buffer of the agent corresponding to number i to perform gradient update calculations.
[0123] The calculation process of the RMSProp parameter update module includes the following steps:
[0124] Step 71, read the gradient value dθ from the gradient calculation module, and read the historical gradient dθ' from the storage module into the gradient aggregation unit;
[0125] Step 72: sum the read gradient values, and then send the calculation result to the storage module. After a certain clock cycle, the gradient aggregation calculation is completed.
[0126] Step 73, when the gradient aggregation calculation is completed, the control signal is read and transmitted to the first-in-first-out memory FIFO. When the parameter update unit is idle, the selector reads out the control signal of the FIFO read port, and simultaneously accesses the central agent parameter memory and the gradient value buffer of the agent corresponding to the control signal, performs gradient update calculation, and transmits the updated network parameter value to the storage module.
[0127] In the design of FPGA hardware accelerator, the present invention uses single-precision floating point numbers for calculation, mainly because the back propagation process of the neural network has very high requirements for calculation accuracy, and the use of single-precision floating point numbers can ensure the accuracy of each calculation process. The present invention measures the signal-to-noise ratio of the calculation results of the reasoning and training of the designed deep reinforcement learning accelerator to measure the calculation error of the software and hardware results and to verify the correctness of the reasoning calculation and training calculation results. The results are shown in Table 2. It can be seen that the signal-to-noise ratio of all calculations is higher than 130dB, which shows that the error of the software and hardware calculation results is very small.
[0128] Table 2 Average signal-to-noise ratio of software and hardware
[0129]
[0130] The following is combined with specific experimental results to illustrate that the FPGA accelerator proposed in the present invention has the advantage of high energy efficiency compared to general-purpose processors. The performance evaluation indicators of the deep reinforcement learning algorithm accelerator mainly include exploration times per second (IPS), power consumption (W), exploration times per watt (IPW), and acceleration ratio. Table 3 compares the performance of the A3C algorithm implemented on FPGA with the results of running on CPU and GPU (where the running data under CPU and GPU are 1000 consecutive exploration tasks). The FPGA platform used to implement the proposed accelerator architecture is the VC707 development board of Xilinx; in the comparative experiment, the CPU uses the Intel (R) Core (TM) i7-10700F processor with a main frequency of 2.9GHz; the GPU uses the NVIDIA GeForce GTX 1660SUPER with a core frequency of 1.53GHz.
[0131] Table 3 Comparison of A3C execution performance on different platforms
[0132]
[0133] It can be seen from Table 3 that compared with the CPU platform, the FPGA-based accelerator of the present invention can achieve a 5.8-fold speed increase, and the power consumption overhead is only 49.9% of that of the CPU platform; compared with the GPU platform, the FPGA-based accelerator can achieve a 7.7-fold speed increase, and the power consumption overhead is 60.5% of that of the GPU platform.
[0134] Table 4 FPGA resource overhead
[0135]
[0136] Table 4 shows the resource consumption of FGPA. The accelerator design of the present invention fully considers resource reuse, multi-level storage, and pipeline design, effectively reducing the utilization rate of the main resources of FPGA. Because in the process of accelerated calculation, the power consumption of reading data from outside the chip is much greater than the power consumption of reading data from the on-chip BRAM, and reading data from the on-chip BRAM is beneficial to improving the accelerator frequency. Therefore, in order to reduce the power consumption overhead of the accelerator and improve the performance of the accelerator, all weight caches are placed on the chip. The problem caused by placing all weight caches on the chip is that the utilization rate of the on-chip BRAM resources is high. The present invention reduces BRAM resources as much as possible by reusing cache modules, and finally controls the BRAM resource utilization rate to about 72%.
[0137] The present invention adopts the acceleration strategy of computing parallelism and pipeline design to improve the computing rate of the accelerator, adopts heterogeneous computing structure deployment to improve the access efficiency of weight storage, adopts multi-module design to realize all computing processes of A3C deep reinforcement learning agent, divides multiple independent storage spaces and deploys multiple PEs in the computing unit to realize the distributed learning framework of the A3C algorithm, and controls the parameter update order of the agent in the RMSProp parameter update unit to realize the asynchronous learning framework of the A3C algorithm.
[0138] The above description is only a specific implementation of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a technician familiar with the technical field within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention.
Claims
1. An FPGA-based A3C deep reinforcement learning algorithm accelerator, comprising a host computer for providing an interactive environment and an FPGA accelerator for computing acceleration, characterized in that: The FPGA accelerator includes a storage module, a forward calculation module, a reverse calculation module, a reverse input calculation module, a gradient calculation module and an RMSProp parameter update module, wherein: The forward calculation module includes N parallel calculation FPE modules, and the FPE module includes a first matrix calculation unit, a ReLU activation unit, and a Softmax activation unit; wherein, When computing shared layers: A first matrix calculation unit is used to read the input feature map x and the network parameter θ from the storage module, perform a matrix multiplication operation on x and the network parameter θ, and then output the operation result A to the ReLU activation unit and the storage module; A ReLU activation unit, used for performing an activation operation on the operation result A output by the first matrix calculation unit and then outputting a feature map y to a storage module cache; When calculating the output layer: The first matrix calculation unit is used to read y and the network parameter θ from the storage module, perform linear multiplication and summation on y and the network parameter θ, and obtain a Critic network output value v to output to the storage module; The Softmax activation unit is used to process the calculation results of the shared layer read in parallel, the calculation results of the shared layer refer to y, obtain a set of Actor network output values π and output them to the storage module; The reverse input calculation module is used to calculate the reverse input feature map x' and output it to the storage module according to the calculation results of the A3C agent network output layer in the storage module. The calculation results of the A3C agent network output layer are the Actor network output value π and the Critic network output value v. x' includes the Actor network reverse input map y' π And the reverse input graph y' of the Critic network v ; The reverse computing module includes N parallel computing BPE modules, where: The BPE module is used to process the forward input node data X, the reverse input feature map x' and the network parameter θ to obtain the reverse output feature map y' and output it to the storage module; wherein the forward input node data X refers to the operation result A output by the first matrix calculation unit without the Relu activation operation; The gradient calculation module includes N parallel computing GPE modules, among which, The GPE module reads the forward input node data X and the reverse input node data X' from the storage module, where X' refers to the reverse input feature map x' or the reverse output feature map y'. The GPE module processes X and X' and outputs a set of network parameter gradient values dθ to the RMSProp parameter update module and the storage module. The RMSProp parameter update module includes a gradient aggregation unit and a parameter update unit, where: A gradient aggregation unit, used to aggregate and calculate dθ according to the historical gradient values read from the storage module, and output the aggregated gradient values to the parameter updating unit; A parameter updating unit, used to update and calculate the historical network parameters read from the storage module according to the aggregated gradient values, obtain new network parameters and output them to the storage module; The BPE module includes a positive and negative cache unit, a weight input control unit and a second matrix calculation unit, wherein the positive and negative cache unit includes a selector and a register for recording the positive and negative of the forward input node data; the weight input control unit includes a selector for completing the derivation operation of the ReLU activation function according to the positive and negative of the forward input node data; the second matrix calculation unit includes a multiplier and an adder, and the second matrix calculation unit is used to complete the matrix multiplication operation between the reverse input feature map x' and the output of the weight input control unit, and output the reverse output feature map y' to the storage module.
2. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The first matrix calculation unit includes a multiplier and an adder, the ReLU activation unit includes a 0-value comparator, and the Softmax activation unit includes an exponential operator, a divider, and an adder.
3. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The calculation process of the forward calculation module is as follows: When calculating the shared layer, the first matrix calculation unit and the ReLU calculation unit are used. At this time, the calculation process of the forward calculation module includes the following steps: Step 11: read the input feature map x and the network parameter θ from the storage module to the first matrix calculation unit; Step 12: Send the input feature map x and network parameter θ into the multiplication-addition tree structure of the first matrix calculation unit. x and θ will be added to the bias after multiplication and summation. Step 13, the output result of the first matrix calculation unit is sent to the ReLU activation unit as input data, and the input data is compared with 0. When the input data is less than 0, the output is 0; when the input data is greater than or equal to 0, the data is output and the size of the input data is kept unchanged, and the output data is cached in the storage module. After a preset clock cycle, all output calculations are completed; When calculating the output layer, the first matrix calculation unit and the Softmax activation unit are used. At this time, the calculation process of the forward calculation module includes the following steps: Step 21, read y and network parameter θ from the storage module to the first matrix calculation unit, and read y to the Softmax activation unit; Step 22, the multiplication-addition tree structure of the first matrix calculation unit completes the linear multiplication and summation of y and the network parameter θ by multiplication and addition, and obtains a Critic network output value v; Step 23, the Softmax activation unit uses the calculation results of the shared layer read in parallel as input data, converts the input data into a serial arrangement, and obtains a serial sequence. The calculation result of the shared layer refers to y; Step 24: Send the serial sequence obtained in step 23 to the exponential operator to obtain the exponential output, and then calculate a set of Actor network outputs π through the accumulator and the divider.
4. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The reverse input calculation module includes a multiplier, an adder and a selector; the calculation process of the reverse input calculation module includes the following steps: When calculating the reverse input graph of the Actor network, the calculation process of the reverse input calculation module includes the following steps: Step 31: Read the output result π of the l Actor network layer from the storage module to the reverse input calculation module, where π is recorded as z1~z l , z i is the output result of the ith Actor network layer, z j is the output result of the j-th Actor network layer, 1≤i≤l, 1≤j≤l; Step 32: Use floating point numbers to calculate IP check z1~z l After negation, logarithm, multiplication and addition, we get 1-lnz i 、-z i z j With z i (1-z i )result; Step 33: 1-lnz obtained in step 32 i 、-z i z j With z i (1-z i ) The result is sent to the multiplication-addition tree structure, and the calculation result output by the multiplication-addition tree structure is multiplied by the hyperparameter c and the time error δ, and then the sum is obtained to obtain the reverse input graph y' of the Actor network π ; When calculating the reverse input graph of the Critic network, the calculation process of the reverse input calculation module includes the following steps: Step 41: Read the first to third network parameters θ of the Critic network layer from the storage module w1 ~θ w3 To the reverse input calculation module; Step 42: Use the floating point calculation IP core to invert and double the time error δ and then send it to the multiplier to multiply it with the network parameter matrix to obtain the reverse input graph y' of the Critic network. v .
5. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The calculation process of the reverse calculation module includes the following steps: Step 51, read the network parameter θ, the forward input node data X and the reverse input feature map x' from the storage module to the reverse calculation module, and use the positive and negative cache units to record the positive and negative of the forward input node data; the forward input node data X refers to the output result A of the first matrix calculation unit without the Relu activation operation; Step 52, the weight input control unit uses the positive and negative values stored in the positive and negative buffer units in step 51 to complete the derivation operation of the Relu function. When the positive and negative values are 0, the weight input is 0; when the positive and negative values are 1, the weight input is the network parameter read in step 51; Step 53: Send the output of the weighted input control unit and the reverse input feature map x' to the multiplication-accumulation structure of the second matrix calculation unit, and complete the calculation of the reverse output feature map y' after a certain clock cycle.
6. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: Each GPE module includes a positive and negative cache unit, an input control unit and n parallel multipliers; the positive and negative cache unit includes a selector and a register, the input of the positive and negative cache unit is the positive input node data X, and the positive and negative cache unit is used to record the positive and negative of the positive input node data; the input control unit includes a selector, the input of the input control unit is 0 and the positive input node data X, and is used to complete the derivative operation of the ReLU activation function according to the positive and negative of the forward calculation result; n parallel multipliers are used to complete the reverse input node data X', X' refers to the multiplication operation between the reverse input feature map x' or the reverse output feature map y' and the output of the input control unit, and output a set of network parameter gradient values dθ to the RMSProp parameter update module; The calculation process of the gradient calculation module is as follows: Step 61, read the forward input node data X and the reverse input node data X' into the gradient calculation module; Step 62: Use the positive and negative buffer units and the input control unit to control the multiplication of the reverse input node data X' and the forward input node data X to obtain the gradient calculation result. After a certain clock cycle, the calculation of all gradient values can be completed.
7. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The RMSProp parameter update module includes a gradient aggregation unit and a parameter update unit; the gradient aggregation unit includes a plurality of adder arrays with a parallelism of N, the input of the gradient aggregation unit is the network parameter gradient value dθ transmitted by the gradient calculation module, which is used to complete the gradient aggregation calculation of each GPE module in the gradient calculation module, and after the calculation is completed, the aggregated gradient value is output to the parameter update unit; the parameter update unit includes a multiplier, an adder and a register, the parameter update unit reads the historical network parameters from the storage module, and uses the calculation results of the gradient aggregation unit to perform parameter update calculation, and then outputs the new network parameters to the storage module.
8. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The calculation process of the RMSProp parameter update module is as follows: Step 71, read the gradient value dθ from the gradient calculation module, and read the historical gradient dθ' from the storage module into the gradient aggregation unit; Step 72: sum the read gradient values, and then send the calculation result to the storage module. After a certain clock cycle, the gradient aggregation calculation is completed. Step 73, when the gradient aggregation calculation is completed, the control signal is read and transmitted to the first-in-first-out memory FIFO. When the parameter update unit is idle, the selector reads out the control signal of the FIFO read port, and simultaneously accesses the central agent parameter memory and the gradient value buffer of the agent corresponding to the control signal, performs gradient update calculation, and transmits the updated network parameter value to the storage module.
9. The FPGA-based A3C deep reinforcement learning algorithm accelerator according to claim 1, characterized in that: The storage module includes an on-chip BRAM, which includes an agent data storage unit and a reverse calculation module cache unit. The agent data storage unit includes a central agent cache and N local agent caches. The central agent cache is used to store the central network parameter θ c , and the storage of each local agent is divided into parameter θ cache, parameter g cache, gradient value cache and forward calculation cache; among them, the parameter θ cache is used to store the local agent deep neural network parameter θ; the parameter g cache stores the RMPProp parameter g maintained by the local agent; the gradient value cache is used to store the gradient value calculation results of the local agent; the forward calculation cache is used to store the input and output of each layer of the deep neural network of the local agent during the reasoning calculation process; the reverse calculation module cache unit allocates an intermediate result cache area for each BPE, which is used to store the intermediate calculation results generated by the deep neural network propagation in the reverse calculation.
Citation Information
Patent Citations
Neural networks for selecting actions to be performed by a robotic agent
CN110023965A
Convolutional neural network accelerator based on FPGA
CN115018062A
Improved neural network hardware acceleration method and device based on FPGA
CN115564035A
Hardware accelerator for compressed GRU on FPGA
US20180046901A1
