{'fraction_non_alphanumeric': 0.04043434952101037, 'fraction_numerical': 0.010034802070907681, 'mean_word_length': 4.449902821526707, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
DisCor: Corrective Feedback in Reinforcement Learning via Distribution Correction

Deep reinforcement learning can learn effective policies for a wide range of tasks, but is notoriously difficult to use due to instability and sensitivity to hyperparameters. The reasons for this remain unclear. When using standard supervised methods (e.g., for bandits), on-policy data collection provides"hard negatives"that correct the model in precisely those states and actions that the policy is likely to visit. We call this phenomenon"corrective feedback."We show that bootstrapping-based Q-learning algorithms do not necessarily benefit from this corrective feedback, and training on the experience collected by the algorithm is not sufficient to correct errors in the Q-function. In fact, Q-learning and related methods can exhibit pathological interactions between the distribution of experience collected by the agent and the policy induced by training on that experience, leading to potential instability, sub-optimal convergence, and poor results when learning from noisy, sparse or delayed rewards. We demonstrate the existence of this problem, both theoretically and empirically. We then show that a specific correction to the data distribution can mitigate this issue. Based on these observations, we propose a new algorithm, DisCor, which computes an approximation to this optimal distribution and uses it to re-weight the transitions used for training, resulting in substantial improvements in a range of challenging RL settings, such as multi-task learning and learning from noisy reward signals. Blog post presenting a summary of this work is available at: https://bair.berkeley.edu/blog/2020/03/16/discor/.


Introduction
Reinforcement learning (RL) algorithms, when combined with high-capacity deep neural net function approximators, have shown promise in domains ranging from robotic manipulation [1] to recommender systems [2]. However, current deep RL methods can be difficult to use, due to sensitivity with respect to hyperparameters and inconsistent and unstable convergence. While a number of hypotheses have been proposed to understand these issues [3,4,5,6], and gradual improvements have led to more powerful algorithms in recent years [7,8], an effective solution has proven elusive. We hypothesize that a major source of instability in reinforcement learning with function approximation and value function estimation, such as Q-learning [9,10,11] and actor-critic algorithms [12,13], is a pathological interaction between the data distribution induced by the latest policy, and the errors induced in the learned approximate value function as a consequence of training on this distribution, which then exacerbates the issues for the data distribution at the next iteration.
While a number of prior works have provided a theoretical examination of various approximation dynamic programming (ADP) methods -which encompasses Q-learning and actor-critic algorithms -prior work has not extensively studied the relationship between the data distribution induced by the latest value function, and the errors in the future value functions obtained by training on this data.
When using supervised learning to train a model, as in the case of contextual bandits or model-based RL, using the resulting model to select the most optimal actions results in a kind of "hard negative" mining: the model collects precisely those transitions that lead to good outcomes according to the model (potentially erroneously). This results in collecting precisely the data needed to fix those errors and improve. We refer to this as "corrective feedback." We argue that ADP algorithms (e.g., Q-learning and actor-critic), which use bootstrapped targets rather than ground-truth labels, often do not enjoy this sort of corrective feedback. Since they regress onto bootstrapped estimates of the current value function, rather than the true optimal value function (which is unknown), simply visiting states with high error and updating the value function at those states does not necessarily correct those errors, since errors in the target value might be due to upstream errors in other states that are visited less often. This absence of corrective feedback can result in severe detrimental consequences on performance.
We demonstrate that naïvely training a value function on transitions collected either by the latest policy or a mixture of recent policies (i.e., with replay buffers) may not result in corrective feedback. In fact, in some cases, it can actually lead to increasing accumulation of errors, which can lead to poor performance even on simple tabular MDPs. We then show how to address this issue by re-weighting the data buffer using a distribution that explicitly optimizes for corrective feedback, which gives rise to our proposed algorithm, DisCor.
The two main contributions of our work consist of an analysis showing that ADP methods may not benefit from corrective feedback, even with online data collection, as well as a proposed solution to this problem based on estimating target value error and resampling the replay buffer to mitigate error accumulation. Our method, DisCor, is general and can be used in conjunction with most modern ADP-based deep RL algorithms, such as DQN [11] and SAC [7]. Our experiments show that DisCor substantially improves performance of standard RL methods, especially in challenging settings, such as multi-task RL and learning from noisy rewards. We evaluate our approach on both continuous control tasks and discrete-action Atari games. On the multi-task MT10 benchmark [14] and several robotic manipulation tasks, our method learns policies with a final success rate that is 50% higher than that of SAC.

Preliminaries
The goal in reinforcement learning is to learn a policy that maximizes the expected cumulative discounted reward in a Markov decision process (MDP), which is defined by a tuple (S, A, T, R, γ). S, A represent state and action spaces, T (s |s, a) and r(s, a) represent the dynamics and reward function, and γ ∈ (0, 1) represents the discount factor. ρ 0 (s) is the initial state distribution. The infinite-horizon, discounted marginal state distribution of the policy π(a|s) is denoted as d π (s) and the corresponding state-action marginal is d π (s, a) = d π (s)π(a|s).
Approximate dynamic programming (ADP) algorithms, such as Q-learning and actor-critic methods, aim to acquire the optimal policy by modeling the optimal state (V * (s)) and state-action (Q * (s, a)) value functions. These algorithms are based on recursively iterating the Bellman optimality operator, B * , defined as The goal is to converge to the optimal value function, Q * , by applying successive Bellman projections. With function approximation, these algorithms project the values of the Bellman optimality operator B * onto a family of Q-function approximators Q (e.g., deep neural nets) under a sampling or data distribution µ, such that Q k+1 ← Π µ (B * Q k ) and Π µ (Q) We refer to B * Q as the target value for the projection step. Q-function fitting is usually interleaved with additional data collection, which typically uses a policy derived from the latest value function, augmented with either -greedy [11] or Boltzmann-style [7] exploration. To simplify analysis, we mainly consider an underlying RL algorithm (Appendix C, Algorithm 2) that alternates between fitting the action-value function, Q(s, a), fully with the current data by minimizing Bellman error, and then collecting data with the policy derived from this value function. This corresponds to fitted Q-iteration. For commonly used ADP methods, µ simply corresponds to the on-policy state-action marginal, µ k = d π k (at iteration k) or else a "replay buffer" [7,11,15] formed as a mixture distribution over all past policies, such that µ k = k i=1 d πi . However, as we will show in this paper, the choice of the sampling distribution µ is of crucial importance for the stability and efficiency of ADP algorithms, and that many commonly-used choices of this distribution can lead to convergence to sub-optimal solutions, even with online data collection. We analyze this issue in Section 3, and then discuss a potential solution to this problem in Section 5.

Corrective Feedback in Q-Learning
In this paper, we study how the policies induced by value functions learned via ADP result in data distributions that can fail to correct systematic errors in those value functions, in contrast to non-bootstrapped methods (e.g., supervised learning of models). That is, ADP methods lack "corrective feedback." To define corrective feedback intuitively and formally, we start with a contextual bandit example, where the goal is to learn the optimal stateaction value function Q * (s, a) which, for a bandit, is equal to the reward r(s, a) for performing action a in state s. At iteration k, the algorithm minimizes the estimation error of the Q-function: E s∼β(s),a∼π k (a|s) [|Q k (s, a) − Q * (s, a)|]. Using a greedy or Boltzmann policy π k (a|s) to collect data for training Q k+1 leads the agent to choose actions a with over-optimistic Q k (s, a) values at a state s, and observe the corresponding true Q * (s, a) values as a result. Minimizing this estimation error then leads to the errors being corrected, as Q k (s, a) is pushed closer to match the true Q * (s, a) for actions a with incorrectly high Q-values. This constructive interaction between online data collection and error correction is what we refer to as corrective feedback.
In contrast, as we will observe shortly, ADP methods that employ bootstrapped target values do not necessarily benefit from such corrective feedback, and therefore can converge to suboptimal solutions. Because value functions are trained with target values computed by applying the Bellman backup on the previous learned Q-function, rather than the true optimal Q * , errors in the previous Q-function at the states that serve as backup targets can result in incorrect Q-value targets at the current state. In this case, no matter how often the current transition is observed, the error at this transition is not corrected. Since ADP algorithms typically use data collected using past Q-functions for training, thus coupling the data distribution to the learned value function, this issue can make them unable to correct target value errors.
As shown in Figure 1 (experiment setup described at the end of Section 2), state visitation frequencies of the latest policy in an ADP algorithm can often correlate positively with increasing error, suggesting that visiting a state can actually increase error at that state, in contrast to supervised learning in bandit problems, where this correlation is either negative (i.e., the error decreases) or 0.

Visitation and Error Correction
Bandit ADP Figure 1: Left: Return attained by with direct supervised learning of values in a bandit problem ("Bandit") and with bootstrapped targets ("ADP") on a simple tabular MDP. Right: Cosine similarity between per-iteration error increase E k+1 − E k and the policy's state visitation frequency d π k for the two training runs. The ADP run performs poorly, and exhibits a positive cosine similarity for prolonged periods during training, suggesting that the policy visitation at least at some states correlates with an increase in error. With ground truth targets ("Bandit"), this quantity is negative until convergence (around iteration 25), and then fluctuates around 0, suggesting that this approach does benefit from corrective feedback.
Thus, naïvely coupling the choice of data distribution µ and the Q function being optimized, by sampling uniformly from a replay buffer collected by policies corresponding to prior Q-functions [11], or even just sampling from data collected by the latest policy, can cause an absence of corrective feedback. As we will show in Section 3.2, this can lead to several detrimental effects such as sub-optimal convergence, instability, and slow learning progress. To theoretically analyze the lack of corrective feedback, we first define error against the optimal value function as follows: The value error is defined as the expected absolute error to the optimal Q-function Q * weighted under the corresponding on-policy (π k ) state-action marginal, d π k : A smooth decrease in the value error E k indicates that the algorithm is effectively correcting errors in the Q-function. If E k fluctuates or increases, the algorithm may be making poor learning progress. When the value error E k is roughly stagnant at a non-zero value, this may indicate premature, sub-optimal convergence, provided that the function approximator class is able to support lower-error solutions (which is typically the case for large deep networks). Thus, having the learning process monotonically and quickly bring the value error E k down to 0 is desirable for effective learning. By means of a simple didactic example, we now discuss some reasons why corrective feedback may be absent in ADP methods. We will then describe several examples that illustrate the negative consequences of absent corrective feedback on learning progress.

A Didactic Example and Theoretical Analysis of an Absence of Corrective Feedback
In this section, we first present a diadctic example which provides intuition for why corrective feedback may be absent in RL, and then we generalize this intuition to a more formal result in Section 3.1.2.

Didactic Example
We first describe our didactic example which is a tree-structured deterministic MDP (Figures 2 and 3) with 7 states and 2 actions, a 1 and a 2 , at each state. The MDP has deterministic transitions, where action a 1 transitions to a node's left child, and a 2 transitions to the right child. At each leaf node, the episode terminates and the agent receives a reward. We illustrate the learning progress of Q-learning (Algorithm 2) on this tree-MDP in Figure 2 and the learning progress of a method with an optimal distribution in Figure 3. In the on-policy setting, Q-values at states are updated according to the visitation frequency of these states under the current policy. Since the leaf nodes are the least likely in this distribution, the Bellman backup is slow to correct errors at the leaves. Using these incorrect leaf Q-values as target values for nodes higher in the tree then gives rise to incorrect values, even if Bellman error is fully minimized for the sampled transitions. Thus, most of the Bellman updates do not actually bring the updated Q-values closer to Q * . If we carefully order the states, such that the lowest level nodes are updated first before proceeding upwards in the tree, as shown in Figure 3, the errors are much lower. We will show in Section 5 that our proposed approach in this paper aims at performing updates in the manner shown in Figure 3 by re-weighting transitions collected by on-policy rollouts via importance sampling.
Reasons for the absence of corrective feedback. The above example provides an intuitive explanation for how on-policy or replay buffer distributions may not lead to error correction. Updates on states from such distributions may fail to correct Q-values at states that are the causes of the errors. In general, Bellman backups rely on the correctness of the values at the states that are used as targets, which may mean relying on the correctness of states that occur least frequently in any distribution generated by online data collection. While this is sufficient to guarantee convergence in tabular settings, with function approximation this can lead to an absence  Figure 3: Iterations of Q-learning on a tree-structured MDP with an optimal training distribution, where states are sampled starting from the leaf nodes, progressing upwards towards the root node in the tree. Note that this method backs up very few incorrect values in any iterations, and takes only a few iterations to converge. Our aim will be to approximate such an optimal training distribution.
of corrective feedback, as states with erroneous targets are visited more and more often, while the visitation frequency of the states that cause these errors does not increase.

Theoretical Analysis
We next present a theoretical result that generalizes the didactic example in a formal result. Proof for this result can be found in Appendix C. Our result is a lower-bound on the iteration complexity of on-policy Q-learning. We show that, under the on-policy distribution, Q-learning may require exponentially many iterations to learn the optimal Q-function. This will also provide an explanation for the slow and unstable learning as described in Figure 2 and in Section 3.2, Figure 4c. We state the result next. An extension to the replay buffer setting is given in Appendix C.
Theorem 3.1 (Exponential lower bound for on-policy and replay buffer distributions) There exists a family of MDPs parameterized by H > 0, with |S| = 2 H , |A| = 2, such that even with features, Φ that can represent the optimal Q-function near-perfectly, i.e., ||Q * − Φw|| ∞ ≤ ε, on-policy or replay-buffer Q-learning, i.e. D k = d π k , or D k = k i=1 d πi respectively, requires Ω γ −H exact Bellman projection steps for convergence to Q * , if at all the algorithm converges to Q * .
Thus, on-policy or replay buffer distributions can induce extremely slow learning in certain environments, even when all transitions are available for training (i.e., without any exploration issues), requiring exponentially many Bellman backups. When function approximation is employed, the smaller the frequency of a transition, the less likely Q-learning is to correct the Q-value of the state-action pair corresponding to this transition. In contrast, we show in Appendix C.2.2 that the method we propose in this paper requires only poly(H) iterations in this scenario, and it behaves similarly to a method that learns Q-values from the leaf nodes, gradually moving upwards toward the root of the tree.

Consequences of Absent Corrective Feedback
In this section, we investigate the phenomenon of an absence of corrective feedback in a number of RL tasks. We first plot the value error E k for the Q-function by assuming access to Q * for analysis, but this is not available while learning from scratch. We first show that an absence of corrective feedback happens in practice. In Figures 4a, 4b and 4c, we plot E k for on-policy and replay buffer sampling. Observe that ADP methods can suffer from prolonged periods where E k is increasing or fluctuating, and returns degrade or stagnate ( Figure 4b). Next, we empirically analyze a number of pathological outcomes that can occur when corrective feedback is absent.
1. Convergence to suboptimal Q-functions. We find that on-policy sampling can cause ADP to converge to a suboptimal solution, even in the absence of sampling error. This is not an issue with the capacity of the function approximator -even when the optimal Q-function Q * can be represented in the function class [6], learning converges to a suboptimal fixed point far from Q * . Figure 4a shows that the value error E k rapidly decreases initially, and eventually converges to a value significantly greater than 0, from which the learning process never recovers.

Suboptimal Convergence
(a) Sub-optimal convergence for onpolicy distributions: return (dashed) and value error (solid). Note that value error decreases rapidly at the start and finally converges to a nonzero value, leading to sub-optimal return.  2. Instability in the learning process. Q-learning with replay buffers may not converge to sub-optimal solutions as often as on-policy sampling ( Figure 13). However, we observe that even then (Figure 4b), ADP with replay buffers can be unstable. For instance, the algorithm is prone to degradation even if the latest policy obtains returns that are very close to optimal returns ( Figure 4b). This instability is often correlated with a lack of corrective feedback, and exists even with all transitions present in the buffer controlling for sampling error. 3. Inability to learn with low signal-to-noise ratio. Lack of corrective feedback can also prevent ADP algorithms from learning quickly in scenarios with low signal-to-noise ratio, such as tasks with sparse or noisy rewards (Figure 4c). For efficient learning, Q-learning needs to effectively "exploit" the reward signal even in the presence of noise and delay, and we find that the learning becomes significantly worse in the presence of these factors. This is not an exploration issue, since all transitions in the MDP are provided to the algorithm.

Optimal Distributions for Optimizing Corrective Feedback
In the previous section, we observed that an absence of corrective feedback can occur when ADP algorithms naïvely use the on-policy or replay buffer distributions for training Q-functions. However, if we can compute an "optimal" data distribution that provides maximal corrective feedback, and train Q-functions using this distribution, then we can ensure that the ADP algorithm always enjoys corrective feedback, and hence makes steady learning progress.
In this section, we aim to derive a functional form for this optimal data distribution. We first present an optimization problem for this optimal data distribution, which we refer to as p k (different from µ, which refers to the data distribution in the replay buffer, or the on-policy distribution), for any iteration k of the ADP algorithm, and then present a solution to this optimization problem. Proofs from this section can be found in Appendix A. We will show in this section that the resulting optimization when approximated practically, yields a very simple and intuitive algorithm. A more intuitive description of the resulting algorithm can be found in Section 5 Our goal is to minimize the value error E k at every iteration k, with respect to the the distribution p k used for Bellman error minimization at iteration k. The resulting optimization problem is: (2) Theorem 4.1 An optimal solution p k to optimization problem 2 satisfies the following relationship: where λ * ∈ R + , is an optimal Lagrange dual variable that ensures p k is a valid distribution in Problem 2.
Proof (Sketch) A complete proof is provided in Appendix A. Here we provide a rough sketch of the steps involved for completeness. We first use the Fenchel-Young inequality [16] to obtain an upper bound on the true objective, in terms of the "soft-min" of the errors |Q k − Q * | and then minimize this upper bound. Formally, this is given by the RHS of the equation below, H denotes Shannon entropy.
Then, we solve for p k by setting the gradient of the Lagrangian for Problem 2 to 0, which requires an addition of constraints s,a p k (s, a) = 1 and p k (s, a) > 0 to ensure that p k is a valid distribution. We then use the implicit function theorem (IFT) [17] to compute implicit gradients of Q k with respect to p k . IFT is required for this step since Q k is an output of a minimization procedure that uses p k as an input. Rearranging the expression gives the above result.
Intuitively, p k , shown in Equation 3, assigns higher probability to state-action tuples with high Bellman error |Q k − B * Q k−1 |, but only when the resulting Q-value Q k is close to Q * . However, the expression for p k contains terms that depend on Q * . Since both Q k and Q * are observed only after p k is chosen, we need to estimate these quantities using surrogate quantities which we discuss in the following section.

Tractable Approximation to Optimal Distribution
The expression for p k in Equation 3 contains terms dependent on Q * and Q k , namely |Q k − Q * | and |Q k − B * Q k−1 |. As described previously, since both Q k and Q * are observed only after p k is chosen, in this section, we develop surrogates to estimate these quantities. For error against Q * , we show that the cumulative sum of discounted Bellman errors over the past iterations of training, denoted as ∆ k , shown in Equation 4, is a valid proxy (equivalent to an upper bound) for |Q k − Q * |. In fact, Theorem 4.2 shows that ∆ k , offset by a state-action independent constant, is a tractable upper bound on |Q k − Q * | constructed only from prior Q-function iterates, Q 0 , · · · , Q k−1 .
The following theorem formally states this result.
Theorem 4.2 There exists a k 0 ∈ N, such that ∀ k ≥ k 0 and ∆ k from Equation 4, ∆ k satisfies the following inequality, pointwise, for each s, a: The key insight in this argument is to use a recursive inequality, presented in Lemma B.0.1, App. B, to decompose |Q k − Q * |, which allows us to show that ∆ k + i γ k−i α i is a solution to the corresponding recursive equality, and hence, an upper bound on |Q k − Q * |. Note that, the initialization |Q 0 − Q * | matters only infinitesimally once, k ≥ k 0 , with k 0 being such that γ k0 |Q k − Q * | < 1, therefore, agnostic to the initialization of ∆, ∆ 0 , we note that the statement in the theorem holds true for large-enough k.
Estimating |Q k − B * Q k−1 |. The expression for p k in Equation 3 also includes an unobserved Bellman error multiplier term, |Q k − B * Q k−1 | as well. With no available information about Q k -which will only be observed after Bellman error minimization under p k -a viable approximation is to bound this term |Q k − B * Q k−1 | between the minimum and maximum Bellman errors obtained at the previous iteration, We can simply restrict the support of state-action pairs (s, a) used to compute c 1 and c 2 to come from transitions observed in the replay buffer used for the Q-function update, to ensure that both c 1 and c 2 are finite.
Re-weighting the replay buffer µ. Since it is challenging to directly obtain samples from p k via online interaction, a practically viable alternative is to instead perform weighted Bellman updates by re-weighting transitions drawn from the a regular replay buffer µ using importance weights given by w k = p k (s,a) µ(s,a) . However, naïve importance sampling often suffers from high-variance of these importance weights, leading to instabilities in learning. To prevent such issues, instead of directly re-weighting to p k , we re-weight samples from µ to a projection of p k , denoted as q k , that is still close to µ under the KL-divergence metric: q k = arg min q D KL (q||p k ) + (τ − 1)D KL (q||µ), where τ is a scalar, τ > 1. The equation for weights w k , in this case, is thus given by: A derivation is provided in Appendix B. Having described all approximations, we now discuss how to obtain a tractable and practically usable data distribution for training the Q-function that maximally mitigates error accumulation.

Putting it All Together
We have noted all practical approximations to the expression for optimal p k (Equation 3), including estimating surrogates for Q k and Q * , and the usage of importance weights to develop a method that can achieve the benefits of the optimal distribution, simply by re-weighting transitions in the replay buffer, rather than altering the exploration strategy. We also discussed a technique to reduce the variance of weights used for this reweighting. We now put these techniques together to obtain the final, practically tractable expression for the weights used for our practical approach. We note that the term |Q k − Q * |, appearing inside the exponent in the expression for w k in Equation 5 can be approximated by the tractable upper bound ∆ k . However, computing ∆ k requires the quantity |Q k − B * Q k−1 | which also is unknown when w k is being chosen. Combining the upper bound on |Q k − B * Q k−1 | ≤ c 2 , Theorem 4.2 and Equation 4, we obtain the following bound: Using this bound in the expression for w k , along with the lower bound, |Q k − B * Q k−1 | ≥ c 1 , we obtain the following lower bound on weights w k : Finally, we note that using a worst-case lower bound for w k (Equation 7) will down-weight some additional transitions which in reality lead to low error accumulation, but this scheme will never up-weight a transition with high error, thus providing for a "conservative" distribution. A less conservative expression for getting these weights is a subject of future work. Simplifying the constants c 1 , c 2 and λ * , the final expression for the practical choice of w k is:

Distribution Correction (DisCor) Algorithm
In this section, we present the resulting algorithm, that uses weights w k from Equation 8 to re-weight the Bellman backup in order to induce corrective feedback. We first present an intuitive explanation of our algorithm, and then describe the implementation details.
Intuitive Explanation. Using weights w k in Equation 8 for weighting Bellman backups possess a very clear and intuitive explanation. P π k−1 ∆ k−1 corresponds to the estimated upper bound on the error of the target values for the current transition, due to the backup operator P π k−1 . Intuitively, this implies that weights w k downweight those transitions for which the bootstrapped target Q-value estimate has a high estimated error to Q * , effectively focusing the learning on samples where the supervision (target value) is accurate, which are precisely the samples that we expect maximally improve the accuracy of the Q function. This prevents error accumulation, and hence provides correct feedback. Such a scheme also resembles prior methods for learning with noisy labels by "abstention" from training on labels that are likely to be inaccurate [18].

5:
Compute target values for Q and ∆ on samples: Compute w k using Equation 8.

7:
Minimize Bellman error for training Q θ weighted by w k .
Details. Pseudocode for our approach, which we call DisCor (Distribution Correction), is presented in Algorithm 1, with the main differences from standard ADP methods highlighted in red. In addition to a standard Q-function, DisCor trains another parametric model, ∆ φ , to estimate ∆ k (s, a) at each state-action pair. The recursion in Equation 4 is used to obtain a simple approximate dynamic programming update rule for the parameters φ (Line 8). The second change is the introduction of a weighted Q-function backup with weights w k (s, a), as shown in Equation 8, on Line 7. We also present a practical implementation of the DisCor algorithm, built on top of standard DQN/SAC algorithm pseudocodes in Algorithm 3, Appendix E.

Related Work
Prior work has pointed out a number of issues arising when dynamic programming is used with function approximation. Some work [19,20,21] focused on analysing error induced from the typically used projected Bellman operator under the assumption of an abstract error model. Further, fully gradient-based objectives for Q-learning [22,23,24] gave rise to convergent ADP algorithms with function approximation. In contrast to these works, which mostly focus on ensuring convergence of the Bellman backup, we focus on the interaction between the ADP update and the data distribution µ. On the other hand, prior work on fully online Q-learning from a stochastic approximation viewpoint analyzes time-varying µ, but in the absence of function approximation [9,25,26], or at the granularity of a single time-step in the environment [27], unlike our setting. Our setting involves both a time-varying µ depending on the prior and latest Q-functions as well as function approximation.
A number of prior works have focused on studying non-convergence and generalization effects in ADP methods with deep net function approximators, both theoretically [28] and empirically [6,29,30]. In this paper, we study a different issue that is distinct from non-convergence and generalization issues due to the specific choice of deep net function approximators: the interaction between the data distribution and the fitting error in the value function.
In the fully offline setting, prior works have noted that sampling distributions can affect performance of ADP methods [6]. This has been generally aimed at resolving what is typically known as the "deadly triad" [31]: divergence caused by an interaction between function approximation, bootstrapped updates and off-policy sampling, resulting in the development of batch RL algorithms that choose sampling schemes [32,33] for guaranteed convergence. However, we show that sampling distributions can have a drastic impact on the learning process even where the algorithm performs online (on-policy) interaction to collects its own data. [34] studies the interaction between data collection and training for multi-objective policy gradient methods and note the bias towards optimizing only a few components of the objective that arises.
Our proposed algorithm weights the transition in the buffer based on an estimate of their error to the true optimal value function. Related to our approach, prioritized sampling has been used previously in ADP methods, such as PER [35], to prioritize transitions with higher Bellman error. We show in Section 7, that this choice may fail to perform in many cases. Recent work [36] has attempted to use a distribution-checking oracle to control the amount of exploration performed. Our work aims at ensuring corrective feedback, solely by re-weighting the data distribution for Q-learning with bootstrapped backups.
We further discuss the relationship with other prior works in an extended related work section in Appendix D.

Experimental Evaluation of DisCor
The goal of our empirical evaluation is to study the following questions: 1. Can DisCor ensure continuous corrective feedback in RL tasks, mitigating the issues raised in Section 3.2? 2. How does DisCor compare to prior methods, including those that also reweight the data in various ways? 3. Can DisCor attain good performance in challenging settings, such as multi-task RL or noisy reward signals? 4. How do approximations from Section 4 affect the efficacy of DisCor in mitigating error accumulation? We start by presenting a detailed analysis on tabular MDPs with function approximation, studying each component of DisCor in isolation, and then study six challenging robotic manipulation tasks, the multi-task MT10 benchmark from MetaWorld [14], and three Atari games [37].

Analysis of DisCor on Tabular Environments
We first use the tabular domains from Section 3, described in detail in Appendix F.1, to analyze the corrective feedback induced by DisCor and evaluate the effect of the approximations used in our method, such as the upper bound estimator ∆ k . We first study the setting without sampling error, where all transitions in the MDP are added to the training buffer, and then consider the setting with sampling error, where the algorithm also needs to explore the environment and collect transitions.
Results. In both settings, shown in Figure 5, DisCor consistently provides correct feedback ( Figure 5(a)). An oracle version of the algorithm (labeled DisCor (oracle); Equation 5), which uses the true error |Q k − Q * | in place of ∆ k , is somewhat better than DisCor ( Figure 5(b) histograms, red vs blue), but DisCor still outperforms on-policy and replay buffer sampling schemes, which often suffer from an absence of corrective feedback as shown in Section 3. Prioritizing based on high Bellman error struggles on domains with sparse rewards (App. F.1, Fig. 12).
Analysis. While DisCor (oracle) consistently performs better than DisCor, as we would expect, the approximate DisCor method still attains better performance than naïve uniform weighting and prioritization similar to PER. This shows that the principle behind DisCor is effective when applied exactly, and that even the approximation that we utilize to make the method practical still improves performance considerably.

Continuous Control Experiments
We next perform a comparative evaluation of DisCor on several continuous control tasks, using six robotic manipulation tasks from the Meta-World suite (pull stick, hammer, insert peg side, push stick, push with wall and turn dial). A pictorial description of these tasks is provided in Figure 6. These domains were chosen because they are challenging for state-of-the-art RL methods, such as soft actor-critic (SAC).
Meta-World. We applied DisCor to these tasks by modifying the weighting of samples in soft actor-critic (SAC) [7]. DisCor does not alter any hyperparameter from SAC, and requires minimal tuning. There is only one additional temperature hyperparameter, which is also automatically chosen across all domains. More details are presented in Appendix E.2.
We compare DisCor to standard SAC without weighting, as well as prioritized experience replay (PER) [35], which uses weights based on the last Bellman error. On these tasks, DisCor often attains better performance, as shown in Figures 7 and 16, achieving better success rates than standard SAC on several tasks. DisCor is also more efficient, achieving good performance earlier than the other methods on these tasks. PER, on the other hand, performs poorly, as prioritizing high Bellman error states may lead to higher error accumulation if the target values are incorrect.
Gym. We also performed comparisons on the conventional OpenAI gym benchmarks, where we see a small but consistent benefit from DisCor reweighting. Since prior methods, such as SAC already solves these tasks easily, and have been tuned well for them, the room for improvement is very small. We include these results in Appendix F.3 for completeness. We also modified the gym environments to have stochastic rewards, thus lowering the signal-to-noise ratio, and compare different algorithms on these domains. The results, along with a description of the noise added, are shown in Appendix F.3. In these experiments, DisCor generally exhibits better sample efficiency as compared to other methods.

Multi-Task Reinforcement Learning
Another challenging setting for current RL methods is the multi-task setting. This is known to be difficult, to the point that oftentimes learning completely separate policies for each of the tasks is actually faster, and resulting in better performance, than learning the tasks together [14,34].  MT10 multi-task benchmark. We evaluate on the MT10 MetaWorld benchmark [14], which consists of ten robotic manipulation tasks to be learned jointly. We follow the protocol from [14], and append task ID to the state. As shown in Figure 8(a), DisCor applied on top of SAC outperforms standard unweighted SAC by a large margin, achieving 50% higher success rates compared to SAC, and a high overall return (Fig 19). Figure 8(b) shows that DisCor makes progress on 7/10 tasks, as compared to 3/10 for SAC.
MT50 multi-task benchmark. We further compare the performance of DisCor and SAC on the more challenging MT50 benchmark [14], which is shown in Figure 20, and observe a similar benefit as compared to MT10, where the standard unweighted SAC algorithm tends to saturate at a suboptimal success rate for about 4M environment steps, whereas DisCor continuously keeps learning, and achieves asymptotic performance faster than SAC.

Arcade Learning Environment
Our final experiments were aimed at testing the efficacy of DisCor on stochastic, discrete-action environments.
To this end, we evaluated DisCor on three commonly reported tasks from the Atari suite -Pong, Breakout and Asterix. We compare to the baseline DQN [11], all our implementations are built off of Dopamine [38] and use the evaluation protocol with sticky actions [39]. We build DisCor on top of DQN by simply replacing the standard replay buffer sampling scheme in DQN with the DisCor weighted update. We show in Figure 9 that DisCor usually outperforms unweighted DQN in learning speed and performance.

Discussion, Future Work and Open Problems
In this work, we show that deep RL algorithms suffer from the absence of a corrective feedback mechanism in scenarios with naïve online data collection. This results in a number of problems during learning, including slow convergence and oscillation. We propose a method to compute the optimal data distribution in order to achieve corrective feedback, and design a practical algorithm, DisCor, that applies this distribution correction by re-weighting the transitions in the replay buffer based on an estimate of the accuracy of their target values. DisCor yields improvements across a wide range of RL problems, including challenging robotic manipulation tasks, multi-task reinforcement learning and Atari games and can be easily combined with a variety of ADP algorithms. As shown through our analysis and experiments, studying the connection between data distributions, function approximation, and approximate dynamic programming can allow us to devise stable and efficient reinforcement learning algorithms. This suggests several exciting directions for future work. First, a characterization of the learning dynamics and their interaction with corrective feedback and data distributions in ADP algorithms may lead to even better and more stable algorithms, by better identifying the accuracy of target values. Second, our approach is limited by the transitions that are actually collected by the behavior policy, since it only reweights the replay buffer. An exciting direction of future investigation would involve studying how we might directly modify the exploration policy to change which transitions are collected, so as to more directly alter the training distribution and produce large gains in sample efficiency and asymptotic performance. If we can devise RL methods that are guaranteed to enjoy corrective feedback and thus are stable, robust, and effective, then RL algorithms can be reliably scaled to large open-world settings.

Appendices Appendix A. Detailed Proof of Theorem 4.1 (Section 4)
In this appendix, we present a detailed proofs for the theoretical derivation of DisCor outlined in Section 4. To get started, we mention the optimization problem being solved for convenience.
We break down this derivation in steps marked as relevant paragraphs. The first step is to decompose the objective into a more tractable one via an application of the Fenchel-Young inequality [16].
Step 1: Fenchel-Young Inequality. The optimization objective in Problem 9 is the inner product of d π k−1 and |Q k − Q * |. We can decompose this objective by applying the Fenchel-Young inequality [16]. For any two vectors, x, y ∈ R d , and any convex function f and its Fenchel conjugate f * , we have that, x T y ≤ f (x) + f * (y). We therefore have: Since minimizing an upper bound leads to minimization of the original objective, we can replace the objective in Problem 9 with the upper bound in Equation 10. As we will see below, a convenient choice of f is the soft-min function: f * in this case is given by the Shannon entropy, which is defined as H(y) = − j y j log y j . Plugging this back in problem 9, we obtain an objective that dictates minimization of the marginal state-action entropy of the policy π.
In order to make this objective even more convenient and tractable, we upper bound the Shannon entropy, H(y) by the entropy of the uniform distribution over states and actions, H(U). This step ensures that the entropy of the state-action marginal d π is not reduced drastically due to the choice of p. We can now minimize this upper bound, since minimizing an upper bound, leads to a minimization of the original problem, and therefore, we obtain the following new optimization problem shown in Equation 12 is: Another way to interpret this step is to modify the objective in Problem 9 to maximize entropy-augmented V CF : V CF (k) + H(d π k ) as is common in a number of prior works, albeit with entropy over different distributions such as [40,7]. This also increases the smoothness of the loss landscape, which is crucial for performance of RL algorithms [41].
Step 2: Computing the Lagrangian. In order to solve optimization problem Problem 12, we follow standard procedures for finding solutions to constrained optimization problems. We first write the Lagrangian for this problem, which includes additional constraints to ensure that p k is a valid distribution: with constraints s,a p k (s, a) = 1 and p k (s, a) ≥ 0 (∀s, a) and their corresponding Lagrange multipliers, λ and µ, respectively, that ensure p k is a valid distribution. An optimal p k is obtained by setting the gradient of the Lagrangian with respect to p k to 0. This requires computing the gradient of Q k , resulting from Bellman error minimization, i.e. computing the derivative through the solution of another optimization problem, with respect to the distribution p k . We use the implicit function theorem (IFT) [17] to compute this gradient. We next present an application of IFT in our scenario.
Step 3: IFT gradient used in the Lagrangian. We derive an expression for ∂Q k ∂p k which will be used while computing the gradient of the Lagrangian Equation 13 which involves an application of the implicit function theorem. The IFT gradient is given by: To get started towards showing Equation 14, we consider a non-parametric representation for Q k (a table), so that we can compute a tractable term without going onto the specific calculations for Jacobian or inverse-Hessian vector products for different parametric models. In this case, the Hessians in the expression for IFT and hence, the implicit gradient are given by: provided p k ≥ 0 (which is true, since we operate in a full coverage regime, as there is no exploration bottleneck when all transitions are provided). This quantity is 0 only if the Bellman residuals Q k − B * Q k−1 are 0, however, that is rarely the case, hence this gradient is non-zero, and intuitively quantifies the right relationship: Bellman residual errors Q k − B * Q k−1 should be higher at state-action pairs with low density p k , indicating a roughly inverse relationship between the two terms -which is captured by the IFT term.
Step 4: Computing optimal p k . Now that we have the equation for IFT (Equation 14) and an expression for the Lagrangian (Equation 13), we are ready to compute the optimal p k via an application of the KKT conditions. At an optimal p k , we have, Now, re-arranging Equation 16 and plugging in the expression for ∂Q k ∂p k from Equation 14 in this Equation to obtain an expression for p k (s, a), we get: Provided, each component of p is positive, i.e. p k (s, a) ≥ 0 for all s, a, the optimal dual variable µ * s,a = 0, satisfies µ * (s, a)p k (s, a) = 0 by KKT-conditions, and µ * ≥ 0 (since it is a Lagrange dual variable), thus implying that µ * = 0.
Intuitively, the expression in Equation 17 assigns higher probability to state-action tuples with high Bellman error |Q k − B * Q k−1 |, but only when the post-update Q-value Q k is close to Q * . Hence we obtain the required theorem.
Summary of the derivation. To summarize, our derivation for the optimal p k consists of the following key steps: • Use the Fenchel-Young inequality to get a convenient form for the objective.
• Compute the Lagrangian, and use the implicit function theorem to compute gradients of the Q-function Q k with respect to the distribution p k . • Compute the expression for optimal p k by setting the Lagrangian gradient to 0.

Appendix B. Proofs for Tractable Approximations in Section 4.1
Here we present the proofs for the arguments behind each of the approximations described in Section 4.1.
Computing weights w k for re-weighting the buffer distribution, µ. Since sampling directly from p k may not be easy, we instead choose to re-weight samples transitions drawn from a replay buffer µ, using weights w k to make it as close to p k . How do we obtain the exact expression for w k (s, a)? One option is to apply importance sampling: choose w k as the importance ratio, w k (s, a) = p k (s,a) µ(s,a) , however this suffers from two problems -(1) 18 importance weights tend to exhibit high variance, which can be detrimental for stochastic gradient methods; and (2) densities µ(s, a), needed to compute w k are unknown.
In order to circumvent these problems, we solve a different optimization problem, shown in Problem 18 to find the optimal surrogate projection distribution q k , which is closest to p k , and at the same time closest to µ as well, trading off these quantities by a factor τ − 1.
where λ is a temperature hyperparameter that trades of bias and variance. The solution to the above optimization is shown in Equation 19, where the second statement follows by using a tractable approximation of setting µ 1− 1 τ to be equal to µ, which can be ignored if τ is large, hence 1 − 1 τ ≈ 1. The third statement follows by an application of Equation 17 and the fourth statement denotes the importance ratio, q k (s,a) µ k (s,a) , as the weights w k .
Our next proof justifies the usage of the estimate ∆ k , which is a worst-case upper bound on |Q k − Q * | in Equation 19.
Proof of Theorem 4.2. We now present a Lemma B.0.1 which proves a recursive inequality for |Q k − Q * |, then show that the corresponding recursive estimator upper bounds |Q k − Q * | pointwise in Lemma B.0.2, and then finally show that our chosen estimator ∆ k is equivalent to this recursive estimator in Theorem B.1 therefore proving Theorem 4.2.
Lemma B.0.1 For any k ∈ N, |Q k − Q * | satisfies the following recursive inequality, pointwise for each s, a: Proof Our proof relies on a worst-case expansion of the quantity |Q k − Q * |. The proof follows the following steps. The first few steps follow common expansions/inequalities operated upon in the work on error propagation in Q-learning [19].
where (a) follows from adding and subtracting B * Q k−1 , (b) follows from an application of triangle inequality, (c) follows from the definition of B * applied to two different Q-functions, (d) follows from algebraic manipulation, (e) follows from an application of the triangle inequality, and (f) follows from bounding the maximum difference in transition matrices |P π k−1 − P * | by maximum total variation divergence between policy π k−1 and π * , and bounding the maximum possible value of Q * by Rmax 1−γ .
Proof Let ∆ k be an estimator satisfying Equation 20. In order to show that ∆ k + i γ k−i α i ≥ |Q k − Q * |, we use the principle of mathematical induction. The base case, k = 0 is satisfied, since ∆ 0 + α 0 ≥ |Q 0 − Q * |. Now, let us assume that for a given k = m, for each (s, a). Now, we need to show that a similar relation holds for k = m + 1, and then we can appeal to the principle of mathematical induction to complete the argument. In order to show this, we note that, where (21) follows from the definition of ∆ k , (22) follows by rearranging the recursive sum containing α i , for i ≤ m alongside ∆ m , (23) follows from the inductive hypothesis at k = m, and (24) follows from Lemma B.0.1. Thus, by using the principle of mathematical induction, we have shown that ∆ k + i γ k−i α i ≥ |Q k − Q * | pointwise for each s, a, for every k ∈ N.
The final piece in this argument is to show, that the estimator ∆ k used by the DisCor algorithm (Algorithm 1), which is initialized randomly, i.e. not initialized to ∆ 0 = |Q 0 − Q * |, still satisfies the property from Lemma B.0.2, possibly for certain k ∈ N.
Therefore, we now show why: log γ , the error estimator ∆ k pointwise satisfies: where α i 's are scalar constants independent of any state-action pair. (Note that Theorem 4.2 has a typo γ i instead of γ k−i , this theorem presents the correct inequality.)

Proof
Main Idea/ Sketch: As shown in Algorithm 1, the estimator ∆ k is initialized randomly, without taking into account |Q 0 − Q * |. Therefore, in this theorem, we want to show that irrespective of the initialization of Q 0 , a randomly initialized ∆ k eventually satisfies the inequality shown in Theorem 4.2. Now, we present the formal proof.
Consider k 0 to be the smallest k, such that the following inequality is satisfied: Thus, k 0 ≥ log(1−γ) log γ , assuming R max = 1 without loss of generality. For a different reward scaling, the bound can be scaled appropriately. To see this, we substitute |Q 0 − Q * | as an upper-bound R max /(1 − γ), and bound R max by 1.
Let ∆ k correspond to the upper-bound estimator as derived in Lemma B.0.2. For each k ≥ k 0 , the contribution of the initial error |Q 0 − Q * | in |Q k − Q * | is upper-bounded by 1, and gradually decreases with a rate γ as more backups are performed, i.e., as k increases. Thus we can construct another sequence ∆ 1 , ·, ∆ k , · · · which chooses to ignore |Q 0 − Q * |, and initializes ∆ 0 = 0 (or randomly) and the sequences ∆ and ∆ k satisfy: Furthermore, the difference |∆ k − ∆ k | steadily shrinks to 0, with a linear rate γ, so the overall contribution of the initialization sub-optimality |Q 0 − Q * | drops linearly with a rate of γ. Hence, ∆ and ∆ converge to the same sequence beyond a fixed k = k 0 . Since ∆ k is computed using the RHS of Lemma B.0.1, it is guaranteed to be an upper bound on |Q k − Q * |: A note on the value of k 0 . For a discounting of γ = 0.95, we get that k 0 ≈ 59 and for γ = 0.99, k 0 ≈ 460. In practical instances, an RL algorithm takes a minimum of about ≥ 1M gradient steps, so this value of k 0 is easy achieved. Even in the gridworld experiments presented in Section 7.1, γ = 0.95, hence, the effects of initialization stayed significant only untill about 59 iterations during training, out of a total of 300 or 500 performed, which is a small enough percentage.

Summary of Proof for Theorem 4.2. ∆ k in DisCor is given by the quantity ∆
is an upper bound for the error |Q k − Q * |, and we can safely initialize the parametric function ∆ φ using standard neural network initialization, since the value of initial error will matter only infinitesimally after a large enough k.
As k → ∞, the following is true: Also, note that if π k is improving, i.e. π k → π * , then, we have that D TV (π k , π * ) → 0, and since limit of a sum is equal to the sum of the limit, and γ < 1, therefore, the final inequality in Equation 30 tends to 0 as k → ∞.

Appendix C. Missing Proofs From Section 3
In this section, we provide omitted proofs from Section 3 of this paper. Before going into the proofs, we first describe notation and prove some lemmas that will be useful later in the proofs. We also describe the underlying ADP algorithm we use as an ideal algorithm for the proofs below. Collect trajectories using πt

4:
Choose distribution Dt for projection.

5:
Qt+1 Qt−1(s, a)) 2 ] 6: end for Assumptions. The assumptions used in the proofs are as follows: • Q-function is linearly represented, i.e. given a set of features, φ(s, a) ∈ R d for each state and action, concisely represented as the matrix Φ ∈ R |S||A|×d , Q-learning aims to learn a d-dimensional feature vector w, such that Q(s, a) = w T φ(s, a). This is not a limiting factor as we will prove in Assumption C.1, for problems with sufficiently large |S| and |A|.

C.1 Suboptimal Convergence of On-policy Q-learning
We first present a result that describes how Q-learning can converge sub-optimally when performed with on-policy distributions, thus justifying our empirical observation of suboptimal convergence with on-policy distributions.
Proof This statement was proven to be true in [42], where it was shown the projection operator H has the same fixed points as another operator, F α given by: where α ∈ (0, 1) is a constant. They showed that the operator F α is a contraction for small-enough α and used a compact set argument to generalize it to other positive values of α. We refer the reader to [42] for further reference. They then showed a 2-state MDP example (Example 6.1, [42]) such that the Bellman operator H has 2 fixed points, thereby showing the existence of one or more fixed points for the on-policy Bellman backup operator.

C.2 Proof of Theorem 3.1
We now provide an existence proof which highlights the difference in the speeds of learning accurate Q-values from online or on-policy and replay buffer distributions versus a scheme like DisCor. We first state an assumption (Assumption C.1) on the linear features parameterization used for the Q-function. This assumption ensures that the optimal Q-function exists in the function class (i.e. linear function class) used to model the Q-function. This assumption has also been used in a number of recent works including [43]. Analogous to [43], in our proof, we show that this assumption is indeed satisfied for features lying in a space that is logarithmic in the size of the state-space. For this theorem, we present an episodic example, and operate in a finite horizon setting with discounting γ and H denotes the horizon length. An episode terminates deterministically as soon as the run reaches a terminal node -in our case a leaf node of the tree MDP, i.e. a node at level H − 1 -as we will see next.
We first prove an intermediate property of Φ satisfying the above assumption that will be crucial for the lower bound argument for on-policy distributions.
Corollary C.1.1 There exists a set of features Φ ∈ R 2 H ×O(H 2 /ε 2 ) satisfying assumption C.1, such that the following holds: Proof This proof builds on the existence argument presented in [43]. Using the ε-rank property of the identity matrix, one can show that there exists a feature set Φ ∈ R 2 H ×O(H/ε 2 ) such that ||I 2 H − ΦΦ T || ∞ ≤ . Thus, we can choose any such Φ, for a sufficiently low threshold ε. In order to assign features Φ to a state, we can simply perform an enumeration of nodes in the tree via a standard graph search procedure such as depth first search and assign a node (s, a) a feature vector φ(s, a). To begin with, let's show how we can satisfy assumption C.1 by choosing a different weight vector w h for each level h, such that we obtain |Q h (s, a) − w T h φ(s, a)| ≤ . Since for each level h exactly one state satisfies Q * (s j , a j ) = γ H−j+1 , so we can just let w j = γ H−j+1 φ(s j , a j ) and thus we are able to satisfy Assumption C.1. This is the extent of the argument used in [43]. Now we generalize this argument to find a single w ∈ R d , unlike different weights w h for different levels h. In order to do this, we create a new Φ , of size Φ ∈ R 2 H ×O(H 2 / 2 ) (note H 2 versus H dimensions for Φ and Φ) given , 0, ..., 0 Essentially, we pad Φ with zeros, such that for (s, a) belonging to a level h, Φ is equal to Φ in the h−th, dim(φ(s, a))-sized block. A choice of a single w ∈ R dim(Φ (s,a)) for Φ is given by simply concatenating w 1 , · · · , w h found earlier for Φ.
It is easy to see that w T Φ satisfies assumption C.1. A fact that will be used in the proof for Theorem C.2, is that this construction of Φ also satisfies: We now restate the theorem from Section 3 and provide a proof below.
Theorem C.2 (Exponential lower bound for on-policy distributions) There exists a family of MDPs parameterized by H > 0, with |S| = 2 H , |A| = 2 and a set of features satisfying Assumption C.1, such that on-policy sampling distribution, i.e. D k = d π k , requires Ω γ −H exact fixed-point iteration steps in the generic algorithm (Algorithm 2) for convergence, if at all, the algorithm converges to an ε−accurate Q-function.

Proof
Tree Construction. Consider the family of tree MDPs like the one shown in Figure 10. Both the transition function T and the reward function r are deterministic, and there are two actions at each state: a 1 and a 2 . There are H level of states, thereby forming a full binary tree of depth H. Executing action a 1 transitions the state to its left child int he tree and executing action a 2 transitions the state to its right child. There are 2 h states in level h. Among the 2 H−1 states in level H − 1, there is one state, s * , such that action a * at this state yields a reward of r(s * , a * ) = 1. For other states of the MDP, r(s, a) = 0. This is a typical example of a sparse reward problem, generally used for studying exploration [43], however, we re-iterate that in this case, we are primarily interested in the number of iterations needed to learn, and thereby assume that the algorithm is given infinite access to the MDP, and all transitions are observed, and the algorithm just picks a distribution D k , in this case, the on-policy state-action marginal for performing backups.
Main Argument. Now, we are equipped with a family of the described tree MDPs and a corresponding set of features Φ which can represent an ε−accurate Q-function. Our aim is to show that on-policy Q-learning takes steps, exponential in the horizon for solving this task. For any stochastic policy π(a|s), andp defined asp = min s∈S,a∈A π(a|s), 0 <p < 0.5, the marginal state-action distribution satisfies: Since d π is a discounted state-action marginal distribution, another property that it satisfies is that: where c is a constant c > 0. The above is true, since, there are 2 H states in this MDP, and the maximum values of any entry in d π can be 1 1−γ since, 1 − γ is the least eigenvalue of (I − γP π ) for any policy π, since ||P π || 2 = 1. Now, under an on-policy sampling scheme and a linear representation of the Q-function as assumed, the updates on the weights for each iteration of Algorithm 2 are given by (D π k represents Diag(d π k )): Now, ||D π k r|| ≤ γ H (1 −p) H+1 ||φ(s * , a * )|| from the property Equation 34. Hence, the maximum 2-norm of the updated w k+1 is given by: where the first inequality follows by an application of the triangle inequality, the second inequality follows by using the minimum value of the Frobenius norm of the matrix Φ to be (1 − ε) · 2 H−1 (using the ε−rank lemma used to satisfy Assumption C.1) in the denominator of the first term, bounding ||D π k r|| by Equation 34, and finally bounding the second term by γ||w k || 2 , since the maximum eigenvalue of the entire matrix in front of w k is ≤ 1, as it is a projection matrix with a discount γ valued scalar multiplier. The third inequality follows from lower bounding D π k by c using Equation 35.
The optimal w * is given by the fixed point of the Bellman optimality operator, and in this case satisfies the following via Cauchy-Schwartz inequality, Thus, in order for w k to be equal to w * , it must satisfy the above condition (Equation 38). If we choose an initialization w 0 = 0 (or a vector sufficiently close to 0), we can compute the minimum number of steps it will take for on-policy ADP to converge in this setting by using 37 and 38: for sufficiently small ε. Hence, the bound follows.
A note on the bound. Since typically RL problems usually assume discount factors γ close to 1, one might wonder the relevance is this bound in practice. We show via an example that this is indeed relevant. In particular, we compute the value of this bound for commonly used γ,p and H. For a discount γ = 0.99, and a minimum probability ofp = 0.01 (as it is common to use entropy bonuses that induce a minimum probability of taking each action), this bound is of the order of (γ · (1 −p)) H ≈ 10 9 for H = 1000 (40) for commonly used horizon lengths of 1000 (example, on the gym benchmarks).
Corollary C.2.1 (Extension to replay buffers) There exists a family of MDPs parameterized by H > 0, with |S| = 2 H , |A| = 2 and a set of features Φ satisfying assumption C.1, such that ADP with replay buffer distribution takes Ω(γ −H ) many steps of exact fixed-point iteration for convergence of ADP, if at all convergence happens to an −accurate Q-function.
Proof For replay buffers, we can prove a similar statement as previously. The steps in this proof follow exactly the steps in the proof for the previous theorem. With replay buffers, the distribution for the projection at iteration k is given by: Therefore, we can bound the probability of observing any state-action pair similar to Equation 34 as: withp as defined previously. Note that this inequality is the same as the previous proof, and doesn't change. We next bound the 2-norm of the state-visitation distribution, in this case, the state-distribution in the buffer.
where c > 0. The two main inequalities used are thus the same as the previous proof. Now, we can simply follow the previous proof to prove the result.
Practical Implications. In this example, both on-policy and replay buffer Q-learning suffer from the problem of exponentially many samples need to reach the optimal Q-function. Even in our experiments in Section 3, we find that on-policy distributions tend to reduce errors very slowly, at a rate that is very small. The above bound extends this result to replay buffers as well.
In our next result, however, we show that an optimal choice of distribution, including DisCor, can avoid the large iteration complexity in this family of MDPs. Specifically, using the errors against Q * , i.e. |Q k − Q * | can help provide a signal to improve the Q-function such that this optimal distribution / DisCor will take only poly(H) many iterations for convergence.
Corollary C.2.2 (Optimal distributions / DisCor) In the tree MDP family considered in Theorem 3.1, with linear function approximation for the Q-function, and with Assumption C.1 for the features Φ, DisCor takes poly(H) many exact iterations for ε−accurate convergence to the optimal Q-function.
Proof We finally show that the DisCor algorithm, which prioritizes states based on the error in target values, will take poly(H) many steps for convergence. Assume that Q-values are initialized randomly, for example via a normal random variable with standard deviation σ, i.e., Q 0 (s, a) ∼ N (0, σ 2 ), however, σ is very small, but is more than 0 (σ > 0) (this proof is still comparable to the proof for on-policy distributions, since Q-values can also be initialized very close to 0 even in that case, and the proof of Theorem C.2 still remains valid.).
Now we reason about a run of DisCor in this case.

Iteration 1.
In the first iteration, among all nodes in the MDP, the leaf nodes (depth H-1) have 0 error at the corresponding target values, since an episode terminates once a rollout reaches a leaf node. Hence, the algorithm will assign equal mass to all leaf node states, and exactly update the Q-values for nodes in this level (upto ε-accuracy).

Iteration 2.
In the second iteration, the leaf nodes at level H −1 have accurate Q-values, therefore, the algorithm will pick nodes at the level H − 2, for which the target values, i.e. Q-values for nodes at level H − 1, have 0 error along with nodes at level H − 1. The algorithm will update Q-values at these nodes at level H − 2, while ensuring that the incurred error at the nodes at level H − 1 isn't beyond ε, since nodes at both levels are chosen. Since, the optimal value function Q * can be represented upto ε−accuracy, we can satisfy this criterion.
Iteration k. In iteration k, the algorithm updates Q-values for nodes at level H − k, while also ensuring Q-values for all nodes at a level higher than H − k are estimated within the range of ε−allowable error, since all the nodes below level H − k are updated. This is feasible since, Q * is expressible with ε−accuracy within the linear function class chosen. This iteration process continues, and progress level by level, from the leaves (level H − 1) to the root (level 0). At each iteration Q-values for all states at the same level, and below are learned together. Since learning progresses in a "one level at-a-time" fashion, with guaranteed correct target values (i.e. target values are equal to the optimal Q-function Q * ) for any update that the algorithm performs, it would take at most poly(H) many iterations (for example, multiple passes through the depth of the tree) for ε-accurate convergence to the optimal Q-function.

Appendix D. Extended Related Work
Error propagation in ADP. A number of prior works have analysed error propagation in ADP methods. Most work in this area has been devoted to analysing how errors in Bellman error minimization propagate through the learning process of the ADP algorithm, typically focusing on methods such as fitted Q-iteration (FQI) [10] or approximate policy iteration [44]. Prior works in this area assume an abstract error model, and analyze how errors propagate. Typically these prior works only limitedly explore reasons for error propagation or present methods to curb error propagation. [45] analyze error propagation in approximate policy iteration methods using quadratic norms. [19] analyze the propagation of error across iterations of approximate value iteration (AVI) for L p -norm p = (1, 2). [21] provide finite sample guarantees of AVI using error propagation analysis. Similar ideas have been used to provide error bounds for a number of different methods - [20,46,47,48] and many more. In this work, we show that ADP algorithms suffer from an absence of corrective feedback, which arises because the data distribution collected by an agent is insufficient to ensure that error propagation is eventually corrected for. We further propose an approach, DisCor, which can be used in conjunction with modern deep RL methods.
Offline / Batch Reinforcement Learning. Our work bears similarity to the recent body of literature on batch, or offline reinforcement learning [30,49,50]. All of these works exploit the central idea of constraining the policy to lie in a certain neighborhood of the behavior, data-collection policy. While [30] show that this choice can be motivated from the perspective of error propagation, we note that there are clear differences between our work and such prior works in batch RL. First, the problem statement of batch RL requires learning from completely offline experience, however, our method learns online, via on-policy interaction. While error propagation is a reason behind incorrect Q-functions in batch RL, we show that such error accumulation also happens in online reinforcement, which results in a lack of corrective feedback.
Generalization effects in deep Q-learning. There are a number of recent works that theoretically analyze and empirically demonstrate that certain design decisions for neural net architectures used for Q-learning, or ADP objectives can prove to be significant in deep Q-learning. For instance, [29] point out that sparse representations may help Q-learning algorithms, which links back to prior literature on state-aliasing and destructive interference. [28] uses an objective inspired from the neural tangent kernel (NTK) [51] to "cancel" generalization effects in the Q-function induced across state-action pairs to mimic tabular and online Q-learning. Our approach, DisCor, can be interpreted as only indirectly affecting generalization via the target Q-values for state-action pairs that will be used as bootstrap targets for the Bellman backup, which are expected to be accurate with DisCor, and this can aid generalization, similar to how generalization can be achieved via abstention from training on noisy labels in supervised learning [18].
Replay Buffers and Generalization. There are some prior works performing analytical studies on the size of the replay buffer [52,53], which propose that larger replay buffers might hurt training with function approximation. Partly this problem goes away if smaller buffers are used, or if the algorithm chooses to replay recent experience more often. Our work indicates an absence of corrective feedback problem -online data collection might not be able to correct errors in the Q-function -which is distinct from the size of the replay buffer.

5:
Compute target values for Q and ∆ on samples: Compute w k using Equation 8 with temperature τ k

7:
Take G gradient steps on the Bellman error for training Q θ weighted by w k .

8:
Tale G gradient steps to minimize unweighted (regular) Bellman error for training φ.
Update the policy π ψ if it is explicitly modeled. 10: Update target networks using soft updates (SAC), hard updates (DQN) Update temperature hyperparameter for DisCor: 12: end for

E.1 DisCor in Practice
In this section, we provide details on the experimental setup and present the pseudo-code for the practical instantiation of our algorithm, DisCor. The pseudocode for the practical algorithm is provided in Algorithm 3. Like any other ADP algorithm, such as DQN or SAC, our algorithm maintains a pair of Q-functions -the online Q-network Q θ and a target network Qθ. For continuous control domains, we use the clipped double Q-learning trick [5], which is also referred to as the "twin-Q" trick, and it further parametrizes another pair of online and target Q-functions, and uses the minimum Q-value for backup computation. In addition to Q-functions, in a continuous control domain, we parametrize a separate policy network π ψ similar to SAC. In a discrete action domain, the policy is just given by a greedy maximization of the online Q-network.
DisCor further maintains a model for accumulating errors ∆ φ parameterized by φ and the corresponding target error network ∆φ. In the setting with two Q-functions, DisCor models two networks, one for modelling error in each Q-function. At every step, a few (depending upon the algorithm) gradient steps are performed on Q and ∆, and π -if it is explicitly modeled, for instance in continuous control domains. This is a modification of generalized ADP Algorithm 2 and the corresponding DisCor version (Algorithm 1), customized to modern deep RL methods.

E.2 Experimental Hyperparameter Choices
We finally specify the hyperparameters we used for our experiments. These are as follows: Figure 11: Performance of different methods: DisCor (blue), DisCor (oracle) (red), Replay buffer Q-learning (green, on-policy (grey) and prioritized updates (orange), across different environments measured in terms of smooth normalized returns in the exact setting with all transitions. Note that DisCor and DisCor (oracle) generally tend to perform better. Figure 12: Performance of different methods: DisCor (blue), DisCor (oracle) (red), Replay buffer Q-learning (green) and prioritized updates (orange). across different environments measured in terms of smooth normalized return with sampled transitions. Note that DisCor and DisCor (oracle) generally tend to perform better. present some individual-environment learning curves for these environments comparing different methods in both exact ( Figure 13) and sampled ( Figure 14).

F.2 MetaWorld Tasks
In this section, we first provide a pictorial description of the six hard tasks we tested on from meta-world, where SAC usually does not perform very well. Figure 15 shows these tasks. We provide the trends for average return achieved during evaluation (not the success rate as shown in Figure 7 in Section 7) for each of the six tasks. Note that DisCor clearly outperforms both the baseline SAC and the prior method PER in all six cases, achieving nearly 50% more than the returns achieved by SAC.

F.3 OpenAI Gym Benchmarks
Here we present an evaluation on the standard OpenAI continuous control gym benchmark environments. Modern ADP algorithms such as SAC can already solve these tasks easily, without any issues, since these algorithms have been tuned on these tasks. A comparison of the three algorithms DisCor, SAC and PER, on three of these benchmark tasks is shown in Figure 17. We note that in this case, all the algorithms are roughly comparable to each other. For instance, DisCor performs better than SAC and PER on Walker2d, however, is outperformed by SAC on Ant.
Stochastic reward signals. That said, we also performed an experiment to verify the impact of stochasticity, such as noise in the reward signal, on the DisCor algorithm as compared to other baseline algorithms like SAC and PER. Analogous the diagnostic tabular experiments on low signal-to-noise ratio environments, such as those with sparse reward, we would expect a baseline ADP method to be impacted more due to an absence of corrective feedback in tasks with stochastic reward noise, since a noisy reward effectively reduces the signal-to-noise ratio. We would also expect a method that ensures corrective feedback to perform better. In order to test this hypothesis, we created stochastic reward tasks out of the OpenAI gym benchmarks. We modified the reward function r(s, a) in these gym tasks to be equal to: r (s, a) = r(s, a) + z, z ∼ N (0, 1) (44) and the agent is only provided these noisy rewards during training. However, we only report the deterministic ground-truth reward during evaluation. We present the results in Figure 18. Observe that in this scenario, DisCor  From left to right: pull stick, push with wall, push with stick, turn dial, hammer and insert peg side tasks. Note that DisCor clearly achieves better returns or learns faster in most of the tasks. emerges as the best performing algorithm on these tasks, and outperforms other baselines SAC and PER both in terms of asymptotic performance (example, HalfCheetah) and sample efficiency (example, Ant).  Figure 18: Performance of DisCor, SAC and PER on continuous control gym benchmarks with stochastic reward noise. Note that DisCor learns slightly faster and performs better than SAC and PER on these stochastic problems.

F.4 MT10 Multi-Task Experiments
In this section, we present the trend of returns, as a learning curve and as a comparative histogram (at 1M environment steps of training) for the multi-task MT10 benchmark, extending the results shown in Section 7.3, Figure 8. These plots are shown in Figure 19. Observe that DisCor achieves more than 30% of the return of SAC, and obtains an individually higher value of return on more tasks.

MT-10 Multi Task Benchmark
DisCor SAC (a) Average task return (b) Per-task return at 1M steps Figure 19: Performance of DisCor and SAC on the MT10 benchmark. Returns for DisCor are higher than SAC by around 30%; (2) DisCor achieves a non-trivial return on 7/10 tasks after 1000k steps, as compared to 3/10 for unweighted SAC, similar to the trend at 500k steps shown in Figure 8.

F.5 MT50 Multi-Task Experiments
We further evaluated the performance of DisCor on the multi-task MT50 benchmark [14]. This is an extremely challenging benchmark where the task is to learn a single policy that can solve 50 tasks together, with the same evaluation protocol as previously used in the MT10 experiments (Section 7.3 and Appendix F.4). We present the results (average task return and average success rate) in Figures 20. Note that while SAC tends to saturate/plateau in between 4M -8M steps, accounting for corrective feedback via the DisCor algorithm makes the algorithm continue learning in that scenario too.  Table 1: Average Performance of DQN + 3-step returns, DisCor and Discor + 3-step returns on Pong and Breakout at 60M steps into training, rounded off to the nearest integer. Note that DisCor clearly outperforms DQN with multi-step returns. We also find that adding n-step returns to DisCor can hurt, for instance, on Breakout, where the same hurts with DQN as well (for comparison, see Figure 9 in the main paper), however, we still observe that DisCor, when applied with multi-step returns performs better than DQN with multi-step returns as well, indicating the benefits of DisCor even when methods such as multi-step returns are used.

F.6 Comparison with AFM
In this section, we present a comparison of DisCor and AFM [6], a prior method similar to prioritized experience replay on the MuJoCo gym benchmarks. We find that DisCor clearly outperforms AFM in these scenarios. We present these results in Figure 21 where the top row presents results in the case of regular gym benchmarks, and the bottom row presents results in the case of gym benchmarks with stochastic reward noise. F.7 DQN with multi-step returns N-step returns with DQN are hypothesized to stabilize learning since updates to the Q-function now depends on reward values spanning multiple steps, and the coefficient of the bootstrapped Q-value is γ T , which is exponentially smaller than γ used conventionally in Bellman backups, implying that the error accumulation process due to incorrect targets is reduced. Thus, we perform a comparison of DisCor and DQN with n-step backups, where n was chosen to be 3, n = 3, in accordance with commonly used multi-step return settings for Atari games. We present the average return obtained by DisCor and DQN (+n-step), with sticky actions, in Table 1. We clearly observe that DisCor outperforms DQN with 3-step returns in all three games evaluated on. We also observe that n-step returns applied with DisCor also outperform n-step returns applied with DQN, indicating the benefits of using DisCor even when other techniques, such as n-step returns are used.  Figure 21: Performance of DisCor, SAC, PER and AFM on continuous control gym benchmarks (top row) and gym benchmarks with stochastic reward noise (bottom row). Note that DisCor clearly out-performs AFM in both scenarios, on all three benchmarks tested on.

F.8 Code for the Method
The code is shown in Figure 22. It is a simplified version of the code from our implementation of DisCor on top of the official SAC repository [55].  Figure 22: Code for training the error function ∆ φ , and modified training for the Q-function Q(s, a) using ∆ φ to get weights w(s, a) for training. Code written in convention with regular Tensorflow guidelines, in the same style as the official SAC implementation [55].