EXPLORING UNDER-APPRECIATED REWARDS
This paper presents a novel form of policy gradient for model-free reinforcement learning (RL) with improved exploration properties. Current policy-based methods use entropy regularization to encourage undirected exploration of the reward landscape, which is ineffective in high dimensional spaces with sparse rewards. We propose a more directed exploration strategy that promotes exploration of under-appreciated reward regions. An action sequence is considered under-appreciated if its log-probability under the current policy under-estimates its resulting reward. The proposed exploration strategy is easy to implement, requiring small modifications to the REINFORCE algorithm. We evaluate the approach on a set of algorithmic tasks that have long challenged RL methods. Our approach reduces hyper-parameter sensitivity and demonstrates significant improvements over baseline methods. The proposed algorithm successfully solves a benchmark multi-digit addition task and generalizes to long sequences, which, to our knowledge, is the first time that a pure RL method has solved addition using only reward feedback.
1 INTRODUCTION
Humans can reason about symbolic objects and solve algorithmic problems. After learning to count and then manipulate numbers via simple arithmetic, people eventually learn to invent new algorithms and even reason about their correctness and efficiency. The ability to invent new algorithms is fundamental to artificial intelligence (AI). Although symbolic reasoning has a long history in AI (Russell et al., 2003), only recently have statistical machine learning and neural network approaches begun to make headway in automated algorithm discovery (Reed & de Freitas, 2016; Kaiser & Sutskever, 2016; Neelakantan et al., 2016), which would constitute an important milestone on the path to AI. Nevertheless, most of the recent successes depend on the use of strong supervision to learn a mapping from a set of training inputs to outputs by maximizing a conditional log-likelihood, very much like neural machine translation systems (Sutskever et al., 2014; Bahdanau et al., 2015). Such a dependence on strong supervision is a significant limitation that does not match the ability of people to invent new algorithmic procedures based solely on trial and error.
By contrast, reinforcement learning (RL) methods (Sutton & Barto, 1998) hold the promise of searching over discrete objects such as symbolic representations of algorithms by considering much weaker feedback in the form of a simple verifier that tests the correctness of a program execution on a given problem instance. Despite the recent excitement around the use of RL to tackle Atari games (Mnih et al., 2015) and Go (Silver et al., 2016), standard RL methods are not yet able to consistently and reliably solve algorithmic tasks in all but the simplest cases (Zaremba & Sutskever, 2014). A key property of algorithmic problems that makes them challenging for RL is reward sparsity, i.e., a policy usually has to get a long action sequence exactly right to obtain a non-zero reward.
∗Work done as a member of the Google Brain Residency program (g.co/brainresidency) †Also at the Department of Computing Science, University of Alberta, daes@ualberta.ca
We believe one of the key factors limiting the effectiveness of current RL methods in a sparse reward setting is the use of undirected exploration strategies (Thrun, 1992), such as -greedy and entropy regularization (Williams & Peng, 1991). For long action sequences with delayed sparse reward, it is hopeless to explore the space uniformly and blindly. Instead, we propose a formulation to encourage exploration of action sequences that are under-appreciated by the current policy. Our formulation considers an action sequence to be under-appreciated if the model’s log-probability assigned to an action sequence under-estimates the resulting reward from the action sequence. Exploring underappreciated states and actions encourages the policy to have a better calibration between its logprobabilities and observed reward values, even for action sequences with negligible rewards. This effectively increases exploration around neglected action sequences.
We term our proposed technique under-appreciated reward exploration (UREX). We show that the objective given by UREX is a combination of a mode seeking objective (standard REINFORCE) and a mean seeking term, which provides a well motivated trade-off between exploitation and exploration. To empirically evaluate our method, we take a set of algorithmic tasks such as sequence reversal, multi-digit addition, and binary search. We choose to focus on these tasks because, although simple, they present a difficult sparse reward setting which has limited the success of standard RL approaches. The experiments demonstrate that UREX significantly outperforms baseline RL methods, such as entropy regularized REINFORCE and one-step Q-learning, especially on the more difficult tasks, such as multi-digit addition. Moreover, UREX is shown to be more robust to changes of hyper-parameters, which makes hyper-parameter tuning less tedious in practice. In addition to introducing a new variant of policy gradient with improved performance, our paper is the first to demonstrate strong results for an RL method on algorithmic tasks. To our knowledge, the addition task has not been solved by any model-free reinforcement learning approach. We observe that some of the policies learned by UREX can successfully generalize to long sequences; e.g., in 2 out of 5 random restarts, the policy learned by UREX for the addition task correctly generalizes to addition of numbers with 2000 digits with no mistakes, even though training sequences are at most 33 digits long.
2 NEURAL NETWORKS FOR LEARNING ALGORITHMS
Although research on using neural networks to learn algorithms has witnessed a surge of recent interest, the problem of program induction from examples has a long history in many fields, including program induction, inductive logic programming (Lavrac & Dzeroski, 1994), relational learning (Kemp et al., 2007) and regular language learning (Angulin, 1987). Rather than presenting a comprehensive survey of program induction here, we focus on neural network approaches to algorithmic tasks and highlight the relative simplicity of our neural network architecture.
Most successful applications of neural networks to algorithmic tasks rely on strong supervision, where the inputs and target outputs are completely known a priori. Given a dataset of examples, one learns the network parameters by maximizing the conditional likelihood of the outputs via backpropagation (e.g., Reed & de Freitas (2016); Kaiser & Sutskever (2016); Vinyals et al. (2015)). However, target outputs may not be available for novel tasks, for which no prior algorithm is known to be available. A more desirable approach to inducing algorithms, followed in this paper, advocates using self-driven learning strategies that only receive reinforcement based on the outputs produced. Hence, just by having access to a verifier for an algorithmic problem, one can aim to learn an algorithm. For example, if one does not know how to sort an array, but can check the extent to which an array is sorted, then one can provide the reward signal necessary for learning sorting algorithms.
We formulate learning algorithms as an RL problem and make use of model-free policy gradient methods to optimize a set parameters associated with the algorithm. In this setting, the goal is to learn a policy πθ that given an observed state st at step t, estimates a distribution over the next action at, denoted πθ(at | st). Actions represent the commands within the algorithm and states represent the joint state of the algorithm and the environment. Previous work in this area has focused on augmenting a neural network with additional structure and increased capabilities (Zaremba & Sutskever, 2015; Graves et al., 2016). In contrast, we utilize a simple architecture based on a standard recurrent neural network (RNN) with LSTM cells (Hochreiter & Schmidhuber, 1997) as depicted in Figure 1. At each episode, the environment is initialized with a latent state h, unknown to the agent, which determines s1 and the subsequent state transition and reward functions. Once the agent observes s1
as the input to the RNN, the network outputs a distribution πθ(a1 | s1), from which an action a1 is sampled. This action is applied to the environment, and the agent receives a new state observation s2. The state s2 and the previous action a1 are then fed into the RNN and the process repeats until the end of the episode. Upon termination, a reward signal is received.
3 LEARNING A POLICY BY MAXIMIZING EXPECTED REWARD
We start by discussing the most common form of policy gradient, REINFORCE (Williams, 1992), and its entropy regularized variant (Williams & Peng, 1991). REINFORCE has been applied to model-free policy-based learning with neural networks and algorithmic domains (Zaremba & Sutskever, 2015; Graves et al., 2016).
The goal is to learn a policy πθ that, given an observed state st at step t, estimates a distribution over the next action at, denoted πθ(at |st). The environment is initialized with a latent vector, h, which determines the initial observed state s1 = g(h), and the transition function st+1 = f(st,at | h). Note that the use of nondeterministic transitions f as in Markov decision processes (MDP) may be recovered by assuming that h includes the random seed for the any nondeterministic functions. Given a latent state h, and s1:T ≡ (s1, . . . , sT ), the model probability of an action sequence a1:T ≡ (a1, . . . ,aT ) is expressed as,
πθ(a1:T | h) = T∏ t=1 πθ(at | st) , where s1 = g(h), st+1 = f(st,at | h) for 1 ≤ t < T .
The environment provides a reward at the end of the episode, denoted r(a1:T | h). For ease of readability we drop the subscript from a1:T and simply write πθ(a | h) and r(a | h). The objective used to optimize the policy parameters, θ, consists of maximizing expected reward under actions drawn from the policy, plus an optional maximum entropy regularizer. Given a distribution over initial latent environment states p(h), we express the regularized expected reward as,
ORL(θ; τ) = Eh∼p(h) {∑
a∈A πθ(a | h)
[ r(a | h)− τ log πθ(a | h) ]} . (1)
When πθ is a non-linear function defined by a neural network, finding the global optimum of θ is challenging, and one often resorts to gradient-based methods to find a local optimum of ORL(θ; τ). Given that ddθπθ(a) = πθ(a) d dθ log πθ(a) for any a such that πθ(a) > 0, one can verify that,
d
dθ ORL(θ; τ | h) = ∑ a∈A πθ(a | h) d dθ log πθ(a | h) [ r(a | h)− τ log πθ(a | h)− τ ] . (2)
Because the space of possible actionsA is large, enumerating over all of the actions to compute this gradient is infeasible. Williams (1992) proposed to compute the stochastic gradient of the expected
reward by using Monte Carlo samples. Using Monte Carlo samples, one first drawsN i.i.d. samples from the latent environment states {h(n)}Nn=1, and then draws K i.i.d. samples {a(k)}Kk=1 from πθ(a | h(n)) to approximate the gradient of (1) by using (2) as,
d
dθ ORL(θ; τ) ≈
1
NK N∑ n=1 K∑ k=1 d dθ log πθ(a (k) | h(n)) [ r(a(k) | h(n))− τ log πθ(a(k) | h(n))− τ ] .
(3) This reparametrization of the gradients is the key to the REINFORCE algorithm. To reduce the variance of (3), one uses rewards r̂ that are shifted by some offset values,
r̂ (a(k) | h) = r(a(k) | h)− b(h) , (4) where b is known as a baseline or sometimes called a critic. Note that subtracting any offset from the rewards in (1) simply results in shifting the objective ORL by a constant. Unfortunately, directly maximizing expected reward (i.e., when τ = 0) is prone to getting trapped in a local optimum. To combat this tendency, Williams & Peng (1991) augmented the expected reward objective by including a maximum entropy regularizer (τ > 0) to promote greater exploration. We will refer to this variant of REINFORCE as MENT (maximum entropy exploration).
4 UNDER-APPRECIATED REWARD EXPLORATION (UREX)
To explain our novel form of policy gradient, we first note that the optimal policy π∗τ , which globally maximizes ORL(θ; τ | h) in (1) for any τ > 0, can be expressed as,
π∗τ (a | h) = 1
Z(h) exp {1 τ r(a | h) } , (5)
where Z(h) is a normalization constant making π∗τ a distribution over the space of action sequences A. One can verify this by first acknowledging that,
ORL(θ; τ | h) = −τ DKL (πθ(· | h) ‖ π∗τ (· | h)) . (6) Since DKL (p ‖ q) is non-negative and zero iff p = q, then π∗τ defined in (5) maximizes ORL. That said, given a particular form of πθ, finding θ that exactly characterizes π∗τ may not be feasible.
The KL divergence DKL (πθ ‖ π∗τ ) is known to be mode seeking (Murphy, 2012, Section 21.2.2) even with entropy regularization (τ > 0). Learning a policy by optimizing this direction of the KL is prone to falling into a local optimum resulting in a sub-optimal policy that omits some of the modes of π∗τ . Although entropy regularization helps mitigate the issues as confirmed in our experiments, it is not an effective exploration strategy as it is undirected and requires a small regularization coefficient τ to avoid too much random exploration. Instead, we propose a directed exploration strategy that improves the mean seeking behavior of policy gradient in a principled way.
We start by considering the alternate mean seeking direction of the KL divergence, DKL (π∗τ ‖ πθ). Norouzi et al. (2016) considered this direction of the KL to directly learn a policy by optimizing
ORAML(θ; τ) = Eh∼p(h) { τ ∑ a∈A π∗τ (a | h) log πθ(a | h) } , (7)
for structured prediction. This objective has the same optimal solution π∗τ as ORL since, ORAML(θ; τ | h) = −τ DKL (π∗τ (· | h) ‖ πθ(· | h)) + const . (8)
Norouzi et al. (2016) argue that in some structured prediction problems when one can draw samples from π∗τ , optimizing (7) is more effective than (1), since no sampling from a non-stationary policy πθ is required. If πθ is a log-linear model of a set of features,ORAML is convex in θ whereasORL is not, even in the log-linear case. Unfortunately, in scenarios that the reward landscape is unknown or computing the normalization constant Z(h) is intractable, sampling from π∗τ is not straightforward.
In RL problems, the reward landscape is completely unknown, hence sampling from π∗τ is intractable. This paper proposes to approximate the expectation with respect to π∗τ by using selfnormalized importance sampling (Owen, 2013), where the proposal distribution is πθ and the reference distribution is π∗τ . For importance sampling, one draws K i.i.d. samples {a(k)}Kk=1 from
πθ(a | h) and computes a set of normalized importance weights to approximate ORAML(θ; τ | h) as,
ORAML(θ; τ | h) ≈ τ K∑ k=1 wτ (a (k) | h)∑K m=1 wτ (a (m) | h) log πθ(a (k) | h) , (9)
where wτ (a(k) | h) ∝ π∗τ/πθ denotes an importance weight defined by,
wτ (a (k) | h) = exp {1 τ r(a(k) | h)− log πθ(a(k) | h) } . (10)
One can view these importance weights as evaluating the discrepancy between scaled rewards r/τ and the policy’s log-probabilities log πθ. Among the K samples, a sample that is least appreciated by the model, i.e., has the largest r/τ − log πθ, receives the largest positive feedback in (9). In practice, we have found that just using the importance sampling RAML objective in (9) does not always yield promising solutions. Particularly, at the beginning of training, when πθ is still far away from π∗τ , the variance of importance weights is too large, and the self-normalized importance sampling procedure results in poor approximations. To stabilize early phases of training and ensure that the model distribution πθ achieves large expected reward scores, we combine the expected reward and RAML objectives to benefit from the best of their mode and mean seeking behaviors. Accordingly, we propose the following objective that we call under-appreciated reward exploration (UREX),
OUREX(θ; τ) = Eh∼p(h) {∑
a∈A
[ πθ(a | h) r(a | h) + τ π∗τ (a | h) log πθ(a | h) ]} , (11)
which is the sum of the expected reward and RAML objectives. In our preliminary experiments, we considered a composite objective of ORL + ORAML, but we found that removing the entropy term is beneficial. Hence, theOUREX objective does not include entropy regularization. Accordingly, the optimum policy for OUREX is no longer π∗τ , as it was for ORL and ORAML. Appendix A derives the optimal policy for OUREX as a function of the optimal policy for ORL. We find that the optimal policy of UREX is more sharply concentrated on the high reward regions of the action space, which may be an advantage for UREX, but we leave more analysis of this behavior to future work.
To compute the gradient ofOUREX(θ; τ), we use the self-normalized importance sampling estimate outlined in (9). We assume that the importance weights are constant and contribute no gradient to d dθOUREX(θ; τ). To approximate the gradient, one draws N i.i.d. samples from the latent environment states {h(n)}Nn=1, and then draws K i.i.d. samples {a(k)}Kk=1 from πθ(a |h (n)) to obtain
d
dθ OUREX(θ; τ) ≈
1
N N∑ n=1 K∑ k=1 d dθ log πθ(a (k) |h(n)) [ 1 K r̂ (a(k) | h(n))+τ wτ (a (k) |h(n))∑K m=1wτ (a (m) |h(n)) ] .
(12) As with REINFORCE, the rewards are shifted by an offset b(h). In this gradient, the model logprobability of a sample action sequence a(k) is reinforced if the corresponding reward is large, or the corresponding importance weights are large, meaning that the action sequence is under-appreciated. The normalized importance weights are computed using a softmax operator softmax(r/τ − log πθ).
5 RELATED WORK
Before presenting the experimental results, we briefly review some pieces of previous work that closely relate to the UREX approach.
Reward-Weighted Regression. Both RAML and UREX objectives bear some similarity to a method in continuous control known as Reward-Weighted Regression (RWR) (Peters & Schaal, 2007; Wierstra et al., 2008). Using our notation, the RWR objective is expressed as,
ORWR(θ; τ | h) = log ∑ a∈A π∗τ (a | h)πθ(a | h) (13)
≥ ∑ a∈A q(a | h) log π ∗ τ (a | h)πθ(a | h) q(a | h) . (14)
To optimize ORWR, Peters & Schaal (2007) propose a technique inspired by the EM algorithm to maximize a variational lower bound in (14) based on a variational distribution q(a | h). The RWR objective can be interpreted as a log of the correlation between π∗τ and πθ. By contrast, the RAML and UREX objectives are both based on a KL divergence between π∗τ and πθ.
To optimize the RWR objective, one formulates the gradient as, d
dθ ORWR(θ; τ | h) = ∑ a∈A π∗τ (a | h)πθ(a | h) C d dθ log πθ(a | h), (15)
where C denotes the normalization factor, i.e., C = ∑
a∈A π ∗ τ (a | h)πθ(a | h). The expectation
with respect to π∗τ (a | h)πθ(a | h)/C on the RHS can be approximated by self-normalized importance sampling,1 where the proposal distribution is πθ. Accordingly, one draws K Monte Carlo samples {a(k)}Kk=1 i.i.d. from πθ(a |h) and formulates the gradient as,
d
dθ ORWR(θ; τ | h) ≈
1
K K∑ k=1 u(a(k) | h)∑K m=1 u(a (m) | h) d dθ log πθ(a (k) | h), (16)
where u(a(k) | h) = exp{ 1τ r(a (k) | h)}. There is some similarity between (16) and (9) in that they both use self-normalized importance sampling, but note the critical difference that (16) and (9) estimate the gradients of two different objectives, and hence the importance weights in (16) do not correct for the sampling distribution πθ(a |h) as opposed to (9). Beyond important technical differences, the optimal policy of ORWR is a one hot distribution with all probability mass concentrated on an action sequence with maximal reward, whereas the optimal policies for RAML and UREX are everywhere nonzero, with the probability of different action sequences being assigned proportionally to their exponentiated reward (with UREX introducing an additional re-scaling; see Appendix A). Further, the notion of under-appreciated reward exploration evident in OUREX, which is key to UREX’s performance, is missing in the RWR formulation. Exploration. The RL literature contains many different attempts at incorporating exploration that may be compared with our method. The most common exploration strategy considered in valuebased RL is -greedy Q-learning, where at each step the agent either takes the best action according to its current value approximation or with probability takes an action sampled uniformly at random. Like entropy regularization, such an approach applies undirected exploration, but it has achieved recent success in game playing environments (Mnih et al., 2013; Van Hasselt et al., 2016; Mnih et al., 2016).
Prominent approaches to improving exploration beyond -greedy in value-based or model-based RL have focused on reducing uncertainty by prioritizing exploration toward states and actions where the agent knows the least. This basic intuition underlies work on counter and recency methods (Thrun, 1992), exploration methods based on uncertainty estimates of values (Kaelbling, 1993; Tokic, 2010), methods that prioritize learning environment dynamics (Kearns & Singh, 2002; Stadie et al., 2015), and methods that provide an intrinsic motivation or curiosity bonus for exploring unknown states (Schmidhuber, 2006; Bellemare et al., 2016).
In contrast to value-based methods, exploration for policy-based RL methods is often a by-product of the optimization algorithm itself. Since algorithms like REINFORCE and Thompson sampling choose actions according to a stochastic policy, sub-optimal actions are chosen with some non-zero probability. The Q-learning algorithm may also be modified to sample an action from the softmax of the Q values rather than the argmax (Sutton & Barto, 1998).
Asynchronous training has also been reported to have an exploration effect on both value- and policy-based methods. Mnih et al. (2016) report that asynchronous training can stabilize training by reducing the bias experienced by a single trainer. By using multiple separate trainers, an agent is less likely to become trapped at a policy found to be locally optimal only due to local conditions. In the same spirit, Osband et al. (2016) use multiple Q value approximators and sample only one to act for each episode as a way to implicitly incorporate exploration.
By relating the concepts of value and policy in RL, the exploration strategy we propose tries to bridge the discrepancy between the two. In particular, UREX can be viewed as a hybrid combination of value-based and policy-based exploration strategies that attempts to capture the benefits of each.
1Bornschein & Bengio (2014) apply the same trick to optimize the log-likelihood of latent variable models.
Per-step Reward. Finally, while we restrict ourselves to episodic settings where a reward is associated with an entire episode of states and actions, much work has been done to take advantage of environments that provide per-step rewards. These include policy-based methods such as actor-critic (Mnih et al., 2016; Schulman et al., 2016) and value-based approaches based on Qlearning (Van Hasselt et al., 2016; Schaul et al., 2016). Some of these value-based methods have proposed a softening of Q-values which can be interpreted as adding a form of maximum-entropy regularizer (Asadi & Littman, 2016; Azar et al., 2012; Fox et al., 2016; Ziebart, 2010). The episodic total-reward setting that we consider is naturally harder since the credit assignment to individual actions within an episode is unclear.
6 SIX ALGORITHMIC TASKS
We assess the effectiveness of the proposed approach on five algorithmic tasks from the OpenAI Gym (Brockman et al., 2016), as well as a new binary search problem. Each task is summarized below, with further details available on the Gym website2 or in the corresponding open-source code.3 In each case, the environment has a hidden tape and a hidden sequence. The agent observes the sequence via a pointer to a single character, which can be moved by a set of pointer control actions. Thus an action at is represented as a tuple (m,w, o) where m denotes how to move, w is a boolean denoting whether to write, and o is the output symbol to write.
1. Copy: The agent should emit a copy of the sequence. The pointer actions are move left and right. 2. DuplicatedInput: In the hidden tape, each character is repeated twice. The agent must dedupli-
cate the sequence and emit every other character. The pointer actions are move left and right.
3. RepeatCopy: The agent should emit the hidden sequence once, then emit the sequence in the reverse order, then emit the original sequence again. The pointer actions are move left and right.
4. Reverse: The agent should emit the hidden sequence in the reverse order. As before, the pointer actions are move left and right.
5. ReversedAddition: The hidden tape is a 2×n grid of digits representing two numbers in base 3 in little-endian order. The agent must emit the sum of the two numbers, in little-endian order. The allowed pointer actions are move left, right, up, or down.
The OpenAI Gym provides an additional harder task called ReversedAddition3, which involves adding three numbers. We omit this task, since none of the methods make much progress on it.
For these tasks, the input sequences encountered during training range from a length of 2 to 33 characters. A reward of 1 is given for each correct emission. On an incorrect emission, a small penalty of−0.5 is incurred and the episode is terminated. The agent is also terminated and penalized with a reward of −1 if the episode exceeds a certain number of steps. For the experiments using UREX and MENT, we associate an episodic sequence of actions with the total reward, defined as the sum of the per-step rewards. The experiments using Q-learning, on the other hand, used the per-step rewards. Each of the Gym tasks has a success threshold, which determines the required average reward over 100 episodes for the agent to be considered successful.
We also conduct experiments on an additional algorithmic task described below: 6. BinarySearch: Given an integer n, the environment has a hidden array of n distinct numbers
stored in ascending order. The environment also has a query number x unknown to the agent that is contained somewhere in the array. The goal of the agent is to find the query number in the array in a small number of actions. The environment has three integer registers initialized at (n, 0, 0). At each step, the agent can interact with the environment via the four following actions: • INC(i): increment the value of the register i for i ∈ {1, 2, 3}. • DIV(i): divide the value of the register i by 2 for i ∈ {1, 2, 3}. • AVG(i): replace the value of the register i with the average of the two other registers. • CMP(i): compare the value of the register i with x and receive a signal indicating which
value is greater. The agent succeeds when it calls CMP on an array cell holding the value x.
2gym.openai.com 3github.com/openai/gym
We set the maximum number of steps to 2n+1 to allow the agent to perform a full linear search. A policy performing full linear search achieves an average reward of 5, because x is chosen uniformly at random from the elements of the array. A policy employing binary search can find the number x in at most 2 log2 n + 1 steps. If n is selected uniformly at random from the range 32 ≤ n ≤ 512, binary search yields an optimal average reward above 9.55. We set the success threshold for this task to an average reward of 9.
7 EXPERIMENTS
We compare our policy gradient method using under-appreciated reward exploration (UREX) against two main RL baselines: (1) REINFORCE with entropy regularization termed MENT (Williams & Peng, 1991), where the value of τ determines the degree of regularization. When τ = 0, standard REINFORCE is obtained. (2) one-step double Q-learning based on bootstrapping one step future rewards.
7.1 ROBUSTNESS TO HYPER-PARAMETERS
Hyper-parameter tuning is often tedious for RL algorithms. We found that the proposed UREX method significantly improves robustness to changes in hyper-parameters when compared to MENT. For our experiments, we perform a careful grid search over a set of hyper-parameters for both MENT and UREX. For any hyper-parameter setting, we run the MENT and UREX methods 5 times with different random restarts. We explore the following main hyper-parameters:
• The learning rate denoted η chosen from a set of 3 possible values η ∈ {0.1, 0.01, 0.001}. • The maximum L2 norm of the gradients, beyond which the gradients are clipped. This parame-
ter, denoted c, matters for training RNNs. The value of c is selected from c ∈ {1, 10, 40, 100}. • The temperature parameter τ that controls the degree of exploration for both MENT and UREX.
For MENT, we use τ ∈ {0, 0.005, 0.01, 0.1}. For UREX, we only consider τ = 0.1, which consistently performs well across the tasks.
In all of the experiments, both MENT and UREX are treated exactly the same. In fact, the change of implementation is just a few lines of code. Given a value of τ , for each task, we run 60 training jobs comprising 3 learning rates, 4 clipping values, and 5 random restarts. We run each algorithm for a maximum number of steps determined based on the difficulty of the task. The training jobs for Copy, DuplicatedInput, RepeatCopy, Reverse, ReversedAddition, and BinarySearch are run for 2K, 500, 50K, 5K, 50K, and 2K stochastic gradient steps, respectively. We find that running a trainer job longer does not result in a better performance. Our policy network comprises a single LSTM layer with 128 nodes. We use the Adam optimizer (Kingma & Ba, 2015) for the experiments.
Table 1 shows the percentage of 60 trials on different hyper-parameters (η, c) and random restarts which successfully solve each of the algorithmic tasks. It is clear that UREX is more robust than
MENT to changes in hyper-parameters, even though we only report the results of UREX for a single temperature. See Appendix B for more detailed tables on hyper-parameter robustness.
7.2 RESULTS
Table 2 presents the number of successful attempts (out of 5 random restarts) and the expected reward values (averaged over 5 trials) for each RL algorithm given the best hyper-parameters. Onestep Q-learning results are also included in the table. We also present the training curves for MENT and UREX in Figure 2. It is clear that UREX outperforms the baselines on these tasks. On the more difficult tasks, such as Reverse and ReverseAddition, UREX is able to consistently find an appropriate algorithm, but MENT and Q-learning fall behind. Importantly, for the BinarySearch task, which exhibits many local maxima and necessitates smart exploration, UREX is the only method that can solve it consistently. The Q-learning baseline solves some of the simple tasks, but it makes little headway on the harder tasks. We believe that entropy regularization for policy gradient and - greedy for Q-learning are relatively weak exploration strategies in long episodic tasks with delayed rewards. On such tasks, one random exploratory step in the wrong direction can take the agent off the optimal policy, hampering its ability to learn. In contrast, UREX provides a form of adaptive and smart exploration. In fact, we observe that the variance of the importance weights decreases as the agent approaches the optimal policy, effectively reducing exploration when it is no longer necessary; see Appendix E.
7.3 GENERALIZATION TO LONGER SEQUENCES
To confirm whether our method is able to find the correct algorithm for multi-digit addition, we investigate its generalization to longer input sequences than provided during training. We evaluate the trained models on inputs up to a length of 2000 digits, even though training sequences were at most 33 characters. For each length, we test the model on 100 randomly generated inputs, stopping when the accuracy falls below 100%. Out of the 60 models trained on addition with UREX, we find that 5 models generalize to numbers up to 2000 digits without any observed mistakes. On the best UREX hyper-parameters, 2 out of the 5 random restarts are able to generalize successfully. For more detailed results on the generalization performance on 3 different tasks including Copy,
DuplicatedInput, and ReversedAddition, see Appendix C. During these evaluations, we take the action with largest probability from πθ(a | h) at each time step rather than sampling randomly. We also looked into the generalization of the models trained on the BinarySearch task. We found that none of the agents perform proper binary search. Rather, those that solved the task perform a hybrid of binary and linear search: first actions follow a binary search pattern, but then the agent switches to a linear search procedure once it narrows down the search space; see Appendix D for some execution traces for BinarySearch and ReversedAddition. Thus, on longer input sequences, the agent’s running time complexity approaches linear rather than logarithmic. We hope that future work will make more progress on this task. This task is especially interesting because the reward signal should incorporate both correctness and efficiency of the algorithm.
7.4 IMPLEMENTATION DETAILS
In all of the experiments, we make use of curriculum learning. The environment begins by only providing small inputs and moves on to longer sequences once the agent achieves close to maximal reward over a number of steps. For policy gradient methods including MENT and UREX, we only provide the agent with a reward at the end of the episode, and there is no notion of intermediate reward. For the value-based baseline, we implement one-step Q-learning as described in Mnih et al. (2016)-Alg. 1, employing double Q-learning with -greedy exploration. We use the same RNN in our policy-based approaches to estimate the Q values. A grid search over exploration rate, exploration rate decay, learning rate, and sync frequency (between online and target network) is conducted to find the best hyper-parameters. Unlike our other methods, the Q-learning baseline uses intermediate rewards, as given by the OpenAI Gym on a per-step basis. Hence, the Q-learning baseline has a slight advantage over the policy gradient methods.
In all of the tasks except Copy, our stochastic optimizer uses mini-batches comprising 400 policy samples from the model. These 400 samples correspond to 40 different random sequences drawn from the environment, and 10 random policy trajectories per sequence. In other words, we set K = 10 and N = 40 as defined in (3) and (12). For MENT, we use the 10 samples to subtract the mean of the coefficient of ddθ log πθ(a | h) which includes the contribution of the reward and entropy regularization. For UREX, we use the 10 trajectories to subtract the mean reward and normalize the importance sampling weights. We do not subtract the mean of the normalized importance weights. For the Copy task, we use mini-batches with 200 samples using K = 10 and N = 20. Experiments are conducted using Tensorflow (Abadi et al., 2016).
8 CONCLUSION
We present a variant of policy gradient, called UREX, which promotes the exploration of action sequences that yield rewards larger than what the model expects. This exploration strategy is the result of importance sampling from the optimal policy. Our experimental results demonstrate that UREX significantly outperforms other value and policy based methods, while being more robust
to changes of hyper-parameters. By using UREX, we can solve algorithmic tasks like multi-digit addition from only episodic reward, which other methods cannot reliably solve even given the best hyper-parameters. We introduce a new algorithmic task based on binary search to advocate more research in this area, especially when the computational complexity of the solution is also of interest. Solving these tasks is not only important for developing more human-like intelligence in learning algorithms, but also important for generic reinforcement learning, where smart and efficient exploration is the key to successful methods.
9 ACKNOWLEDGMENT
We thank Sergey Levine, Irwan Bello, Corey Lynch, George Tucker, Kelvin Xu, Volodymyr Mnih, and the Google Brain team for insightful comments and discussions.
A OPTIMAL POLICY FOR THE UREX OBJECTIVE
To derive the form of the optimal policy for the UREX objective (11), note that for each h one would like to maximize ∑
a∈A
[ πθ(a) r(a) + τ π ∗ τ (a) log πθ(a) ] , (17)
subject to the constraint ∑
a∈A πθ(a) = 1. To enforce the constraint, we introduce a Lagrange multiplier α and aim to maximize∑
a∈A
[ πθ(a) r(a) + τ π ∗ τ (a) log πθ(a)− απθ(a) ] + α . (18)
Since the gradient of the Lagrangian (18) with respect to θ is given by∑ a∈A dπθ(a) dθ [ r(a) + τ π∗τ (a) πθ(a) − α ] , (19)
the optimal choice for πθ is achieved by setting
πθ(a) = τ π∗τ (a)
α− r(a) for all a ∈ A , (20)
forcing the gradient to be zero. The Lagrange multiplier α can then be chosen so that ∑
a∈A πθ(a) = 1 while also satisfying α > maxa∈A r(a); see e.g. (Golub, 1987).
B ROBUSTNESS TO HYPER-PARAMETERS
Tables 3–8 provide more details on different cells of Table 1. Each table presents the results of MENT using the best temperature τ vs. UREX with τ = 0.1 on a variety of learning rates and clipping values. Each cell is the number of trials out of 5 random restarts that succeed at solving the task using a specific η and c.
C GENERALIZATION TO LONGER SEQUENCES
Table 9 provides a more detailed look into the generalization performance of the trained models on Copy, DuplicatedInput, and ReversedAddition. The tables show how the number of models which can solve the task correctly drops off as the length of the input increases.
D EXAMPLE EXECUTION TRACES
We provide the traces of two trained agents on the ReversedAddition task (Figure 3) and the BinarySearch task (Table 10).
E VARIANCE OF IMPORTANCE WEIGHTS
F A SIMPLE BANDIT TASK
overview:
This work proposes to link trajectory log-probabilities and rewards by defining under-appreciated rewards. This suggests that there is a linear relationship between trajectory rewards and their log-probability which can be exploited by measuring the resulting mismatch.
That is, when an action sequence under-appreciates its reward, its log-probability is increased.
This method is a simple modification to the well-known REINFORCE method, requiring only one extra hyperparameter \tau, and intuitively provides us with a better exploration mechanism than \epsilon-greedy or random exploration.
The method is tested on algorithmic environments, and compared to entropy-regularized REINFORCE and double Q-learning, and performs equally or better than those two baselines, especially in more complex environments.
remarks:
- the focus in the introduction on algorithmic tasks may be a double-edged sword. It is an interesting domain to test your hypothesis and benchmark your method. At the same time, it distracts the reader from the (IMO) generality of the proposed method.
- in the introduction you say the reward is sparse, in section 6, on tasks 1-5, you then say there is a reward at each correct emission, i.e. each time step. This is only 'corrected' to end-of-episode-reward in section 7.4, after having discussed results. I'd move or mention this in section 6.
- approach seems quite sensible to tau being in the same range as logpi(a|h), but you only try tau=0.1 for UREX. I'm not sure I understand nor agree with this experimentation choice.
- an alternative to grid search is random search (Bergstra&Bengio, 2012). It may illustrate better hyperparameter robustness, and allow you to explore more in the same number of experiment.
opinion:
- An interesting approach to policy-gradient, to be sure. It tackles the very important question of "how should agents explore?"
- I'm ambivalent to claiming that an algorithm is robust to hyperparmeters simply because it performs better on the selected hyperparameter range. All you really show is that it performs well some amount of time when the hyperparams lay in that range. Couldn't it be that MENT needs different hyperparameters? (Just being devil's advocate here)
- I see why matching 1/tau with logpi is the obvious choice, but it implies a very strong prior: that the reward (to a factor of 1/tau) lies in the same space as the log policy. One point of failure I see (but correct me if I'm wrong) is that as the length of the trajectory grows the reward is expected to grow linearly, so short ways to get some reward will be less explored than long ways of getting the same reward, creating an imbalance unless the reward is shaped such that shorter trajectories get more reward (which is only the case in task 6).
- It might have been good to also compare with methods explicitly trying to explore better with value-functions (e.g. prioritized experience replay, Schaul et al 2015)
- At the risk of repeating myself, tau plays a major role in this method, but there is little analysis on its effect on experiments.
The methodology and reasoning is clearly explained and I think this paper communicates its message very well.
That message is novel, albeit a minor modification to a well-known algorithm, it is well motivated and, I think, a welcome addition to literature concerning exploration in RL.
The experiments are chosen accordingly, and results seem to reflect the hypothesis of the authors.
I realize the tyranny of extensive experimentation and the scarcity of time, but I do think that this paper would benefit from more (or cleverer) experimentation, as well as demonstrating more explicitly the impact of the method on exploration.
Reading this paper convinced me that measuring mismatch between a trajectory's observed reward and its probability given the current policy is a clever (and well motivated) thing to do. Yet, I think that the paper could have a more convincing empirical argument, even if it is for toy tasks.