ddpgaigym
Continuous control with deep reinforcement learning  Deep Deterministic Policy Gradient (DDPG) algorithm implemented in OpenAI Gym environments
view repo
Recent work has shown that deep neural networks are capable of approximating both value functions and policies in reinforcement learning domains featuring continuous state and action spaces. However, to the best of our knowledge no previous work has succeeded at using deep neural networks in structured (parameterized) continuous action spaces. To fill this gap, this paper focuses on learning within the domain of simulated RoboCup soccer, which features a small set of discrete action types, each of which is parameterized with continuous variables. The best learned agent can score goals more reliably than the 2012 RoboCup champion agent. As such, this paper represents a successful extension of deep reinforcement learning to the class of parameterized action space MDPs.
READ FULL TEXT VIEW PDFContinuous control with deep reinforcement learning  Deep Deterministic Policy Gradient (DDPG) algorithm implemented in OpenAI Gym environments
None
None
This paper extends the Deep Deterministic Policy Gradients (DDPG) algorithm (Lillicrap et al., 2015) into a parameterized action space. We document a modification to the published version of the DDPG algorithm: namely bounding action space gradients. We found this modification necessary for stable learning in this domain and will likely be valuable for future practitioners attempting to learn in continuous, bounded action spaces.
We demonstrate reliable learning, from scratch, of RoboCup soccer policies capable of goal scoring. These policies operate on a lowlevel continuous state space and a parameterizedcontinuous action space. Using a single reward function, the agents learn to locate and approach the ball, dribble to the goal, and score on an empty goal. The best learned agent proves more reliable at scoring goals, though slower, than the handcoded 2012 RoboCup champion.
RoboCup 2D HalfFieldOffense (HFO) is a research platform for exploring single agent learning, multiagent learning, and adhoc teamwork. HFO features a lowlevel continuous state space and parameterizedcontinuous action space. Specifically, the parameterized action space requires the agent to first select the type of action it wishes to perform from a discrete list of high level actions and then specify the continuous parameters to accompany that action. This parameterization introduces structure not found in a purely continuous action space.
The rest of this paper is organized as follows: the HFO domain is presented in Section 2. Section 3 presents background on deep continuous reinforcement learning including detailed actor and critic updates. Section 5 presents a method of bounding action space gradients. Section 6 covers experiments and results. Finally, related work is presented in Section 8 followed by conclusions.
RoboCup is an international robot soccer competition that promotes research in AI and robotics. Within RoboCup, the 2D simulation league
works with an abstraction of soccer wherein the players, the ball, and the field are all 2dimensional objects. However, for the researcher looking to quickly prototype and evaluate different algorithms, the full soccer task presents a cumbersome prospect: full games are lengthy, have high variance in their outcome, and demand specialized handling of rules such as free kicks and offsides.
The Half Field Offense domain abstracts away the difficulties of full RoboCup and exposes the experimenter only to core decisionmaking logic, and to focus on the most challenging part of a RoboCup 2D game: scoring and defending goals. In HFO, each agent receives its own state sensations and must independently select its own actions. HFO is naturally characterized as an episodic multiagent POMDP because of the sequential partial observations and actions on the part of the agents and the welldefined episodes which culminate in either a goal being scored or the ball leaving the play area. To begin each episode, the agent and ball are positioned randomly on the offensive half of the field. The episode ends when a goal is scored, the ball leaves the field, or 500 timesteps pass. Example videos of Half Field Offense games may be viewed at: https://vid.me/sNev https://vid.me/JQTw https://vid.me/1b5D. The following subsections introduce the lowlevel state and action space used by agents in this domain.
The agent uses a lowlevel, egocentric viewpoint encoded using 58 continuouslyvalued features. These features are derived through HeliosAgent2D’s (Akiyama, 2010) world model and provide angles and distances to various onfield objects of importance such as the ball, the goal, and the other players. Figure 1 depicts the perceptions of the agent. The most relevant features include: Agent’s position, velocity, and orientation, and stamina; Indicator if the agent is able to kick; Angles and distances to the following objects: Ball, Goal, FieldCorners, PenaltyBoxCorners, Teammates, and Opponents. A full list of state features may be found at https://github.com/mhauskn/HFO/blob/master/doc/manual.pdf.
Half Field Offense features a lowlevel, parameterized action space. There are four mutuallyexclusive discrete actions: Dash, Turn, Tackle, and Kick. At each timestep the agent must select one of these four to execute. Each action has 12 continuouslyvalued parameters which must also be specified. An agent must select both the discrete action it wishes to execute as well as the continuously valued parameters required by that action. The full set of parameterized actions is:
Dash(power, direction): Moves in the indicated direction with a scalar power in . Movement is faster forward than sideways or backwards. Turn(direction): Turns to indicated direction. Tackle(direction): Contests the ball by moving in the indicated direction. This action is only useful when playing against an opponent. Kick(power, direction): Kicks the ball in the indicated direction with a scalar power in . All directions are parameterized in the range of degrees.
True rewards in the HFO domain come from winning full games. However, such a reward signal is far too sparse for learning agents to gain traction. Instead we introduce a handcrafted reward signal with four components: Move To Ball Reward provides a scalar reward proportional to the change in distance between the agent and the ball . An additional reward of 1 is given the first time each episode the agent is close enough to kick the ball. Kick To Goal Reward is proportional to the change in distance between the ball and the center of the goal . An additional reward is given for scoring a goal . A weighted sum of these components results in a single reward that first guides the agent close enough to kick the ball, then rewards for kicking towards goal, and finally for scoring. It was necessary to provide a higher gain for the kicktogoal component of the reward because immediately following each kick, the movetoball component produces negative rewards as the ball moves away from the agent. The overall reward is as follows:
(1) 
It is disappointing that reward engineering is necessary. However, the exploration task proves far too difficult to ever gain traction on a reward that consists only of scoring goals, because acting randomly is exceedingly unlikely to yield even a single goal in any reasonable amount of time. An interesting direction for future work is to find better ways of exploring large state spaces. One recent approach in this direction, Stadie et al. (2015) assigned exploration bonuses based on a model of system dynamics.
Deep neural networks are adept general purpose function approximators that have been most widely used in supervised learning tasks. Recently, however they have been applied to reinforcement learning problems, giving rise to the field of deep reinforcement learning. This field seeks to combine the advances in deep neural networks with reinforcement learning algorithms to create agents capable of acting intelligently in complex environments. This section presents background in deep reinforcement learning in continuous action spaces. The notation closely follows that of
Lillicrap et al. (2015).Deep, modelfree RL in discrete action spaces can be performed using the Deep QLearning method introduced by Mnih et al. (2015)
which employs a single deep network to estimate the value function of each discrete action and, when acting, selects the maximally valued output for a given state input. Several variants of DQN have been explored.
Narasimhan et al. (2015) used decaying traces, Hausknecht & Stone (2015) investigated LSTM recurrency, and van Hasselt et al. (2015) explored double QLearning. These networks work well in continuous state spaces but do not function in continuous action spaces because the output nodes of the network, while continuous, are trained to output QValue estimates rather than continuous actions.An Actor/Critic architecture (Sutton & Barto, 1998) provides one solution to this problem by decoupling the value learning and the action selection. Represented using two deep neural networks, the actor network outputs continuous actions while the critic estimates the value function. The actor network , parameterized by , takes as input a state and outputs a continuous action . The critic network , parameterized by , takes as input a state and action and outputs a scalar QValue . Figure 2 shows Critic and Actor networks.
Updates to the critic network are largely unchanged from the standard temporal difference update used originally in QLearning (Watkins & Dayan, 1992) and later by DQN:
(2) 
Adapting this equation to the neural network setting described above results in minimizing a loss function defined as follows:
(3) 
However, in continuous action spaces, this equation is no longer tractable as it involves maximizing over nextstate actions . Instead we ask the actor network to provide a nextstate action . This yields a critic loss with the following form:
(4) 
The value function of the critic can be learned by gradient descent on this loss function with respect to . However, the accuracy of this value function is highly influenced by the quality of the actor’s policy, since the actor determines the nextstate action in the update target.
The critic’s knowledge of action values is then harnessed to learn a better policy for the actor. Given a sample state, the goal of the actor is to minimize the difference between its current output and the optimal action in that state .
(5) 
The critic may be used to provide estimates of the quality of different actions but naively estimating would involve maximizing the critic’s output over all possible actions: . Instead of seeking a global maximum, the critic network can provide gradients which indicate directions of change, in action space, that lead to higher estimated QValues: . To obtain these gradients requires a single backward pass over the critic network, much faster than solving an optimization problem in continuous action space. Note that these gradients are not the common gradients with respect to parameters. Instead these are gradients with respect to inputs, first used in this way by NFQCA (Hafner & Riedmiller, 2011). To update the actor network, these gradients are placed at the actor’s output layer (in lieu of targets) and then backpropagated through the network. For a given state, the actor is run forward to produce an action that the critic evaluates, and the resulting gradients may be used to update the actor:
(6) 
Alternatively one may think about these updates as simply interlinking the actor and critic networks: On the forward pass, the actor’s output is passed forward into the critic and evaluated. Next, the estimated QValue is backpropagated through the critic, producing gradients
that indicate how the action should change in order to increase the QValue. On the backwards pass, these gradients flow from the critic through the actor. An update is then performed only over the actor’s parameters. Figure 2 shows an example of this update.Updates to the critic rely on the assumption that the actor’s policy is a good proxy for the optimal policy. Updates to the actor rest on the assumption that the critic’s gradients, or suggested directions for policy improvement, are valid when tested in the environment. It should come as no surprise that several techniques are necessary to make this learning process stable and convergent.
Because the critic’s policy influences both the actor and critic updates, errors in the critic’s policy can create destructive feedback resulting in divergence of the actor, critic, or both. To resolve this problem Mnih et al. (2015) introduce a TargetQNetwork , a replica of the critic network that changes on a slower time scale than the critic. This target network is used to generate next state targets for the critic update (Equation 4). Similarly a TargetActorNetwork combats quick changes in the actor’s policy.
The second stabilizing influence is a replay memory , a FIFO queue consisting of the agent’s latest experiences (typically one million). Updating from minibatches of experience sampled uniformly from this memory reduces bias compared to updating exclusively from the most recent experiences.
Employing these two techniques the critic loss in Equation 4 and actor update in Equation 5 can be stably reexpressed as follows:
(7) 
(8) 
Finally, these updates are applied to the respective networks, where is a perparameter step size determined by the gradient descent algorithm. Additionally, the targetactor and targetcritic networks are updated to smoothly track the actor and critic using a factor :
(9) 
Shown in Figure 2
, both the actor and critic employ the same architecture: The 58 state inputs are processed by four fully connected layers consisting of 1024512256128 units respectively. Each fully connected layer is followed by a rectified linear (ReLU) activation function with negative slope
. Weights of the fully connected layers use Gaussian initialization with a standard deviation of
. Connected to the final inner product layer are two linear output layers: one for the four discrete actions and another for the six parameters accompanying these actions. In addition to the 58 state features, the critic also takes as input the four discrete actions and six action parameters. It outputs a single scalar Qvalue. We use the ADAM solver with both actor and critic learning rate set to . Target networks track the actor and critic using a . Complete source code for our agent is available at https://github.com/mhauskn/dqnhfo and for the HFO domain at https://github.com/mhauskn/HFO/. Having introduced the background of deep reinforcement learning in continuous action space, we now present the parameterized action space.Following notation in (Masson & Konidaris, 2015)
, a Parameterized Action Space Markov Decision Process (PAMDP) is defined by a set of discrete actions
. Each discrete action features continuous parameters . Actions are represented by tuples . Thus the overall action space .In Half Field Offense, the complete parameterized action space (Section 2.2) is . The actor network in Figure 2 factors the action space into one output layer for discrete actions and another for all six continuous parameters .
Using the factored action space, deterministic action selection proceeds as follows: At each timestep, the actor network outputs values for each of the four discrete actions as well as six continuous parameters. The discrete action is chosen to be the maximally valued output and paired with associated parameters from the parameter output layer . Thus the actor network simultaneously chooses which discrete action to execute and how to parameterize that action.
During training, the critic network receives, as input, the values of the output nodes of all four discrete actions and all six action parameters. We do not indicate to the critic which discrete action was actually applied in the HFO environment or which continuous parameters are associated with that discrete action. Similarly, when updating the actor, the critic provides gradients for all four discrete actions and all six continuous parameters. While it may seem that the critic is lacking crucial information about the structure of the action space, our experimental results in Section 6 demonstrate that the critic learns to provide gradients to the correct parameters of each discrete action.
Exploration in continuous action space differs from discrete space. We adapt
greedy exploration to parameterized action space: with probability
, a random discrete action is selected and the associated continuous parameters are sampled using a uniform random distribution. Experimentally, we anneal from 1.0 to 0.1 over the first updates. Lillicrap et al. (2015) demonstrate that OrnsteinUhlenbeck exploration is also successful in continuous action space.The Half Field Offense domain bounds the range of each continuous parameter. Parameters indicating direction (e.g. Turn and Kick direction) are bounded in and parameters for power (e.g. Kick and Dash power) are bounded in . Without enforcing these bounds, after a few hundred updates, we observed continuous parameters routinely exceeding the bounds. If updates were permitted to continue, parameters would quickly trend towards astronomically large values. This problem stems from the critic providing gradients that encourage the actor network to continue increasing a parameter that already exceeds bounds. We explore three approaches for preserving parameters in their intended ranges:
Zeroing Gradients: Perhaps the simplest approach is to examine the critic’s gradients for each parameter and zero the gradients that suggest increasing/decreasing the value of a parameter that is already at the upper/lower limit of its range:
(10) 
Where indicates the critic’s gradient with respect to parameter , (e.g. ) and indicate respectively the minimum bound, maximum bound, and current activation of that parameter.
Squashing Gradients: A squashing function such as the hyperbolic tangent (tanh) is used to bound the activation of each parameter. Subsequently, the parameters are rescaled into their intended ranges. This approach has the advantage of not requiring manual gradient tinkering, but presents issues if the squashing function saturates.
Inverting Gradients: This approach captures the best aspects of the zeroing and squashing gradients, while minimizing the drawbacks. Gradients are downscaled as the parameter approaches the boundaries of its range and are inverted if the parameter exceeds the value range. This approach actively keeps parameters within bounds while avoiding problems of saturation. For example, if the critic continually recommends increasing a parameter, it will converge to the parameter’s upper bound. If the critic then decides to decrease that parameter, it will decrease immediately. In contrast, a squashing function would be saturated at the upper bound of the range and require many updates to decrease. Mathematically, the inverted gradient approach may be expressed as follows:
(11) 
It should be noted that these approaches are not specific to HFO or parameterized action space. Any domain featuring a boundedcontinuous action space will require a similar approach for enforcing bounds. All three approaches are empirically evaluated the next section.
We evaluate the zeroing, squashing, and inverting gradient approaches in the parameterized HFO domain on the task of approaching the ball and scoring a goal. For each approach, we independently train two agents. All agents are trained for 3 million iterations, approximately 20,000 episodes of play. Training each agent took three days on a NVidia TitanX GPU.
Of the three approaches, only the inverting gradient shows robust learning. Indeed both inverting gradient agents learned to reliably approach the ball and score goals. None of the other four agents using the squashing or zeroing gradients were able to reliably approach the ball or score.
Further analysis of the squashing gradient approach reveals that parameters stayed within their bounds, but squashing functions quickly became saturated. The resulting agents take the same discrete action with the same maximum/minimum parameters each timestep. Given the observed proclivity of the critic’s gradients to push parameters towards ever larger/small values, it is no surprise that squashing function quickly become saturated and never recover.
Further analysis of the zeroing gradient approach reveals two problems: 1) parameters still overflow their bounds and 2) instability: While the gradient zeroing approach negates any direct attempts to increase a parameter beyond its bounds, we hypothesize the first problem stems from gradients applied to other parameters which inadvertently allow parameter to overflow. Empirically, we observed learned networks attempting to dash with a power of 120, more than the maximum of 100. It is reasonable for a critic network to encourage the actor to dash faster.
Unstable learning was observed in one of the two zeroing gradient agents. This instability is well captured in the QValues and critic losses shown in Figure 3. It’s not clear why this agent became unstable, but the remaining stable agent showed clear results of not learning.
These results highlight the necessity of nonsaturating functions that effectively enforce action bounds. The approach of inverting gradients was observed to respect parameter boundaries (observed dash power reaches 98.8 out of 100) without saturating. As a result, the critic was able to effectively shape the actor’s policy. Further evaluation of the reliability and quality of the invertinggradient policies is presented in the next section.
): As more reward is experienced critic loss is expected to rise as past actions are seen as increasingly suboptimal. Inverting gradients shows growing critic loss with outliers accounting for the rapid increase nearing the right edge of the graph. Zeroing gradients approach shows unstably large loss. Squashing gradients never discovers much reward and loss stays near zero.
We further evaluate the inverting gradient agents by comparing them to an expert agent independently created by the Helios RoboCup2D team. This agent won the 2012 RoboCup2D world championship and source code was subsequently released (Akiyama, 2010). Thus, this handcoded policy represents an extremely competent player and a high performance bar.
As an additional baseline we compare to a SARSA learning agent. StateActionRewardStateAction (SARSA) is an algorithm for modelfree onpolicy Reinforcement Learning Sutton & Barto (1998). The SARSA agent learns in a simplified version of HFO featuring highlevel discrete actions for moving, dribbling, and shooting the ball. As input it is given continuous features that including the distance and angle to the goal center. Tile coding Sutton & Barto (1998) is used to discretize the state space. Experiences collected by playing the game are then used to bootstrap a value function.
To show that the deep reinforcement learning process is reliable, in additional to the previous two invertinggradient agents we independently train another five invertinggradient agents, for a total of seven agents DDPG. All seven agents learned to score goals. Comparing against the Helios’ champion agent, each of the learned agents is evaluated for 100 episodes on how quickly and reliably it can score.
Six of seven DDPG agents outperform the SARSA baseline, and remarkably, three of the seven DDPG agents score more reliably than Helios’ champion agent. Occasional failures of the Helios agent result from noise in the action space, which occasionally causes missed kicks. In contrast, DDPG agents learn to take extra time to score each goal, and become more accurate as a result. This extra time is reasonable considering DDPG is rewarded only for scoring and experiences no real pressure to score more quickly. We are encouraged to see that deep reinforcement learning can produce agents competitive with and even exceeding an expert handcoded agent.

RoboCup 2D soccer has a rich history of learning. In one of the earliest examples, Andre & Teller (1999)
used Genetic Programming to evolve policies for RoboCup 2D Soccer. By using a sequence of reward functions, they first encourage the players to approach the ball, kick the ball, score a goal, and finally to win the game. Similarly, our work features players whose policies are entirely trained and have no handcoded components. Our work differs by using a gradientbased learning method paired with using reinforcement learning rather than evolution.
Masson & Konidaris (2015) present a parameterizedaction MDP formulation and approaches for modelfree reinforcement learning in such environments. The core of this approach uses a parameterized policy for choosing which discrete action to select and another policy for selecting continuous parameters for that action. Given a fixed policy for parameter selection, they use QLearning to optimize the policy discrete action selection. Next, they fix the policy for discrete action selection and use a policy search method to optimize the parameter selection. Alternating these two learning phases yields convergence to either a local or global optimum depending on whether the policy search procedure can guarantee optimality. In contrast, our approach to learning in parameterized action space features a parameterized actor that learns both discrete actions and parameters and a parameterized critic that learns only the actionvalue function. Instead of relying on an external policy search procedure, we are able to directly query the critic for gradients. Finally, we parameterize our policies using deep neural networks rather than linear function approximation. Deep networks offer no theoretical convergence guarantees, but have a strong record of empirical success.
Experimentally, Masson & Konidaris (2015) examine a simplified abstraction of RoboCup 2D soccer which colocates the agent and ball at the start of every trial and features a smaller action space consisting only of parameterized kick actions. However, they do examine the more difficult task of scoring on a keeper. Since their domain is handcrafted and closedsource, it’s hard to estimate how difficult their task is compared to the goal scoring task in our paper.
Competitive RoboCup agents are primarily handcoded but may feature components that are learned or optimized. MacAlpine et al. (2015) employed the layeredlearning framework to incrementally learn a series of interdependent behaviors. Perhaps the best example of comprehensively integrating learning is the Brainstormers who, in competition, use a neural network to make a large portion of decisions spanning low level skills through high level strategy (Riedmiller et al., 2009; Riedmiller & Gabel, 2007). However their work was done prior to the advent of deep reinforcement learning, and thus required more constrained, focused training environments for each of their skills. In contrast, our study learns to approach the ball, kick towards the goal, and score, all within the context of a single, monolithic policy.
Deep learning methods have proven useful in various control domains. As previously mentioned DQN (Mnih et al., 2015) and DDPG (Lillicrap et al., 2015) provide great starting points for learning in discrete and continuous action spaces. Additionally, Levine et al. (2015) demonstrates the ability of deep learning paired with guided policy search to learn manipulation policies on a physical robot. The high requirement for data (in the form of experience) is a hurdle for applying deep reinforcement learning directly onto robotic platforms. Our work differs by examining an action space with latent structure and parameterizedcontinuous actions.
The harder task of scoring on a goalie is left for future work. Additionally, the RoboCup domain presents many opportunities for multiagent collaboration both in an adhocteamwork setting (in which a single learning agent must collaborate with unknown teammates) and true multiagent settings (in which multiple learning agents must collaborate). Challenges in multiagent learning in the RoboCup domain have been examined by prior work (Kalyanakrishnan et al., 2007) and solutions may translate into the deep reinforcement learning settings as well. Progress in this direction could eventually result in a team of deep reinforcement learning soccer players.
Another interesting possibility is utilizing the critic’s gradients with respect to state inputs . These gradients indicate directions of improvement in state space. An agent with a forward model may be able to exploit these gradients to transition into states which the critic finds more favorable. Recent developments in modelbased deep reinforcement learning (Oh et al., 2015) show that detailed next state models are possible.
This paper has presented an agent trained exclusively with deep reinforcement learning which learns from scratch how to approach the ball, kick the ball to goal, and score. The best learned agent scores goals more reliably than a handcoded expert policy. Our work does not address more challenging tasks such as scoring on a goalie or cooperating with a team, but still represents a step towards fully learning complex RoboCup agents. More generally we have demonstrated the capability of deep reinforcement learning in parameterized action space.
To make this possible, we extended the DDPG algorithm (Lillicrap et al., 2015), by presenting an analyzing a novel approach for bounding the action space gradients suggested by the Critic. This extension is not specific to the HFO domain and will likely prove useful for any continuous, bounded action space.
The authors wish to thank Yilun Chen. This work has taken place in the Learning Agents Research Group (LARG) at the Artificial Intelligence Laboratory, The University of Texas at Austin. LARG research is supported in part by grants from the National Science Foundation (CNS1330072, CNS1305287), ONR (21C18401), AFRL (FA87501410070), AFOSR (FA95501410087), and Yujin Robot. Additional support from the Texas Advanced Computing Center, and Nvidia Corporation.
Comments
There are no comments yet.