Increasing the Action Gap: New Operators for Reinforcement Learning
Marc G. Bellemare, Georg Ostrovski, Arthur Guez, Philip S. Thomas, Rémi Munos
Background
A deterministic policy induces a Q-function whose Bellman equation is
The state-conditional expected return is the expected discounted total reward received from starting in and following .
The Bellman operator is defined pointwise as
is a contraction mapping in supremum norm (? ?) whose unique fixed point is the optimal Q-function
which induces the optimal policy :
A Q-function induces a greedy policy , with the property that if and only if . For we call the greedy action with respect to and a nongreedy action; for these are the usual optimal and suboptimal actions, respectively.
We emphasize that while we focus on the Bellman operator, our results easily extend to its variations such as SARSA (? ?), policy evaluation (? ?), and fitted Q-iteration (? ?). In particular, our new operators all have a sample-based form, i.e., an analogue to the Q-Learning rule of ? (?).
The Consistent Bellman Operator
It is well known (and implicit in our notation) that the optimal policy for is stationary (i.e., time-independent) and deterministic. In looking for , we may therefore restrict our search to the space of stationary deterministic policies. Interestingly, as we now show the Bellman operator on is not, in a sense, restricted to .
To begin, consider the two-state MDP depicted in Figure 1. This MDP abstracts a Faustian situation in which an agent repeatedly chooses between an immediately rewarding but ultimately harmful option (), or an unrewarding alternative (). For concreteness, we imagine the agent as faced with an endless supply of delicious cake (with ) and call these the “cake” and “no cake” actions.
Eating cake can cause a transition to , the “bad state”, whose value is independent of the agent’s policy:
In state , however, the Q-values depend on the agent’s future behaviour. For a policy , the value of is
which is greater than for all . It follows that not eating cake is optimal, and thus . Furthermore, (2) tells us that the value difference between optimal and second best action, or action gap, is
and in particular this value is lower than . Instead, describes the value of a nonstationary policy which eats cake once, but then subsequently abstains.
So far we have considered the Q-functions of given stationary policies , and argued that these are nonstationary. We now make a similar statement about the Bellman operator: for any , the nongreedy components of do not generally describe the expected return of stationary policies. Hence the Bellman operator is not restricted to .
To address this issue, we may be tempted to define a new Q-function which explicitly incorporates stationarity:
Under this new definition, the action gap of the optimal policy is . Unfortunately, (4) does not visibly yield a useful operator on . As a practical approximation we now propose the consistent Bellman operator, which preserves a local form of stationarity:
Effectively, our operator redefines the meaning of Q-values: if from state an action is taken and the next state is then is again taken. In our example, this new Q-value describes the expected return for repeatedly eating cake until a transition to the unpleasant state .
Since the optimal policy is stationary, we may intuit that iterated application of this new operator also yields . In fact, below we show that the consistent Bellman operator is both optimality-preserving and, in the presence of direct loops in the corresponding transition graph, gap-increasing:
An operator is optimality-preserving if, for any and , letting ,
Thus under an optimality-preserving operator at least one optimal action remains optimal, and suboptimal actions remain suboptimal.
Let be an MDP. An operator for is gap-increasing if for all , , letting and ,
We are particularly interested in operators which are strictly gap-increasing, in the sense that (9) is a strict inequality for at least one pair.
Our two-state MDP illustrates the first benefit of increasing the action gap: a greater robustness to estimation error. Indeed, under our new operator the optimal Q-value of eating cake becomes
An aggregation scheme for is a tuple where is a set of aggregate states, is a mapping from to distributions over , and is a mapping from to distributions over . For let and , where as before we assign specific roles to and . We define the aggregation Bellman operator as
Generalizing (8), we define the consistent Bellman operator over :
Intuitively (see, e.g., ? ?), the and mappings induce a new MDP, with
In this light, we see that our original definition of and (11) only differ in their interpretation of the transition kernel. Thus the consistent Bellman operator remains relevant in cases where is a deterministic transition kernel, for example when applying multilinear or barycentric interpolation to continuous space MDPs (e.g. ? ?).
Q-Value Interpolation
Aggregation schemes as defined above do not immediately yield a Q-function over . Indeed, the Q-value at an arbitrary is defined (in the ordinary Bellman operator sense) as
which may only be computed from a full or partial model of the MDP, or by inverting . It is often the case that neither is feasible. One solution is instead to perform Q-value interpolation:
which is reasonable when are interpolation coefficientsOne then typically, but not always, takes to be the identity.. This gives the related Bellman operator
with by convexity of the operation. From here one may be tempted to define the corresponding consistent operator as
While remains a contraction, is not guaranteed, and it is easy to show that is not optimality-preserving. Instead we define the consistent Q-value interpolation Bellman operator as
As a corollary to Theorem 1 below we will prove that is also optimality-preserving and gap-increasing.
Experiments on the Bicycle Domain
We now study the behaviour of our new operators on the bicycle domain (? ?). In this domain, the agent must simultaneously balance a simulated bicycle and drive it to a goal 1km north of its initial position. Each time step consists of a hundredth of a second, with a successful episode typically lasting 50,000 or more steps. The driving aspect of this problem is particularly challenging for value-based methods, since each step contributes little to an eventual success and the “curse of dimensionality” (? ?) precludes a fine representation of the state-space. In this setting our consistent operator provides significantly improved performance and stability.
We approximated value functions using multilinear interpolation on a uniform grid over a 6-dimensional feature vector . The first four components of describe relevant angles and angular velocities, while and are polar coordinates describing the bicycle’s position relative to the goal. We approximated Q-functions using Q-value interpolation () over this grid, since in a typical setting we may not have access to a forward model.
We are interested here in the quality of the value functions produced by different operators. We thus computed our Q-functions using value iteration, rather than a trajectory-based method such as Q-Learning. More precisely, at each iteration we simultaneously apply our operator to all grid points, with expected next state values estimated from samples. The interested reader may find full experimental details and videos in the appendix.Videos: https://youtu.be/0pUFjNuom1A
in general. This is especially relevant in the relatively high-dimensional bicycle domain, where a fine discretization of the state space is not practical and most of the trajectories take place “far” from grid points. As an example, consider , the relative angle to the goal: each grid cell covers an arc of , while a single time step typically changes by less than .
Figure 3 summarizes our results. Policies derived from our consistent operator can safely balance the bicycle earlier on, and also reach the goal earlier than policies derived from the Bellman operator. Note, in particular, the striking difference in the trajectories followed by the resulting policies. The effect is even more pronounced when using a grid (results provided in the appendix). Effectively, by decreasing suboptimal Q-values at grid points we produce much better policies within the grid cells. This phenomenon is consistent with the theoretical results of ? (?) relating the size of action gaps to the quality of derived greedy policies. Thus we find a second benefit to increasing the action gap: it improves policies derived from Q-value interpolation.
A Family of Convergent Operators
One may ask whether it is possible to extend the consistent Bellman operator to Q-value approximation schemes which lack a probabilistic interpretation, such as linear approximation (? ?), locally weighted regression (? ?), neural networks (? ?), or even information-theoretic methods (? ?). In this section we answer by the affirmative.
The family of operators which we describe here are applicable to arbitrary Q-value approximation schemes. While these operators are in general no longer contractions, they are gap-increasing, and optimality-preserving when the Q-function is represented exactly. Theorem 1 is our main result; one corollary is a convergence proof for Baird’s advantage learning (? ?). Incidentally, our taking the minimum in (13) was in fact no accident, but rather a simple application of this theorem.
Let be the Bellman operator defined by (1). Let be an operator with the property that there exists an such that for all , , and letting ,
, and
.
Then is both optimality-preserving and gap-increasing.
Thus any operator which satisfies the conditions of Theorem 1 will eventually yield an optimal greedy policy, assuming an exact representation of the Q-function. Condition 2, in particular, states that we may subtract up to (but not including) from at each iteration. This is exactly the action gap at , but for , rather than the optimal . For a particular , this implies we may initially devalue the optimal action in favour of the greedy action. But our theorem shows that cannot be undervalued infinitely often, and in fact must ultimately reach .When two or more actions are optimal, we are only guaranteed that one of them will ultimately be correctly valued. The “1-lazy” operator described below exemplifies this possibility. The proof of this perhaps surprising result may be found in the appendix.
To the best of our knowledge, Theorem 1 is the first result to show the convergence of iterates of dynamic programming-like operators without resorting to a contraction argument. Indeed, the conditions of Theorem 1 are particularly weak: we do not require to be a contraction, nor do we assume the existence of a fixed point (in the Q-function space ) of . In fact, the conditions laid out in Theorem 1 characterize the set of optimality-preserving operators on , in the following sense:
There exists a single-state MDP and an operator with either
or
,
and in both cases there exists a for which .
We note that the above remark does not cover the case where condition (2) is an equality (i.e., ). We leave as an open problem the existence of a divergent example for .
The consistent Bellman operator (11) and consistent Q-value interpolation Bellman operator (13) are optimality-preserving.
In fact, it is not hard to show that the consistent Bellman operator (10) is a contraction, and thus enjoys even stronger convergence guarantees than those provided by Theorem 1. Informally, whenever Condition 2 of the theorem is strengthened to an inequality, we may also expect our operators to be gap-increasing; this is in fact the case for both of our consistent operators.
To conclude this section, we describe a few operators which satisfy the conditions of Theorem 1, and are thus optimality-preserving and gap-increasing. Critically, none of these operators are contractions; one of them, the “lazy” operator, also possesses multiple fixed points.
The method of advantage learning was proposed by ? (?) as a means of increasing the gap between the optimal and suboptimal actions in the context of residual algorithms applied to continuous time problems.Advantage updating, also by Baird, is a popular but different idea where an agent maintains both and . The corresponding operator is
where is a time constant and with . Taking and , we define a new operator with the same fixed point but a now-familiar form:
Note that, while the two operators are motivated by the same principle and share the same fixed point, they are not isomorphic. We believe our version to be more stable in practice, as it avoids the multiplication by the term.
For , the advantage learning operator has a unique limit , and .
While our consistent Bellman operator originates from different principles, there is in fact a close relationship between it and the advantage learning operator. Indeed, we can rewrite (8) as
which corresponds to advantage learning with a -dependent parameter.
Persistent Advantage Learning
In domains with a high temporal resolution, it may be advantageous to encourage greedy policies which infrequently switch between actions — to encourage a form of persistence. We define an operator which favours repeated actions:
Note that the second term of the can also be written as
As we shall see below, persistent advantage learning achieves excellent performance on Atari 2600 games.
The Lazy Operator
As a curiosity, consider the following operator with :
This -lazy operator only updates -values when this would affect the greedy policy. And yet, Theorem 1 applies! Hence is optimality-preserving and gap-increasing, even though it may possess a multitude of fixed points in . Of note, while Theorem 1 does not apply to the -lazy operator, the latter is also optimality-preserving; in this case, however, we are only guaranteed that one optimal action remain optimal.
Experimental Results on Atari 2600
We evaluated our new operators on the Arcade Learning Environment (ALE; ? ?), a reinforcement learning interface to Atari 2600 games. In the ALE, a frame lasts of a second, with actions typically selected every four frames. Intuitively, the ALE setting is related to continuous domains such as the bicycle domain studied above, in the sense that each individual action has little effect on the game.
For our evaluation, we trained agents based on the Deep Q-Network (DQN) architecture of ? (?). DQN acts according to an -greedy policy over a learned neural-network Q-function. DQN uses an experience replay mechanism to train this Q-function, performing gradient descent on the sample squared error , where
where is a previously observed transition. We define the corresponding errors for our operators as
where we further parametrized the weight given to in persistent advantage learning (compare with ).
Our first experiment used one of the new ALE standard versions, which we call here the Stochastic Minimal setting. This setting includes stochasticity applied to the Atari 2600 controls, no death information, and a per-game minimal action set. Specifically, at each frame (not time step) the environment accepts the agent’s action with probability , or rejects it with probability (here, ). If an action is rejected, the previous frame’s action is repeated. In our setting the agent selects a new action every four frames: the stochastic controls therefore approximate a form of reaction delay. As evidenced by a lower DQN performance, Stochastic Minimal is more challenging than previous settings.
We trained each agent for 100 million frames using either regular Bellman updates, advantage learning (A.L.), or persistent advantage learning (P.A.L.). We optimized the parameters over 5 training games and tested our algorithms on 55 more games using 10 independent trials each.
For each game, we performed a paired -test (99% C.I.) on the post-training evaluation scores obtained by our algorithms and DQN. A.L. and P.A.L. are statistically better than DQN on 37 and 35 out of 60 games, respectively; both perform worse on one (Atlantis, James Bond). P.A.L. often achieves higher scores than A.L., and is statistically better on 16 games and worse on 6. These results are especially remarkable given that the only difference between DQN and our operators is a simple modification to the update rule.
For comparison, we also trained agents using the Original DQN setting (? ?), in particular using a longer 200 million frames of training. Figure 4 depicts learning curves for two games, Asterix and Space Invaders. These curves are representative of our results, rather than exceptional: on most games, advantage learning outperforms Bellman updates, and persistent advantage learning further improves on this result. Across games, the median score improvement over DQN is 8.4% for A.L. and 9.1% for P.A.L., while the average score improvement is respectively 27.0% and 32.5%. Full experimental details are provided in the appendix.
The learning curve for Asterix illustrates the poor performance of DQN on certain games. Recently, ? (?) argued that this poor performance stems from the instability of the Q-functions learned from Bellman updates, and provided conclusive empirical evidence to this effect. In the spirit of their work, we compared our learned Q-functions on a single trajectory generated by a trained DQN agent playing Space Invaders in the Original DQN setting. For each Q-function and each state along the trajectory, we computed as well as the action gap at .
The value functions and action gaps resulting from this experimentVideos: https://youtu.be/wDfUnMY3vF8 are depicted in Figure 5. As expected, the action gaps are significantly greater for both of our operators, in comparison to the action gaps produced by DQN. Furthermore, the value estimates are themselves lower, and correspond to more realistic estimates of the true value function. In their experiments, van Hasselt et al. observed a similar effect on the value estimates when replacing the Bellman updates with Double Q-Learning updates, one of many solutions recently proposed to mitigate the negative impact of statistical bias in value function estimation (?; ?; ?). This bias is positive and is a consequence of the max term in the Bellman operator. We hypothesize that the lower value estimates observed in Figure 5 are also a consequence of bias reduction. Specifically, increased action gaps are consistent with a bias reduction: it is easily shown that the value estimation bias is strongest when Q-values are close to each other. If our hypothesis holds true, the third benefit of increasing the action gap is thus to mitigate the statistical bias of Q-value estimates.
Open Questions
Statistical Efficiency of New Operators. Advantage learning (as given by our redefinition) may be viewed as a generalization of the consistent Bellman operator when is unknown or irrelevant. In this light, we ask: is there a probabilistic interpretation to advantage learning? We further wonder about the statistical efficiency of the consistent Bellman operator: is it ever less efficient than the usual Bellman operator, when considering the probability of misclassifying the optimal action? Both of these answers might shed some light on the differences in performance observed in our experiments.
Maximally Efficient Operator. Having revealed the existence of a broad family of optimality-preserving operators, we may now wonder which of these operators, if any, should be preferred to the Bellman operator. Clearly, there are trivial MDPs on which any optimality-preserving operator performs equally well. However, we may ask whether there is, for a given MDP, a “maximally efficient” optimality-preserving operator; and whether a learning agent can benefit from simultaneously searching for this operator while estimating a value function.
Concluding Remarks
We presented in this paper a family of optimality-preserving operators, of which the consistent Bellman operator is a distinguished member. At the center of our pursuits lay the desire to increase the action gap; we showed through experiments that this gap plays a central role in the performance of greedy policies over approximate value functions, and how significantly increased performance could be obtained by a simple modification of the Bellman operator. We believe our work highlights the inadequacy of the classical Q-function at producing reliable policies in practice, calls into question the traditional policy-value relationship in value-based reinforcement learning, and illustrates how revisiting the concept of value itself can be fruitful.
Acknowledgments
The authors thank Michael Bowling, Csaba Szepesvári, Craig Boutilier, Dale Schuurmans, Marty Zinkevich, Lihong Li, Thomas Degris, and Joseph Modayil for useful discussions, as well as the anonymous reviewers for their excellent feedback.
References
Appendix
This appendix is divided into three sections. In the first section we present the proofs of our theoretical results. In the second we provide experimental details and additional results for the Bicycle domain. In the final section we provide details of our experiments on the Arcade Learning Environment, including results on 60 games.
Theoretical Results
Let and be the policy greedy with respect to . Let be an operator with the properties that, for all ,
, and
.
since has a unique fixed point. From this we deduce the second claim. Now, for a given , let and . We have
where in the second line we used Condition 2 of the lemma, and in the third the definition of applied to . Thus we have
Following the derivation of Lemma 1, we have
By the same derivation, for we have
and combined with the fact that (15) holds for this proves the upper bound. ∎
Let be the Bellman operator ((1) in the main text). Let be an operator with the property that there exists an such that for all , , and letting ,
, and
.
Furthermore, is also gap-increasing:
where in (16) we used Jensen’s inequality, and (17) follows from the commutativity of and . Now
We now take the of both sides of (19), which Lemma 2 guarantees exists, and obtain
Combining the above with (18), we deduce that
Hence, is optimality-preserving. To prove that is gap-increasing, observe that the statement
since . But we know (21) to be true from Condition 1 (see the proof of Lemma 1). ∎
The consistent Bellman operator ((5) in the main text) and consistent Q-value interpolation Bellman operator ((9) in the main text) are optimality-preserving and gap-increasing.
Experimental Details: Bicycle
We used the bicycle simulator described by ? (?) with a reward function which encourages driving towards the goal. Recall that Randlov and Alstrom’s reward function is
As noted by Randlov and Alstrom themselves, this reward function is unsuitable for value iteration methods, since it rewards driving away from the goal. Instead we use the following related reward function
with the largest negative reward achievable by the agent. Empirically, we found this reward function easier to work with, while our results remained qualitatively similar for similar reward functions. We further use a discount factor of .
We consider two sample-based operators on , the space of Q-functions over representative states. The sample-based Q-value interpolation Bellman operator is defined as
In both cases, we use Q-value interpolation to define a Q-function over :
For each operator , we computed a sequence of Q-functions using an averaging form of value iteration:
applied simultaneously to all and . We chose this averaging version because it led to faster convergence, and lets us take in the definition of both operators. From a parameter sweep we found to be a suitable step-size.
Our multilinear grid was defined over the six state variables. As done elsewhere in the literature, we defined our grid over the following bounded variables:
Values outside of these ranges were accordingly set to the range’s minimum or maximum.
For completeness, Figure 6 compares the performance of the Bellman and consistent Bellman operators, as well as advantage learning and persistent advantage learning (with ), on and grids. Here, the usual Bellman operator is unable to find a solution to the goal, while the consistent Bellman operator successfully does so. The two other operators also achieve superior performance compared to Bellman operator, although appear slightly more unstable in the smaller grid setting.
Experimental Details: ALE
We omit details of the DQN architecture, which are provided in ? (?). A frame is a single emulation step within the ALE, while a time step consists of four consecutive frames which are treated atomically by the agent.
Our first Atari 2600 experiment (Stochastic Minimal setting) used stochastic controls, which operate as follows: at each frame (not time step), the environment accepts the agent’s action with probability , or rejects it with probability . If an action is rejected, the previous frame’s action is repeated. In our setting, the agent selects a new action every four frames; in this situation, the stochastic controls approximate a form of reaction delay. This particular setting is part of the latest Arcade Learning Environment. For our experiments we use the ALE 0.5 standard value of , and trained agents for 100 million frames.
Our second Atari 2600 experiment (Original DQN setting) was averaged over three different trials, ran for 200 million frames (instead of 100 million), defined a lost life as a termination signal, and did not use stochastic controls. This matches the experimental setting of ? (?). A full table of our results is provided in Table 1.
Our last experiment took place in the Original DQN setting. We generated a trajectory from a trained DQN agent playing an -greedy policy with . The full trajectory (up to the end of the episode) was recorded in this way. We then queried the value functions of the trained agents, including the DQN used to generate the trajectory, in order to generate Figure 4 of the main text. For clarity we report action gaps averaged according to a rolling window of length 50.
Out of the 60 games for which we report results, 5 are new when compared to the table of results provided by ? (?). These five games are identified with a in Table 1.
Recall that DQN maintains two networks in parallel: a policy network, which is used to select actions and is updated at every time step, and a target network. The target network is used to compute the error term , and is only updated every 10,000 time steps (? ?). In our experiments we also used this target network to compute the and , including the added correction term. Our operators performed worse when the correction term was instead computed from the policy network.
Parameter Selection
We used five training games (Asterix, Beam Rider, Pong, Seaquest, Space Invaders) to select the parameter for both of our operators. Specifically, we trained agents using our second experimental setup with parameters , evaluated them according to the highest score achieved, and manually selected the value which seemed to achieve the best performance. Note that corresponds to DQN in both cases. Figure 7 depicts the results of this parameter sweep.