GenDICE: Generalized Offline Estimation of Stationary Values
Ruiyi Zhang, Bo Dai, Lihong Li, Dale Schuurmans
Introduction
Estimation of quantities defined by the stationary distribution of a Markov chain lies at the heart of many scientific and engineering problems. Famously, the steady-state distribution of a random walk on the World Wide Web provides the foundation of the PageRank algorithm (Langville & Meyer, 2004). In many areas of machine learning, Markov chain Monte Carlo (MCMC) methods are used to conduct approximate Bayesian inference by considering Markov chains whose equilibrium distribution is a desired posterior (Andrieu et al., 2002). An example from engineering is queueing theory, where the queue lengths and waiting time under the limiting distribution have been extensively studied (Gross et al., 2018). As we will also see below, stationary distribution quantities are of fundamental importance in reinforcement learning (RL) (e.g., Tsitsiklis & Van Roy, 1997).
Classical algorithms for estimating stationary distribution quantities rely on the ability to sample next states from the current state by directly interacting with the environment (as in on-line RL or MCMC), or even require the transition probability distribution to be given explicitly (as in PageRank). Unfortunately, these classical approaches are inapplicable when direct access to the environment is not available, which is often the case in practice. There are many practical scenarios where a collection of sampled trajectories is available, having been collected off-line by an external mechanism that chose states and recorded the subsequent next states. Given such data, we still wish to estimate a stationary quantity. One important example is off-policy policy evaluation in RL, where we wish to estimate the value of a policy different from that used to collect experience. Another example is off-line PageRank (OPR), where we seek to estimate the relative importance of webpages given a sample of the web graph.
Motivated by the importance of these off-line scenarios, and by the inapplicability of classical methods, we study the problem of off-line estimation of stationary values via a stationary distribution corrector. Instead of having access to the transition probabilities or a next-state sampler, we assume only access to a fixed sample of state transitions, where states have been sampled from an unknown distribution and next-states are sampled according to the Markov chain’s transition operator. The off-line setting is indeed more challenging than its more traditional on-line counterpart, given that one must infer an asymptotic quantity from finite data. Nevertheless, we develop techniques that still allow consistent estimation under general conditions, and provide effective estimates in practice. The main contributions of this work are:
We formalize the problem of off-line estimation of stationary quantities, which captures a wide range of practical applications.
We propose a novel stationary distribution estimator, GenDICE, for this task. The resulting algorithm is based on a new dual embedding formulation for divergence minimization, with a carefully designed mechanism that explicitly eliminates degenerate solutions.
We theoretically establish consistency and other statistical properties of GenDICE, and empirically demonstrate that it achieves significant improvements on several behavior-agnostic off-policy evaluation benchmarks and an off-line version of PageRank.
The methods we develop in this paper fundamentally extend recent work in off-policy policy evaluation (Liu et al., 2018; Nachum et al., 2019) by introducing a new formulation that leads to a more general, and as we will show, more effective estimation method.
Background
We first introduce off-line PageRank (OPR) and off-policy policy evaluation (OPE) as two motivating domains, where the goal is to estimate stationary quantities given only off-line access to a set of sampled transitions from an environment.
The celebrated PageRank algorithm (Page et al., 1999) defines the ranking of a web page in terms of its asymptotic visitation probability under a random walk on the (augmented) directed graph specified by the hyperlinks. If we denote the World Wide Web by a directed graph with vertices (web pages) and edges (hyperlinks) , PageRank considers the random walk defined by the Markov transition operator :
An important generalization of this stationary value estimation problem arises in RL in the form of policy evaluation. Consider a Markov Decision Process (MDP) (Puterman, 2014), where is a state space, is an action space, denotes the transition dynamics, is a reward function, is a discounted factor, and is the initial state distribution. Given a policy, which chooses actions in any state according to the probability distribution , a trajectory is generated by first sampling the initial state , and then for , , , and . The value of a policy is the expected per-step reward defined as:
In the above, the expectation is taken with respect to the randomness in the state-action pair and the reward . Without loss of generality, we assume the limit exists for the average case, and hence is finite.
An important setting of policy evaluation that often arises in practice is to estimate or given a fixed dataset , where is an unknown distribution induced by multiple unknown behavior policies. This problem is different from the classical form of OPE, where it is assumed that a known behavior policy is used to collect transitions. In the behavior-agnostic scenario, however, typical importance sampling (IS) estimators (e.g., Precup et al., 2000) do not apply. Even if one can assume consists of trajectories where the behavior policy can be estimated from data, it is known that that straightforward IS estimators suffer a variance exponential in the trajectory length, known as the “curse of horizon” (Jiang & Li, 2016; Liu et al., 2018).
With this definition, and can be equivalently re-expressed as
We note that Liu et al. (2018) and Nachum et al. (2019) also exploit Equation 5 to reduce OPE to stationary distribution correction, but these prior works are distinct from the current proposal in different ways. First, the inverse propensity score (IPS) method of Liu et al. (2018) assumes the transitions are sampled from a single behavior policy, which must be known beforehand; hence that approach is not applicable in behavior-agnostic OPE setting. Second, the recent DualDICE algorithm (Nachum et al., 2019) is also a behavior-agnostic OPE estimator, but its derivation relies on a change-of-variable trick that is only valid for . This previous formulation becomes unstable when , as shown in Section 6 and Appendix E. The behavior-agnostic OPE estimator we derive below in Section 3 is applicable both when and . This connection is why we name the new estimator GenDICE, for GENeralized stationary DIstribution Correction Estimation.
GenDICE
As noted, there are important estimation problems in the Markov chain and MDP settings that can be recast as estimating a stationary distribution correction ratio. We first outline the conditions that characterize the correction ratio function , upon which we construct the objective for the GenDICE estimator, and design efficient algorithm for optimization. We will develop our approach for the more general MDP setting, with the understanding that all the methods and results can be easily specialized to the Markov chain setting.
The stationary distribution defined in Equation 4 can also be characterized via
At first glance, this equation shares a superficial similarity to the Bellman equation, but there is a fundamental difference. The Bellman operator recursively integrates out future pairs to characterize a current pair value, whereas the distribution operator defined in Equation 6 operates in the reverse temporal direction.
When , Equation 6 always has a fixed-point solution. For , in the discrete case, the fixed-point exists as long as is ergodic; in the continuous case, the conditions for fixed-point existence become more complicated (Meyn & Tweedie, 2012) and beyond the scope of this paper.
The development below is based on a divergence and the following default assumption.
For the given target policy , the resulting state-action transition operator has a unique stationary distribution that satisfies .
In the behavior-agnostic setting we consider, one does not have direct access to for element-wise evaluation or sampling, but instead is given a fixed set of samples from with respect to some distribution over . Define to be a mixture of and ; i.e., let
Obviously, conditioning on one could easily sample to form ; similarly, a sample could be formed from . Mixing such samples with probability and respectively yields a sample . Based on these observations, the stationary condition for the ratio from Equation 6 can be re-expressed in terms of as
where is the correction ratio function we seek to estimate. One natural approach to estimating is to match the LHS and RHS of Equation 8 with respect to some divergence over the empirical samples. That is, we consider estimating by solving the optimization problem
Although this forms the basis of our approach, there are two severe issues with this naive formulation that first need to be rectified:
Degenerate solutions: When , the operator is invariant to constant rescaling: if then for any . Therefore, simply minimizing the divergence cannot provide a desirable estimate of . In fact, in this case the trivial solution cannot be eliminated.
Intractable objective: The divergence involves the computation of , which in general involves an intractable integral. Thus, evaluation of the exact objective is intractable, and neglects the assumption that we only have access to samples from and are not able to evaluate it at arbitrary points.
We address each of these two issues in a principled manner.
2 Eliminating degenerate solutions
With this additional constraint, it is obvious that the trivial solution is eliminated as an infeasible point of Eqn (10), along with other degenerate solutions with .
Unfortunately, exactly solving an optimization with expectation constraints is very complicated in general (Lan & Zhou, 2016), particularly given a nonlinear parameterization for . The penalty method (Luenberger & Ye, 2015) provides a much simpler alternative, where a sequence of regularized problems are solved
with increasing. The drawback of the penalty method is that it generally requires to ensure the strict feasibility, which is still impractical, especially in stochastic gradient descent. The infinite may induce unbounded variance in the gradient estimator, and thus, divergence in optimization. However, by exploiting the special structure of the solution sets to Equation 11, we can show that, remarkably, it is unnecessary to increase .
For and any , the solution to Equation 11 is given by .
The detailed proof for Theorem 1 is given in Appendix A.1. By Theorem 1, we can estimate the desired correction ratio function by solving only one optimization with an arbitrary .
3 Exploiting dual embedding
For an -divergence with valid defining , the objective is convex w.r.t. .
The detailed proof is provided in Appendix A.2. Recall that a suitable convex function can be represented as , where is the Fenchel conjugate of . In particular, we have the representation , which allows us to re-express the objective as
This yields the main optimization formulation, which avoids the aforementioned difficulties and is well-suited for practical optimization as discussed in Section 3.4.
In addition to -divergence, the proposed estimator Equation 11 is compatible with other divergences, such as the integral probability metrics (IPM) (Müller, 1997; Sriperumbudur et al., 2009), while retaining consistency. Based on the definition of the IPM, these divergences directly lead to - optimizations similar to Equation 13 with the identity function as and different feasible sets for the dual functions. Specifically, maximum mean discrepancy (MMD) (Smola et al., 2006) requires where denotes the RKHS with kernel ; the Dudley metric (Dudley, 2002) requires where ; and Wasserstein distance (Arjovsky et al., 2017) requires . These additional requirements on the dual function might incur some extra difficulty in practice. For example, with Wasserstein distance and the Dudley metric, we might need to include an extra gradient penalty (Gulrajani et al., 2017), which requires additional computation to take the gradient through a gradient. Meanwhile, the consistency of the surrogate loss under regularization is not clear. For MMD, we can obtain a closed-form solution for the dual function, which saves the cost of the inner optimization Gretton et al. (2012), but with the tradeoff of requiring two independent samples in each outer optimization update. Moreover, MMD relies on the condition that the dual function lies in some RKHS, which introduces additional kernel parameters to be tuned and in practice may not be sufficiently flexible compared to neural networks.
4 A Practical Algorithm
We have derived a consistent stationary distribution correction estimator in the form of a - saddle point optimization Equation 13. Here, we present a practical instantiation of GenDICE with a concrete objective and parametrization.
We choose the -divergence, which is an -divergence with and . The objective becomes
There two major reasons for adopting -divergence:
For the alternative divergences, the conjugate of the -divergence involves , which may lead to instability in optimization; while the IPM variants introduce extra constraints on dual function, which may be difficult to be optimized. The conjugate function of -divergence enjoys suitable numerical properties and provides squared regularization. We have provided an empirical ablation study that investigates the alternative divergences in Section 6.3.
To parameterize the correction ratio and dual function we use neural networks, and , where and denotes the parameters of and respectively. Since the optimization requires to be non-negative, we add an extra positive neuron, such as , or at the final layer of . We empirically compare the different positive neurons in Section 6.3.
For these representations, and unbiased gradient estimator can be obtained straightforwardly, as shown in Appendix B. This allows us to apply stochastic gradient descent to solve the saddle-point problem Equation 14 in a scalable manner, as illustrated in Algorithm 1.
Theoretical Analysis
We provide a theoretical analysis for the proposed GenDICE algorithm, following a similar learning setting and assumptions to (Nachum et al., 2019).
The target stationary correction are bounded, .
The main result is summarized in the following theorem. A formal statement, together with the proof, is given in Appendix C.
Under mild conditions, with learnable and , the error in the objective between the GenDICE estimate, , to the solution is bounded by
The theorem shows that the suboptimality of GenDICE’s solution, measured in terms of the objective function value, can be decomposed into three terms: (1) the approximation error , which is controlled by the representation flexibility of function classes; (2) the estimation error due to sample randomness, which decays at the order of ; and (3) the optimization error, which arises from the suboptimality of the solution found by the optimization algorithm. As discussed in Appendix C, in special cases, this suboptimality can be bounded below by a divergence between and , and therefore directly bounds the error in the estimated policy value.
There is also a tradeoff between these three error terms. With more flexible function classes (e.g., neural networks) for and , the approximation error becomes smaller. However, it may increase the estimation error (through the constant in front of ) and the optimization error (by solving a harder optimization problem). On the other hand, if and are linearly parameterized, estimation and optimization errors tend to be smaller and can often be upper-bounded explicitly in Appendix C.3. However, the corresponding approximation error will be larger.
Related Work
Off-policy policy evaluation with importance sampling (IS) has has been explored in the contextual bandits (Strehl et al., 2010; Dudík et al., 2011; Wang et al., 2017), and episodic RL settings (Murphy et al., 2001; Precup et al., 2001), achieving many empirical successes (e.g., Strehl et al., 2010; Dudík et al., 2011; Bottou et al., 2013). Unfortunately, IS-based methods suffer from exponential variance in long-horizon problems, known as the “curse of horizon” (Liu et al., 2018). A few variance-reduction techniques have been introduced, but still cannot eliminate this fundamental issue (Jiang & Li, 2016; Thomas & Brunskill, 2016; Guo et al., 2017). By rewriting the accumulated reward as an expectation w.r.t. a stationary distribution, Liu et al. (2018); Gelada & Bellemare (2019) recast OPE as estimating a correction ratio function, which significantly alleviates variance. However, these methods still require the off-policy data to be collected by a single and known behavior policy, which restricts their practical applicability. The only published algorithm in the literature, to the best of our knowledge, that solves agnostic-behavior off-policy evaluation is DualDICE (Nachum et al., 2019). However, DualDICE was developed for discounted problems and its results become unstable when the discount factor approaches (see below). By contrast, GenDICE can cope with the more challenging problem of undiscounted reward estimation in the general behavior-agnostic setting.
Note that standard model-based methods (Sutton & Barto, 1998), which estimate the transition and reward models directly then calculate the expected reward based on the learned model, are also applicable to the behavior-agnostic setting considered here. Unfortunately, model-based methods typically rely heavily on modeling assumptions about rewards and transition dynamics. In practice, these assumptions do not always hold, and the evaluation results can become unreliable.
Classical MCMC (Brooks et al., 2011; Gelman et al., 2013) aims at sampling from by iteratively simulting from the transition operator. It requires continuous interaction with the transition operator and heavy computational cost to update many particles. Amortized SVGD (Wang & Liu, 2016) and Adversarial MCMC (Song et al., 2017; Li et al., 2019) alleviate this issue via combining with neural network, but they still interact with the transition operator directly, i.e., in an on-policy setting. The major difference of our GenDICE is the learning setting: we only access the off-policy dataset, and cannot sample from the transition operator. The proposed GenDICE leverages stationary density ratio estimation for approximating the stationary quantities, which distinct it from classical methods.
Density ratio estimation is a fundamental tool in machine learning and much related work exists. Classical density ratio estimation includes moment matching (Gretton et al., 2008), probabilistic classification (Bickel et al., 2007), and ratio matching (Nguyen et al., 2008; Sugiyama et al., 2008; Kanamori et al., 2009). These classical methods focus on estimating the ratio between two distributions with samples from both of them, while GenDICE estimates the density ratio to a stationary distribution of a transition operator, from which even one sample is difficult to obtain.
Yao & Schuurmans (2013) developed a reverse-time RL framework for PageRank via solving a reverse Bellman equation, which is less sensitive to graph topology and shows faster adaptation with graph change. However, Yao & Schuurmans (2013) still considers the online manner, which is different with our OPR setting.
Experiments
In this section, we evaluate GenDICE on OPE and OPR problems. For OPE, we use one or multiple behavior policies to collect a fixed number of trajectories at some fixed trajectory length. This data is used to recover a correction ratio function for a target policy that is then used to estimate the average reward in two different settings: i) average reward; and ii) discounted reward. In both settings, we compare with a model-based approach and step-wise weighted IS (Precup et al., 2000). We also compare to Liu et al. (2018) (referred to as “IPS” here) in the Taxi domain with a learned behavior policyWe used the released implementation of IPS (Liu et al., 2018) from https://github.com/zt95/infinite-horizon-off-policy-estimation.. We specifically compare to DualDICE (Nachum et al., 2019) in the discounted reward setting, which is a direct and current state-of-the-art baseline. For OPR, the main comparison is with the model-based method, where the transition operator is empirically estimated and stationary distribution recovered via an exact solver. We validate GenDICE in both tabular and continuous cases, and perform an ablation study to further demonstrate its effectiveness. All results are based on 20 random seeds, with mean and standard deviation plotted. Our code is publicly available at https://github.com/zhangry868/GenDICE.
One direct application of GenDICE is off-line PageRank (OPR). We test GenDICE on a Barabasi-Albert (BA) graph (synthetic), and two real-world graphs, Cora and Citeseer. Details of the graphs are given in Appendix D. We use the -divergence between estimated stationary distribution and the ground truth as the evaluation metric, with the ground truth computed by an exact solver based on the exact transition operator of the graphs. We compared GenDICE with model-based methods in terms of the sample efficiency. From the results in Figure 1, GenDICE outperforms the model-based method when limited data is given. Even with samples for a BA graph with nodes, where a transition matrix has entries, GenDICE still shows better performance in the offline setting. This is reasonable since GenDICE directly estimates the stationary distribution vector or ratio, while the model-based method needs to learn an entire transition matrix that has many more parameters.
We use a similar taxi domain as in Liu et al. (2018), where a grid size of yields states in total (, corresponding to taxi locations, 16 passenger appearance status and taxi status). We set the target policy to a final policy after running tabular Q-learning for iterations, and set another policy after iterations as the base policy. The behavior policy is a mixture controlled by as . For the model-based method, we use a tabular representation for the reward and transition functions, whose entries are estimated from behavior data. For IS and IPS, we fit a policy via behavior cloning to estimate the policy ratio. In this specific setting, our methods achieve better results compared to IS, IPS and the model-based method. Interestingly, with longer horizons, IS cannot improve as much as other methods even with more data, while GenDICE consistently improve and achieves much better results than the baselines. DualDICE only works with . GenDICE is more stable than DualDICE when becomes larger (close to ), while still showing competitive performance for smaller discount factors .
2 Continuous Case
We further test our method for OPE on three control tasks: a discrete-control task Cartpole and two continuous-control tasks Reacher and HalfCheetah. In these tasks, observations (or states) are continuous, thus we use neural network function approximators and stochastic optimization. Since DualDICE (Nachum et al., 2019) has shown the state-of-the-art performance on discounted OPE, we mainly compare with it in the discounted reward case. We also compare to IS with a learned policy via behavior cloning and a neural model-based method, similar to the tabular case, but with neural network as the function approximator. All neural networks are feed-forward with two hidden layers of dimension and activations. More details can be found in Appendix D.
Due to limited space, we put the discrete control results in Appendix E and focus on the more challenging continuous control tasks. Here, the good performance of IS and model-based methods in Section 6.1 quickly deteriorates as the environment becomes complex, i.e., with a continuous action space. Note that GenDICE is able to maintain good performance in this scenario, even when using function approximation and stochastic optimization. This is reasonable because of the difficulty of fitting to the coupled policy-environment dynamics with a continuous action space. Here we also empirically validate GenDICE with off-policy data collected by multiple policies.
As illustrated in Figure 3, all methods perform better with longer trajectory length or more trajectories. When becomes larger, i.e., the behavior policies are closer to the target policy, all methods performs better, as expected. Here, GenDICE demonstrates good performance both on average-reward and discounted reward cases in different settings. The right two figures in each row show the MSE curve versus optimization steps, where GenDICE achieves the smallest loss. In the discounted reward case, GenDICE shows significantly better and more stable performance than the strong baseline, DualDICE. Figure 4 also shows better performance of GenDICE than all baselines in the more challenging HalfCheetah domain.
3 Ablation Study
Finally, we conduct an ablation study on GenDICE to study its robustness and implementation sensitivities. We investigate the effects of learning rate, activation function, discount factor, and the specifically designed ratio constraint. We further demonstrate the effect of the choice of divergences and the penalty weight.
Since we are using neural network as the function approximator, and stochastic optimization, it is necessary to show sensitivity to the learning rate with , with results in Figure 5. When , i.e., the OPE tasks are relatively easier and GenDICE obtains better results at all learning rate settings. However, when , i.e., the estimation becomes more difficult and only GenDICE only obtains reasonable results with the larger learning rate. Generally, this ablation study shows that the proposed method is not sensitive to the learning rate, and is easy to train.
We further investigate the effects of the activation function on the last layer, which ensure the non-negative outputs required for the ratio. To better understand which activation function will lead to stable trainig for the neural correction estimator, we empirically compare using i) ; ii) ; and iii) . In practice, we use the since it achieves low variance and better performance in most cases, as shown in Figure 5.
We vary to probe the sensitivity of GenDICE. Specifically, we compare to DualDICE, and find that GenDICE is stable, while DualDICE becomes unstable when the becomes large, as shown in Figure 6. GenDICE is also more general than DualDICE, as it can be applied to both the average and discounted reward cases.
In Section 3, we highlighted the importance of the ratio constraint. Here we investigate the trivial solution issue without the constraint. The results in Figure 6 demonstrate the necessity of adding the constraint penalty, since a trivial solution prevents an accurate corrector from being recovered (green line in left two figures).
We empirically test the GenDICE with several other alternative divergences, e.g., Wasserstein- distance, Jensen-Shannon divergence, -divergence, Hellinger divergence, and MMD. To avoid the effects of other factors in the estimator, e.g., function parametrization, we focus on the offline PageRank task on BA graph with nodes and offline samples. All the experiments are evaluated with random trials. To ensure the dual function to be -Lipchitz, we add the gradient penalty. Besides, we use a learned Gaussian kernel in MMD, similar to Li et al. (2017). As we can see in Figure 7(a), the GenDICE estimator is compatible with many different divergences. Most of the divergences, with appropriate extra techniques to handle the difficulties in optimization and carefully tuning for extra parameters, can achieve similar performances, consistent with phenomena in the variants of GANs (Lucic et al., 2018). However, -divergence is an outlier, performing noticeably worse, which might be caused by the ill-behaved in its conjugate function. The -divergence and JS-divergence are better, which achieve good performances with fewer parameters to be tuned.
The results of different penalty weights are illustrated in Figure 7(b). We vary the with -divergence. Within a large range of , the performances of the proposed GenDICE are quite consistent, which justifies Theorem 1. The penalty multiplies with . Therefore, with increases, the variance of the stochastic gradient estimator also increases, which explains the variance increasing in large in Figure 7(b). In practice, is a reasonable choice for general cases.
Conclusion
In this paper, we proposed a novel algorithm GenDICE for general stationary distribution correction estimation, which can handle both the discounted and average stationary distribution given multiple behavior-agnostic samples. Empirical results on off-policy evaluation and offline PageRank show the superiority of proposed method over the existing state-of-the-art methods.
The authors would like to thank Ofir Nachum, the rest of the Google Brain team and the anonymous reviewers for helpful discussions and feedback.
References
Appendix A Properties of GenDICE
For notation simplicity, we denote and . Also define . We make the following assumption to ensure the existence of the stationary distribution. Our discussion is all based on this assumption.
Under the target policy, the resulted state-action transition operator has a unique stationary distribution in terms of the divergence .
If the total variation divergence is selected, the Assumption 1 requires the transition operator should be ergodic, as discussed in Meyn & Tweedie (2012).
A.1 Consistency of the Estimator
For arbitrary , the solution to the optimization Eqn (11) is for .
We denote , which is clearly a density function. Then, the optimal conditions in Equation 15 imply
or equivalently, is the stationary distribution of . We have thus shown the optimal is the target density ratio.
A.2 Convexity of the Objective
Proof Since the is convex, we consider the Fenchel dual representation of the -divergence , i.e.,
Appendix B Algorithm Details
We provide the unbiased gradient estimator for in Eqn (14) below:
Then, we have the psuedo code which applies SGD for solving Eqn (14).
Appendix C Proof of Theorem 3
For convenience, we repeat here the notation defined in the main text. The saddle-point reformulation of the objective function of GenDICE is:
To avoid the numerical infinity in , we induced the bounded version as
with optimal , and
We consider the error between and using standard arguments (Shalev-Shwartz & Ben-David, 2014; Bach, 2014), i.e.,
The discrepancy and if and only if is stationary distribution of in the weak sense of .
In some special cases, the suboptimality also implies the distance between and . Specifically,for , if the transition operator can be represented as where denotes the (countable) eigenfunctions and denotes the diagonal matrix with eigenvalues, the largest of which is . We consider as identity and , then the will bounded from below by a metric between and . Particularly, we have
Rewrite , where , then
Recall the optimality of , i.e., , we have
C.1 Error Decomposition
We start with the following error decomposition:
We consider the terms one-by-one. By definition, we have
which is induced by introducing for dual approximation.
For the third term , we have
For the term ,
where we define .
Therefore, we can now bound as
We consider the terms from right to left. For the term , we have
which is induced by restricting the function space to . The second term is nonpositive, due to the optimality of . The final inequality comes from the fact that is -Lipschitz w.r.t. .
For the term , by definition
For the term , we have
where the second term is nonpositive, thanks to the optimality of .
Finally, for the term , using the same argument in Equation 21, we have
Therefore, we can bound by
In the following sections, we will bound the and .
C.2 Statistical Error
In this section, we analyze the statistical error
We mainly focus on the batch RL setting with i.i.d. samples , which has been studied by previous authors (e.g., Sutton et al., 2012; Nachum et al., 2019). However, as discussed in the literature (Antos et al., 2008; Lazaric et al., 2012; Dai et al., 2018; Nachum et al., 2019), using the blocking technique of Yu (1994), the statistical error provided here can be generalized to -mixing samples in a single sample path. We omit this generalization for the sake of expositional simplicity.
To bound the , we follow similar arguments by Dai et al. (2018); Nachum et al. (2019) via the covering number. For completeness, the definition is given below.
The Pollard’s tail inequality bounds the maximum deviation via the covering number of a function class:
Let be a permissible class of functions and are i.i.d. samples from some distribution. Then, for any given ,
The covering number can then be bounded in terms of the function class’s pseudo-dimension:
For any set , any points , any class of functions on taking values in with pseudo-dimension , and any ,
The statistical error can be bounded using these lemmas.
Under the Assumption 2, if is -Lipschitz continuous and the psuedo-dimension of and are finite, with probability at least , we have
Proof The proof works by verifying the conditions in Lemma 4 and computing the covering number.
Denote the , we will apply Lemma 4 with , , and .
We check the boundedness of . Based on Assumption 2, we only consider the and bounded by and . We also rectify the . Then, we can bound the :
where . Thus, by Lemma 4, we have
Next, we check the covering number of . Firstly, we bound the distance in ,
Denote the pseudo-dimension of and as and , respectively, we have
where and
Combine this result with Equation 23, we obtain the bound for the statistical error:
Setting with , we have
C.3 Optimization Error
In this section, we investigate the optimization error
Notice our estimator is compatible with different parametrizations for and different optimization algorithms, the optimization error will be different. For the general neural network for , although there are several progress recently (Lin et al., 2018; Jin et al., 2019; Lin et al., 2019) about the convergence to a stationary point or local minimum, it remains a largely open problem to quantify the optimization error, which is out of the scope of this paper. Here, we mainly discuss the convergence rate with tabular, linear and kernel parametrization for .
Particularly, we consider the linear parametrization particularly, i.e., with and . With such parametrization, the is still convex-concave w.r.t .
We can bound the by the primal-dual gap :
C.4 Complete Error Analysis
We are now ready to state the main theorm in a precise way:
where . For , we can apply the results for SGD in Appendix C.3.
Plug all these bounds into Equation 25, we achieve the conclusion.
Appendix D Experimental Settings
For the Taxi domain, we follow the same protocol as used in Liu et al. (2018). The behavior and target policies are also taken from Liu et al. (2018) (referred in their work as the behavior policy for ). We use a similar taxi domain, where a grid size of yields states in total (, corresponding to taxi locations, 16 passenger appearance status and taxi status). We set our target policy as the final policy after running Q-learning (Sutton & Barto, 1998) for iterations, and set another policy after iterations as our base policy. The behavior policy is a mixture policy controlled by as , i.e., the larger is, the behavior policy is more close to the target policy. In this setting, we solve for the optimal stationary ratio exactly using matrix operations. Since Liu et al. (2018) perform a similar exact solve for variables , for better comparison we also perform our exact solve with respect to variables . Specifically, the final objective of importance sampling will require knowledge of the importance weights .
For offline PageRank, the graph statistics are illustrated in Table 1, and the degree statistics and graph visualization are shown in Figure 8. For the Barabasi–Albert (BA) Graph, it begins with an initial connected network of nodes in the network. Each new node is connected to existing nodes with a probability that is proportional to the number of links that the existing nodes already have. Intuitively, heavily linked nodes (‘hubs’) tend to quickly accumulate even more links, while nodes with only a few links are unlikely to be chosen as the destination for a new link. The new nodes have a ‘preference’ to attach themselves to the already heavily linked nodes. For two real-world graphs, it is built upon the real-world citation networks. In our experiments, the weights of the BA graph is randomly drawn from a standard Gaussian distribution with normalization to ensure the property of the transition matrix. The offline data is collected by a random walker on the graph, which consists the initial state and next state in a single trajectory. In experiments, we vary the number of off-policy samples to validate the effectiveness of GenDICE with limited offline samples provided.
D.2 Continuous Case
We use the Cartpole, Reacher and HalfCheetah tasks as given by OpenAI Gym. In importance sampling, we learn a neural network policy via behavior cloning, and use its probabilities for computing importance weights . All neural networks are feed-forward with two hidden layers of dimension and activations.
We modify the Cartpole task to be infinite horizon: We use the same dynamics as in the original task but change the reward to be if the original task returns a termination (when the pole falls below some threshold) and otherwise. We train a policy on this task with standard Deep Q-Learning (Mnih et al., 2013) until convergence.
We then define the target policy as a weighted combination of this pre-trained policy (weight ) and a uniformly random policy (weight ). The behavior policy for a specific is taken to be a weighted combination of the pre-trained policy (weight ) and a uniformly random policy (weight ). We train each stationary distribution correction estimation method using the Adam optimizer with batches of size and learning rates chosen using a hyperparameter search from and choose the best one as .
For the Reacher task, we train a deterministic policy until convergence via DDPG (Lillicrap et al., 2015). We define the target policy as a Gaussian with mean given by the pre-trained policy and standard deviation given by . The behavior policy for a specific is taken to be a Gaussian with mean given by the pre-trained policy and standard deviation given by . We train each stationary distribution correction estimation method using the Adam optimizer with batches of size and learning rates chosen using a hyperparameter search from and the optimal learning rate found was ).
For the HalfCheetah task, we also train a deterministic policy until convergence via DDPG (Lillicrap et al., 2015). We define the target policy as a Gaussian with mean given by the pre-trained policy and standard deviation given by . The behavior policy for a specific is taken to be a Gaussian with mean given by the pre-trained policy and standard deviation given by . We train each stationary distribution correction estimation method using the Adam optimizer with batches of size and learning rates chosen using a hyperparameter search from and the optimal learning rate found was .
Appendix E Additional Experiments
On the discrete control task, we modify the Cartpole task to be infinite horizon: the original dynamics is used but with a modified reward function: the agent will receive if the environment returns a termination (i.e., the pole falls below some threshold) and 1 otherwise. As shown in Figure 3, our method shows competitive results with IS and Model-Based in average reward case, but our proposed method finally outperforms these two methods in terms of log MSE loss. Specifically, it is relatively difficult to fit a policy with data collected by multiple policies, which renders the poor performance of IS.
E.2 Additional Results on Continuous Control
In this section, we show more results on the continuous control tasks, i.e., HalfCheetah and Reacher. Figure 10 shows the MSE towards training steps, and GenDICE outperforms other baselines with different behavior policies. Figure 11 better illustrates how our method beat other baselines, and can accurately estimate the reward of the target policy. Besides, Figure 12 shows GenDICE gives better reward estimation of the target policy. In these figures, the left three figures show the performance with off-policy dataset collected by single behavior policy from more difficult to easier tasks. The right two figures show the results, where off-policy dataset collected by multiple behavior policies.
Figure 13 shows the ablation study results in terms of estimated rewards. The left two figures shows the effects of different learning rate. When , i.e., the OPE tasks are relatively easier, GenDICE gets relatively good results in all learning rate settings. However, when , i.e., the estimation becomes more difficult, only GenDICE in larger learning rate gets reasonable estimation. Interestingly, we can see with larger learning rates, the performance becomes better, and when learning rate is with , the variance is very high, showing some cases the estimation becomes more accurate. The right three figures show different activation functions with different behavior policy. The square and softplus function works well; while the exponential function shows poor performance under some settings. In practice, we use the square function since its low variance and better performance in most cases.
E.3 Comparison with self-normalization trick
The self-normalization trick used in Liu et al. (2018) encodes the normalization constraint in , while the principled optimization technique is considered in GenDICE. Further, the self-normalization trick will lead to several disadvantages theoretically, in both statistical and computational aspects :
It will induce more computational cost. Specifically, the self-normalized ratio will be in the form of , which requires to go through all the samples in training set even for just estimating one stochastic gradient, and thus, is prohibitive for large dataset.
Empirically, self-normalization is the most natural and the first idea we tried during this project. We have some empirical results about this method in the OPR setting.
Despite the additional computational cost, it performs worse than the proposed regularization technique used in the current version of GenDICE. Table 2 shows a comparison between self-normalization and regularization on OPR with -divergence for BA graph with 100 nodes, 10,000 offline samples, and 20 trials. We stop the algorithms in the same running-time budget.