D OUBLY R OBUST B IAS R EDUCTION IN I NFINITE H ORIZON O FF -P OLICY E STIMATION
Li
Google Research
A BSTRACT
Inﬁnite horizon off-policy policy evaluation is a highly challenging task due to the excessively large variance of typical importance sampling (IS) estimators.
Recently,
Liu et al.
(2018a) proposed an approach that substantially reduces the variance of inﬁnite-horizon off-policy evaluation by estimating the stationary density ratio, but at the cost of introducing potentially high biases due to the error in density ratio estimation.
In this paper, we develop a bias-reduced augmentation of their method, which can take advantage of a learned value function to improve accuracy.
Our method is doubly robust in that the bias vanishes when either the density ratio or value function estimation is perfect.
In general, when either of them is accurate, the bias can also be reduced.
Both theoretical and empirical results show that our method yields signiﬁcant advantages over previous methods.
I NTRODUCTION
A key problem in reinforcement learning (RL) (Sutton & Barto, 1998) is off-policy policy evaluation: given a ﬁxed target policy of interest, estimating the average reward garnered by an agent that follows the policy, by only using data collected from different behavior policies .
This problem is widely encountered in many real-life applications (e.g., Murphy et al., 2001;
Li et al., 2011; Bottou et al., 2013; Thomas et al., 2017), where online experiments are expensive and high-quality simulators are difﬁcult to build.
It also serves as a key algorithmic component of off-policy policy optimization (e.g.,
Dud ´ ık et al., 2011; Jiang & Li, 2016; Thomas & Brunskill, 2016; Liu et al., 2019b).
There are two major families of approaches to policy evaluation.
The ﬁrst approach is to build a simulator that mimics the reward and next-state transitions of the real environment (e.g., Fonteneau et al., 2013).
While straightforward, this approach strongly relies on the model assumptions in building the simulator, which may invalidate evaluation results.
The second approach is to use importance sampling to correct the sampling bias in off-policy data, so that an (almost) unbiased estimator can be obtained (Liu, 2001; Strehl et al., 2010; Bottou et al., 2013).
A major limitation, however, is that importance sampling can become inaccurate due to high variance.
In particular, most existing IS-based estimators compute the weight as the product of the importance ratios of many steps in the trajectory, causing excessively high variance for problems with long or inﬁnite horizon, yielding a curse of horizon (Liu et al., 2018a).
Recently, Liu et al.
(2018a) proposes a new estimator for inﬁnite-horizon off-policy evaluation, which presents signiﬁcant advantages to standard importance sampling methods.
Their method directly estimates the density ratio between the state stationary distributions of the target and behavior policies, instead of the trajectories, thus avoiding exponential blowup of variance in the horizon.
While Liu et al.
’s
method shows much promise by signiﬁcantly reducing the variance , in practice, it may suffer from high bias due to the error or model misspecﬁciation when estimating the density ratio function.
In this paper, we develop a doubly robust estimator for inﬁnite horizon off-policy estimation, by integrating Liu et al.
’s method with information from an additional value function estimation.
This signiﬁcantly reduces the bias of Liu et al.
’s method once either the density ratio, or the value function estimation is accurate (hence doubly robust).
Since Liu et al.
’s
method already promises low variance, our additional bias reduction allows us to achieve signiﬁcantly better accuracy for practical problems.
Technically, our new bias reduction method provides a new angle of double robustness for off-policy evaluation, orthogonal to the existing literature of doubly robust policy evaluation that solely devotes to variance reduction (Jiang & Li, 2016; Thomas & Brunskill, 2016; Farajtabar et al., 2018), mostly based on the idea of control variates (e.g. Asmussen & Glynn, 2007).
Our double robustness for bias reduction is signiﬁcantly different, and instead yields an intriguing connection with the fundamental primal-dual relations between the density (ratio) functions and value functions (e.g., Bertsekas, 2000;
Puterman, 2014).
This new perspective can inspire more efﬁcient algorithms for policy evaluation, and lead to uniﬁed frameworks for these types of double robustness in future work.
B ACKGROUND
Inﬁnite Horizon Off-Policy Estimation Let M =
(cid:104)S , A , r, T , µ 0 (cid:105) be a Markov decision process (MDP) with state space S , action space A , reward function r , transition probability function T , and initial-state distribution µ 0 .
A policy π maps states to distributions over A , with π ( a | s ) being the probability of selecting a given s .
The average discounted reward for π , with a given discount γ ∈ (0 , 1) 1 , is deﬁned as
[Equation]
where τ = { s t , a t , r t } 0 ≤ t ≤ T is a trajectory with states, actions, and rewards collected by following policy π in the MDP, starting from s 0 ∼ µ 0 .
Given a set of n trajectories, D = { s ( i ) t , a ( i ) t , r
( i ) t } 1 ≤ i ≤ n, 0 ≤ t ≤ T , collected under a behavior policy π 0 ( a | s ) , the off-policy evaluation problem aims to estimate the average discounted reward R π for another target policy π ( a | s ) .
Estimation via Value Function
The value function for policy π is deﬁned as the expected accumulated discounted future rewards started from a certain state:
V π ( s ) =
E τ ∼ π
[ (cid:80) ∞ {+t =
+}
γ t r {+t | s 
+}
= s ] .
We use r π ( s ) =
E a ∼ π ( ·| s )
[ r ( s, a )] to denote the average reward for state s given policy π .
Under the deﬁnition, the value function can be seen as a ﬁxed point of the Bellman equation:
[Equation]
where P π V ( s ) is the average of the next value function given the current state s and policy π ; see
Appendix A.1 for details.
The value function and the expected reward R π is related in the following straightforward way
[Equation]
where the expectation is with respect to the distribution µ 0 ( s ) of the initial states s 0 at time t .
Therefore, given an approximation (cid:98) V of V π , and samples D 0 :=
{ s ( i ) 0 } 1 ≤ i ≤ n 0 drawn from µ 0 ( s ) , we can estimate R π by
[Equation]
Note that this estimator is off-policy in nature, since it requires no samples from the target policy π .
Estimation via State Density Function Denote d π,t ( · ) as average visitation of s t in time step t .
The state density function, or the discounted average visitation, is deﬁned as:
[Equation]
where (1 − γ ) can be viewed as the normalization factor introduced by (cid:80) ∞ t =0 γ t .
Similar to Bellman equation for value function, the state density function can also be viewed as a ﬁxed point to the following recursive equation (Liu et al., 2018a, Lemma 3):
[Equation]
where
[Equation]
The operator T π is an adjoint operator of P π used in (1); see Appendix A.1 for a discussion.
If the density function d π is known, it provides an alternative way for estimating the expected reward
R π , by noting that
[Equation]
We can see that both density function d π and value function V π can be used to estimate the expected reward R π .
We clarify the connection in detail in Appendix A.1.
Off-Policy State Visitation Importance Sampling Equation (4) can not be directly used for offpolicy estimation, since it involves expectation under the behavior policy π .
Liu et al.
(2018a) addressed this problem by introducing a change of measures via importance sampling:
[Equation]
with
[Equation]
where w π/π 0 ( s ) is the density ratio function of d π and d π 0 .
Given an approximation (cid:98) w of w π/π 0 , and samples D = { s ( i ) t , a ( i ) t , r ( i ) t } 1 ≤ i ≤ n, 0 ≤ t ≤ T collected from policy π 0 , we can estimate R π as:
[Equation]
where Z is the normalized constant of the importance weights.
D OUBLY R OBUST E STIMATOR
Doubly robust estimator is ﬁrst proposed into reinforcement learning community to solve contextual bandit problem by Dud ´ ık et al.
(2011) as an estimator combining inverse propensity score (IPS) estimator and direct method (DM) estimator.
Jiang & Li (2016) introduce the idea of doubly robust estimator into off-policy evaluation in reinforcement learning.
It incorporates an approximate value function as a control variate to reduce the variance of importance sampling estimator.
Inspired by previous works, we propose a new doubly robust estimator based on our inﬁnite horizon off-policy estimator (cid:98) R π SIS .
3. D OUBLY R OBUST E STIMATOR FOR I NFINITE H ORIZON MDP
The value-based estimator (cid:98) R π VAL [ (cid:98) V ] and density-ratio-based estimator (cid:98) R π SIS [ (cid:98) w ] are expected to be accurate when (cid:98) V and (cid:98) w are accurate, respectively.
Our goal is to combine their advantages, obtaining a doubly robust estimator that is accurate once either (cid:98) V or (cid:98) w or is accurate.
To simplify the problem, it is useful to examine the limit of inﬁnite samples, with which (cid:98) R π VAL [ (cid:98) V ] and (cid:98) R π SIS
[ (cid:98) w ] converge to the following limit of expectations:
[Equation]
Here and throughout this work, we assume (cid:98) V and (cid:98) w are ﬁxed pre-deﬁned approximations, and only consider the randomness from the data D .
A ﬁrst observation is that we expect to have r π ≈ (cid:98) V − γ P π (cid:98) V by Bellman equation (1), when ˆ V approximates the true value V π .
Plugging this into R π SIS [ (cid:98) w ] in Equation (7), we obtain the following “bridge estimator”, which incorporates information from both (cid:98) w and (cid:98) V :
[Equation]
where operator P π is deﬁned in Bellman equation (1).
The corresponding empirical estimator is deﬁned by
[Equation]
where Z
[Equation]
( i ) t ) are selfnormalized constant of important weights each empirical estimation.
However, directly estimating R π using the bridge estimator (cid:98) R π bridge [ (cid:98) V , (cid:98) w ] yields a poor estimation, because it includes the errors from both (cid:98) w and (cid:98) V and can be “ doubly worse ”.
However, we can construct our “ doubly robust ” estimator by canceling R π bridge [ (cid:98) V , (cid:98) w ] out from R π SIS [ (cid:98) w ] and R π VAL [ (cid:98) V ] :
[Equation]
[ (cid:98)
[Equation]
[Equation]
=
[Equation]
And its corresponding empirical estimator can be written as:
[Equation]
Doubly Robust Bias Reduction The double robustness of (cid:98) R π DR [ (cid:98) V , (cid:98) w ] is reﬂected in the following key theorem, which shows that it is accurate once either (cid:98) V or (cid:98) w is accurate.
Theorem 3.1 (Doubly Robustness) .
Let R π DR [ (cid:98) V , (cid:98) w ] :=
lim n 0 ,n,T →∞ (cid:98) R π DR [ (cid:98) V , (cid:98) w ] be the limit of (cid:98) R π DR when it has inﬁnite samples.
Following the deﬁnition above, we have
[Equation]
[Equation]
where ε (cid:98) V and ε (cid:98) w are errors of (cid:98) V and (cid:98) w , respective, deﬁned as follows
[Equation]
The error ε (cid:98) w of (cid:98) w is measured by the difference with the true density ratio d π ( s ) /d
π 0 ( s ) , and the error ε (cid:98) V of (cid:98) V is measured using the Bellman residual.
From the theorem we can see that, if (cid:98) V is exact ( (cid:98) V ≡ V π ), we have ε (cid:98) V ≡ 0 ; if (cid:98) w is exact ( (cid:98) w ≡ d π /d π 0 ), we have ε (cid:98) w ≡ 0 .
Therefore, our estimator is consistent (i.e., lim n,n 0 →∞ (cid:98) R π DR [ (cid:98) V , (cid:98) w ]
= R π ) if either (cid:98) V or (cid:98) w are exact.
The estimator is thus doubly robust in this sense.
In contrast, (cid:98) R π SIS [ (cid:98) w ] and (cid:98) R π VAL [ (cid:98) V ] can be more sensitive to the error of (cid:98) w and (cid:98) V , respectively:
[Equation]
Variance Analysis Different from the bias reduction, the doubly robust estimator does not guarantee to the reduce the variance over (cid:98) R π SIS [ (cid:98) w ] or (cid:98) R π VAL [ (cid:98) V ] in general.
However, as we show in the following result, we can break the variance of (cid:98) R π DR [ (cid:98) V , (cid:98) w ] into two parts.
The ﬁrst is the variance of (cid:98) R π VAL [ (cid:98) V ] which is often relatively small.
The second is generally no greater than the variance of (cid:98) R π SIS [ (cid:98) w ] , and can be much smaller when (cid:98) V ≈ V π .
Moreover, (cid:98) R π VAL [ (cid:98) V ] and (cid:98) R π SIS
[ (cid:98) w ] avoid the curse of horizon by design, so their variances tend to be much smaller than the corresponding estimators that apply IPS correction on the trajectories. Input : Transition data D π [Equation] = { s ( i ) t , a ( i ) t , r
( i ) t [Equation] 1 ≤ i ≤ n [Equation]
0 ≤ t ≤ T from policy π
[Equation]
{+D 
+}
= { s ( j ) 0 } 1 ≤ j ≤ n 0 be samples from initial distribution µ
[Equation]
target policy π , value function estimate (cid:98) V ; density ratio estimate (cid:98) w .
Estimation: Use (cid:98) R π DR in (11) to estimate R π using sample from D and D 0 .
Proposition 3.1 (Variance Analysis) .
Assume (cid:98) R π DR [ (cid:98) V , (cid:98) w ] is estimated based on sample D 0 ∼ µ 0 and
D π 0 ∼ d π 0 , which we assume to be independent of each other.
We have
[Equation]
, (13) with (cid:98) R π res [ (cid:98) V , (cid:98) w ] := (cid:98) R π SIS [ (cid:98) w ] − (cid:98) R π bridge [ (cid:98) V , (cid:98) w ] = (cid:98) E D π 0 (cid:2)(cid:98)
ε ˆ V ( s ) (cid:98) w ( s ) (cid:3) and (cid:98)
ε ˆ V ( s ) the TD error of (cid:98) V , (cid:98) ε (cid:98) V
( s ) = (cid:99) r π ( s ) − (cid:98) V ( s ) + γ (cid:99) P π (cid:98) V ( s ) , with (cid:99) r π ( s )
=
r ( s, a ) π ( a | s ) /π[-
-]
[Equation]
a | s ) [-/π 
-], [Equation] =
[Equation]
Therefore,
Var D π 0 ( (cid:98) R π res
[ (cid:98) V , (cid:98) w ]) can be small when (cid:98) V is close to the true value V π , or (cid:98)
ε (cid:98) V ( s )
≈ 0 .
From the proposition we can see that when (cid:98) V is close to the true value V π , the variance of the residual (cid:98) ε (cid:98) V may be negligibly small compared to the variance of (cid:98) R π SIS [ (cid:98) w ] .
A further comparison of the variances between (cid:98) R π res [ (cid:98) V , (cid:98) w ] and (cid:98) R π SIS [ (cid:98) w ] is provided in Appendix A.3.
In the case when the TD error (cid:98) ε
ˆ V is negligible, we have Var D 0 , D π 0 (cid:104) (cid:98) R π DR
[ (cid:98) V , (cid:98) w ] (cid:105)
≈
Var D 0 (cid:104) (cid:98) R π VAL
[ (cid:98) V ] (cid:105) .
Typically, the variance of (cid:98) R π VAL [ (cid:98) V ] is smaller than (cid:98) R π SIS [ (cid:98) w ] since the variance of importance sampling methods heavily depends on the effective sample size, which is less controllable compared to (cid:98) R π VAL [ (cid:98) V ] .
Therefore, the variance of our doubly robust estimator may even be smaller than that of (cid:98) R π SIS [ (cid:98) w ] in practice.
The variance in (13) is a sum of two terms because of the assumption that samples from µ 0 and d πare independent.
In practice, they have dependency but it is possible to couple the samples from µand d π 0 in a certain way to further decrease the variance, which we leave as future work.
Proposed Algorithm for Off-Policy Evaluation Suppose we have already obtained (cid:98) V and (cid:98) w , as estimations of V π and w π/π 0 , respectively, we can directly use equation (11) to estimate R π .
A detail procedure is described in Algorithm 1.
D OUBLE R OBUSTNESS AND L AGRANGIAN D UALITY
In this section, we reveal a surprising connection between our double robustness and Lagrangian duality.
We show that our doubly robust estimator is equivalent to the Lagrangian function of a primal-dual formulation of policy evaluation.
This connection is of interest in itself, and may provide a foundation for deriving more effective algorithms.
We start with the following classic, optimization formulation of policy evaluation (Puterman, 2014):
[Equation]
where we ﬁnd V to maximize its average value, subject to an inequality constraint on the Bellman equation.
It can be shown that the solution of (14) is achieved by the true value function V π , hence yielding a true expected reward R π .
Introducing a Lagrangian multiplier ρ ≥ 0 , we can derive the Lagrangian function L ( V, ρ ) of (14),
[Equation]
[Equation] Comparing L ( V, ρ ) with our estimator (cid:98) R π DR [ (cid:98) V , (cid:98) w ] in (11), we can see that they are in fact equivalent in expectation.
Theorem 4.1 (Primal Dual) .
I) Deﬁne w ρ/π 0 ( s ) =
ρ ( s ) d π 0 ( s ) .
We have
L [Equation] [Equation] R
[Equation]
[Equation] [Equation] [Equation] ] , and hence
[Equation]
which suggests that L ( V, ρ ) is “doubly robust” in that it equals R π if either V
= V π or ρ =
d π .
II)
The primal problem (14) forms a strong duality with the following dual problem,
[Equation]
where T π is deﬁned in (3) .
This shows that the dual problem is equivalent to constraint ρ using the ﬁxed point equation (3) and maximize the average reward given distribution ρ .
Since the unique ﬁxed point of (3) is d π ( s ) , the solution of (16) naturally yields the true reward R π , hence forming a zero duality gap with (14).
It is natural to intuit the double robustness of the Lagrangian function.
From (15), L ( V, ρ ) can be viewed as estimating the reward R π using value function with a correction of Bellman residual ( V − r π − γ P π V ) .
If V = V π , the estimation equals the true reward and the correction equals zero.
From the dual problem (16), L ( V, ρ ) can be viewed as estimating R π using density function ρ , corrected by the residual ( ρ − (1 − γ ) µ 0 − γ T π ρ ) .
We again get the true reward if ρ = d π .
It turns out that we can use the primal-dual formula when γ = 1 to obtain the double robust estimator for the average reward case.
We clarify it in appendix B.
Remark
The fact that the density function d π forms a dual variable of the value function V π is widely known in the optimal control and reinforcement learning literature (e.g., Bertsekas, 2000;
Puterman, 2014; de Farias & Van Roy, 2003), and has been leveraged in various works for policy optimization.
However, it does not seem to be well exploited in the literature of off-policy policy evaluation.
R ELATED W ORK
Off-Policy Value Evaluation
The problem of off-policy value evaluation has been studied in contextual bandits (Fonteneau et al., 2013;
Li et al., 2015; Jiang & Li, 2016; Thomas & Brunskill, 2016; Liu et al., 2018b; Farajtabar et al., 2018; Hanna et al., 2019; Xie et al., 2019; Rowland et al., 2019).
However, most of the existing works are based on importance sampling (IS) to correct the mismatch between the distribution of the whole trajectories induced by the behavior and target policies, which faces the “curse of horizon” (Liu et al., 2018a) when extended to long-horizon (or inﬁnite-horizon) problems.
Several other works (Guo et al., 2017; Hallak & Mannor, 2017; Liu et al., 2018a; Gelada & Bellemare, 2019; Nachum et al., 2019; Liu et al., 2019a) have been proposed to address the high variance issue in the long-horizon problems.
Liu et al.
(2018a) apply importance sampling on the average visitation distribution of state-action pairs, instead of the distribution of the whole trajectories, which provides a uniﬁed approach to break “the curse of horizon”.
However, they require to learn a density ratio function over the whole state-action pairs, which may induce large bias.
Our work incorporates the density ratio and value function estimation, which signiﬁcantly reduces the induced bias of two estimators, resulting a doubly robust estimator.
Our work is also closely related to DR techniques used in ﬁnite horizon problems (Murphy et al., 2001; Dud´ık et al., 2011; Jiang & Li, 2016; Thomas & Brunskill, 2016; Farajtabar et al., 2018), which incorporate an approximate value function as control variates to IS estimators.
Different from existing DR approaches, our work is related to the well known duality between the density and the value function, which reveals the relationship between density (ratio) learning (Liu et al., 2018a) and value function learning.
Based on this interesting observation, we further obtain the doubly robust estimator for estimating average reward in inﬁnite-horizon problems.
A recent work (Xie et al., 2019) has also explored the idea of tracking marginal state distribution shifts at every single time step in an episode, instead of the stationary state distribution across all time steps (Liu et al., 2018a).
It provides additional beneﬁts for understanding and analyzing problems [Figure] such as short horizon and time-variant MDPs.
They call this approach marginalized importance sampling (MIS).
Later on, Kallus & Uehara (2019a) incorporate the DR technique to improve the
MIS estimator.
Independent of this work, Kallus & Uehara (2019b) extend the technique to the inﬁnite horizon setting, whose estimator can be viewed as a variant of ours.
Primal-Dual Value Learning Primal-dual optimization techniques have been widely used for off-policy value function learning and policy optimization (Liu et al., 2015; Chen & Wang, 2016;
Dai et al., 2017a;b; Feng et al., 2019).
Nevertheless, the duality between density and value function has not been well explored in the literature of off policy value estimation.
Our work proposes a new doubly robustness technique for off-policy value estimation, which can be naturally viewed as the
Lagrangian function of the primal-dual formulation of policy evaluation, providing an alternative uniﬁed view for off policy value evaluation.
E XPERIMENT
In this section, we conduct simulation experiments on different environmental settings to compare our new doubly robust estimator with existing methods.
We mainly compare with inﬁnite horizon based estimator including state importance sampling estimator (Liu et al.
(2018a))
and value function estimator.
We do not report results on the vanilla trajectory-based importance sampling estimators because of their signiﬁcant higher variance, but we do compare with the doubly robust version induced by Thomas & Brunskill (2016) (self-normalized variant of Jiang & Li (2016)).
In all experiments we compare with Monte Carlo and naive average as Liu et al.
(2018a) suggested.
The ground truth for each environment is calculated by averaging Monte Carlo estimation with a very large sample size.
[Figure]
[Figure]
Taxi Environment We follow Liu
We pre-train two different (cid:98) V and ˜ V trained with a small and fairly large size of samples, respectively, where ˜ V is very close to true value function V π
but (cid:98) V is relatively further from it.
Similarly we pre-train (cid:98) ρ and ˜ ρ ≈ d π .
For estimation we use a mixed ratio α, β to control the bias of the input V, ρ , where V = α (cid:98) V + (1 − α )
˜ V and ρ = β (cid:98) ρ
+ (1 − β )˜ ρ .
Figure 1(a)-(c) show results of comparison for different methods as we changing the number of trajectories.
We can see that the MSE performance of value function( (cid:98) R π VAL ) and state visitation importance sampling( (cid:98) R π SIS ) estimators are mainly impeded by their large biases, while our method has much less bias thus it can keep decreasing as sample size increase and achieves same performance as on policy estimator.
Figure 1(d) shows results if we change the horizon length.
Notice that here we keep the number of samples to be the same, so if we increase our horizon length we will decrease the number of trajectories in the same time.
We can see that our method alongside with all inﬁnite horizon methods will get better result as horizon length increase.
Figure 1(e)-(f) indicate the “double robustness” of our method, where our method beneﬁts from either a better V or a better ρ .
Puck-Mountain Puck-Mountain is an environment similar to Mountain-Car, except that the goal of Puck-Mountain is to push the puck as high as possible in a local valley, which has a continuous state space of R 2 and a discrete action space similar to Mountain-Car.
We use the softmax functions of an optimal Q-function as both target policy and behavior policy, where the temperature of the behavior policy is higher (encouraging exploration).
For more details of constructing policies and training algorithms for density ratio and value functions, please check appendix C.2.
Figure 2(a)-(c) show results of comparison for different methods as we changing the number of trajectories.
Similar to taxi, we ﬁnd our method has much lower bias than density ratio and value function estimation, which yields a better MSE.
In Figure 2(d) the performance for all inﬁnite horizon estimator will not degenerate as horizon increases, while ﬁnite horizon method such as ﬁnite weighted horizon doubly robust will suffer from larger variance as horizon increases.
InvertedPendulum InvertedPendulum is a pendulum that has its center of mass above its pivot point.
We use the implementation of InvertedPendulum from OpenAI gym
(Brockman et al., 2016), which is a continuous control task with state space in R
and we discrete the action space to be {− 1 , − 0 .
3 , − 0 .
More experiment details can be found in appendix C.2.
In Figure 3(a)-(c) our method again signiﬁcantly reduces the bias, which yields a better MSE comparing with value and density estimation.
Figure 3(d) also shows that our method consistently outperforms all other methods as the horizon increases with a ﬁxed total timesteps.
C ONCLUSION
In this paper, we develop a new doubly robust estimator based on the inﬁnite horizon density ratio and off policy value estimation.
Our new proposed doubly robust estimator can be accurate as long as one of the estimators are accurate, which yields a signiﬁcant advantage comparing to previous estimators.
Future directions include deriving more novel optimization algorithms to learn value function and density(ratio) function by using the primal dual framework.
A CKNOWLEDGEMENT
This work is supported in part by NSF CRII 1830161 and NSF CAREER 1846421.
We would like to acknowledge Google Cloud for their support.
A P ROOF A. T RANSITION O PERATOR FOR B ELLMAN E QUATION
For simplicity, we deﬁne the following two operators thorough our proofs to simplify our notations.
Deﬁnition A.1.
Given a policy π and the unknown environment transition T , we deﬁne T π and P π over any function f : S → R as
[Equation]
Using these operator notations, we can rewrite the above two recursive equations as:
[Equation]
where r π ( s )
=
E a ∼ π ( ·| s )
[ r ( s, a )] .
These transition operators have the following nice adjoint property.
Lemma A.2.
For two function f and g , if the following summation is ﬁnite, we will have
[Equation]
Proof.
(cid:88)
[Equation]
Using this property we can actually using Bellman Equations to re-derive the two different way to get
R π .
[Equation]
A. P ROOF OF T HEOREM 3.
Theorem 3.1 (Doubly Robustness) .
Let R π DR [ (cid:98) V , (cid:98) w ] :=
lim n 0 ,n,T →∞ (cid:98) R π DR [ (cid:98) V , (cid:98) w ] be the limit of (cid:98) R π DR when it has inﬁnite samples.
Following the deﬁnition above, we have
[Equation]
where ε (cid:98) V and ε (cid:98) w are errors of (cid:98) V and (cid:98) w , respective, deﬁned as follows
[Equation]
The error ε (cid:98) w of (cid:98) w is measured by the difference with the true density ratio d π ( s ) /d
π 0 ( s ) , and the error ε (cid:98) V of (cid:98) V is measured using the Bellman residual.
Proof.
Using the property of the operator, we can rewrite (1 − γ ) µ 0 ( s ) using Bellman equation as d π − γ T π d π , thus we have
[Equation]
and similarly if we break r π as ( I − γ P π ) V π , for R π SIS [ (cid:98) w ] we have:
[Equation]
where d (cid:98) w = d π 0 (cid:98) w for short.
Compare with R π = (cid:80) s
( I − γ P π ) V π ( s )
d π ( s ) , we can see the main difference between R π SIS and
R π VAL with R π are they replace d π and d (cid:98) w and V π with (cid:98) V respectively.
If we add them together and minus the connection estimator, we have we will have:
[Equation]
where the third equation is because ( I − γ P π ) ( V π − (cid:98) V )
=
[Equation]
I − γ P π ) V π − ( I − γ P π ) (cid:98) V =
r π − ( I − γ P π ) (cid:98) V .
Similarly, the bias for R π DR and R π SIS can be calculated as:
[Equation]
and
[Equation]
A. M ORE DISCUSSIONS ON THE V ARIANCE IN P ROPOSITION 3.
Recall the proposition 3.1.
Proposition 3.1 (Variance Analysis) .
Assume (cid:98) R π DR [ (cid:98) V , (cid:98) w ] is estimated based on sample D 0 ∼ µ 0 and
D π 0 ∼ d π 0 , which we assume to be independent of each other.
We have
Var
[Equation]
= Var [Equation] , (13) with (cid:98) R π res [ (cid:98) V , (cid:98) w ] := (cid:98) R π SIS [ (cid:98) w ] − (cid:98) R π bridge [ (cid:98) V , (cid:98) w ] = (cid:98) E D π 0 (cid:2)(cid:98)
ε ˆ V ( s ) (cid:98) w ( s ) (cid:3) and (cid:98)
ε ˆ V ( s ) the TD error of (cid:98) V , (cid:98) ε (cid:98) V
( s ) = (cid:99) r π ( s ) − (cid:98) V ( s ) + γ (cid:99) P π (cid:98) V ( s ) , with (cid:99) r π ( s )
=
r ( s, a ) π ( a | s ) /π
( a | s ) , (cid:99)
P π (cid:98) V ( s ) =
π ( a | s ) /π
( a | s ) (cid:98) V ( s (cid:48) ) .
Therefore,
Var D π 0 ( (cid:98) R π res
[ (cid:98) V , (cid:98) w ]) can be small when (cid:98) V is close to the true value V π , or (cid:98)
ε (cid:98) V ( s )
≈ 0 .
Proof.
Since (cid:98) R π DR [ (cid:98) V , (cid:98) w ] = (cid:98) R π VAL [ (cid:98) V ] + (cid:98) R π res
[ (cid:98) V , (cid:98) w ] and we have the assumption that the samples from
D 0 and D π 0 are independent, the proposition comes immediately.
Intuitively, the variance of (cid:98) R π res [ (cid:98) V , (cid:98) w ] is less than (cid:98) R π SIS
[ (cid:98) w ] .
We want to quantitatively study every pieces of orthogonal randomness of (cid:98) R π res
[ (cid:98) V , (cid:98) w ] and (cid:98) R π SIS [ (cid:98) w ] in details, and we state the analysis as the following theorem.
Theorem A.3.
Let Var D
π 0 (cid:104) (cid:98) R π res
[ (cid:98) V , (cid:98) w ] (cid:105) be deﬁned in Proposition 3.1, and suppose the normalization is constant (and hence an ordinary importance sampling which is unbiased).
Then we can further break it into two terms
[Equation]
(18) where ε (cid:98) V ( s ) = (cid:98) V ( s ) − r π ( s ) − γ P π (cid:98) V ( s (cid:48) ) is the Bellman residual(not the empirical one), δ 1 ( s, a )
=
π ( a | s ) π 0 ( a | s ) r
( s, a ) − r π ( s ) is the randomness for action and δ 2 ( s, a, s (cid:48) )
=
π ( a | s ) π 0 ( a | s ) (cid:98) V ( s (cid:48) )
− P π (cid:98) V ( s ) is the randomness for transition operator over function (cid:98) V .
Both δ 1 and δ 2 is zero mean if we condition over s .
Compared with Var (cid:104) (cid:98) R π SIS [ (cid:98) w ] (cid:105) we have:
[Equation]
Proof.
(cid:98) R π res [ (cid:98) V , (cid:98) w ] can be written as
[Equation] [Equation]
(cid:98)
[Equation]
) (cid:17) , where β π/π 0 ( a | s ) is short for π ( a | s ) π 0 ( a | s ) .
We can break β π/π 0 ( a | s )( r + γ (cid:98) V ( s (cid:48) ))
− (cid:98) V ( s ) into β π/π 0 ( a | s )( r ( s, a )
+ γ (cid:98) V
( s (cid:48) ))
− (cid:98) V ( s ) =( − (cid:98) V ( s ) + r π ( s ) + γ P π (cid:98) V ( s ))
+ ( β π/π 0 ( a | s ) r
( s, a ) − r π ( s ))
(cid:124) (cid:123)(cid:122) (cid:125) δ+ γ ( β π/π 0 ( a | s ) (cid:98) V ( s (cid:48) )
− P π (cid:98) V ( s ))
(cid:124) (cid:123)(cid:122) (cid:125) δ= − ε (cid:98) V ( s ) + δ 1 ( s, a ) + γδ 2 ( s, a, s (cid:48) ) .
where ε (cid:98) V = (cid:98)
V − r π − P π (cid:98) V is the Bellman residual and the if we condition over s we have the expectations for δ 1 and δ 2 are 0.
Also notice that if we condition over s then ε (cid:98) V ( s ) become a constant thus it is independent to δ 1 and δ 2 .
Thus we have:
[Equation]
Therefore we have:
[Equation]
For Var
[Equation]
we have:
[Equation]
From the theorem we can see that the variance of residual comes from two parts, the majority part relies on the variance of | ε (cid:98) V ( s ) | is usually much smaller than r π as the majority variance of state visitation importance sampling.
When (cid:98) V ≈ V π , ε (cid:98) V ( s ) ≈ 0 , the variance of residual only comes from δ 1 ( s, a ) and δ 2 ( s, a, s (cid:48) ) .
In practice when we get trajectories data from π 0 , to get samples uniformly from d π 0 , we can either draw sample s t depends on its discounted factor γ t or add an importance weight γ t as we did in our empirical estimator in equation (6) and equation (10).
A. P ROOF OF T HEOREM 4.
Theorem 4.1 (Primal Dual) .
I) Deﬁne w ρ/π 0 ( s ) =
ρ ( s ) d π 0 ( s ) .
We have
L ( V, ρ ) =
R π DR [ V, w ρ/π 0 ] , and hence
L ( V, d π ) =
L ( V π , ρ ) =
R π , ∀ V, ρ, which suggests that L ( V, ρ ) is “doubly robust” in that it equals R π if either V =
V π or ρ =
d π .
II)
The primal problem (14) forms a strong duality with the following dual problem,
[Equation]
where T π is deﬁned in (3)
[Equation]
Proof.
The Lagrangian can be written as:
[Equation]
We can see that the Lagrangian L ( V, ρ ) is actually our doubly robust estimator R π DR [ V, w ρ/π 0 ] .
From the last equation we can derive our dual as:
[Equation]
B D OUBLY R OBUST E STIMATOR FOR A VERAGE C ASE B. P RIMAL D UAL F RAMEWORK
We start from primal dual framework to get our doubly robust estimator similar to section 4.
To estimate the average reward of a given policy π , we can consider solve the following linear programming:
[Equation]
where ρ ( s ) is the stationary distribution of states under P π , and the objective is the average reward given π .
Consider the Lagrangian of above linear programming:
[Equation]
From Equation (21) we can get the dual formula as:
[Equation]
[Equation]
where V ( s ) is the value function and ¯ v is the average reward we want to optimize.
Notice that in average case, V π ( s ) can be viewed as the ﬁxed-point solution to the following Bellman equation:
[Equation]
Note that this explains the constraint and only if we pick ¯ v =
R π , we can ﬁnd a V to guarantee the constraint ¯ v + V ( s ) − P π V ( s ) − r π ( s ) ≥ 0 holds true.
B. D OUBLY R OBUST E STIMATOR
We want to build the doubly robust estimator via the lagrangian.
However, the Lagrangian consist of three term ρ, V and ¯ v .
It is counter-intuitive if we already given an estimator of ¯ v ≈ R π into our estimator.
A better way to solve this problem is to remove the constraint (cid:80) ρ ( s ) = 1 , but we divide it as an self-normalization.
Then our Lagrangian becomes
[Equation]
which can be utilized to deﬁne the doubly robust estimator for average reward.
Deﬁnition B.1.
Given a learned value function ˆ V ( s ) for policy π and an estimated density ratio ˆ w ( s ) for w π/π 0 ( s ) , we deﬁne
[Equation]
where β
[Equation]
Similarly to Theorem 3.1 we will have our double robustness for our average doubly robust estimator:
Theorem B.2.
Suppose we have inﬁnite samples and we can get
[Equation]
Then we have
[Equation]
where ε (cid:98) V and ε (cid:98) w are errors of (cid:98) V and (cid:98) w , respective, deﬁned as follows
[Equation]
Proof.
A key observation is that
[Equation]
Thus we have
[Equation]
Similar to discounted case we have R π DR [ (cid:98) V , (cid:98) w ]
=
R π if either (cid:98) w or (cid:98) V is accurate.
C E XPERIMENTAL D ETAILS C. T ABULAR C ASE : T AXI
Behavior and Target Policies Choosing We use an on-policy Q-learning to get a sequence of policy π 0 , π 1 , ..., π 19 as data size increases.
We pick the last policy π 19 (almost optimum) as our target policy and π 18 as our behavior policy to guarantee that those policies are not far away.
We set our discounted factor γ = 0 . 99 .
Train (cid:98) V and (cid:98)
ρ Separate from testing, we use a set of independent sample to ﬁrst train a value function (cid:98) V and a density function (cid:98) ρ .
Both (cid:98) V and (cid:98) ρ have bias due to ﬁnite sample approximation.
For training (cid:98) V and (cid:98) ρ , we choose to use Monte Carlo method to estimate (cid:98) V and (cid:98) ρ .
We ﬁrst use the ﬁnite samples to get an estimated model (cid:98) T ( s (cid:48) | s, a ) and rewards function (cid:98) r ( s, a ) and (cid:98) d 0 .
Then we solve the following linear equation (by iteration like power method, which is actually Monte Carlo):
[Equation]
ν ( s, a ) .
Estimate R π Using (cid:98) V and (cid:98)
ρ We put (cid:98) V and (cid:98) ρ into the Lagrangian as equation (15) as our doubly robust estimator.
For those states we haven’t visited, we set (cid:98) V ( s ) and (cid:98) ρ ( s ) as 0 and we self-normalized the (cid:98) ρ to get a fair estimation.
C. C ONTINUOUS S TATES O FF -P OLICY E VALUATION
Evaluation Environments We evaluate our method on two inﬁnite horizon environments: PuckMountain and InvertedPendulum.
Puck-Mountain is an environment similar to Mountain-car, except that the goal of the task is to push the puck as high as possible in a local valley whose initial position is at the bottom of the valley.
If the ball reaches the top sides of the valley, it will hit a roof and changes the speed to its opposite direction with half of its original speeds.
The rewards was determined by the current velocity and height of the puck.
InvertedPendulum is a pendulum that has its center of mass above its pivot point.
It is unstable and without additional help will fall over.
We train a near optimal policy that can make the pendulum balance for a long horizon.
For both behavior and target policies, we assume they are good enough to keep the pendulum balance and will never fall down until they reach the maximum timesteps.
We use the implementation from OpenAI Gym (Brockman et al., 2016) and changing the dynamic by adding some additional zero mean Gaussian noise to the transition dynamic.
Behavior and Target Policies Learning We use the open source implementation 2 of deep Qlearning to train a 32 × 32 MLP parameterized Q-function to converge.
We then use the softmax policy of learned the Q-function as the target policy π , which has a default temperature τ = 1 .
For the behavior policy π 0 , we set a relative large temperature which encourages exploration.
We set the temperature of the behavior policy τ 0 = 1 . 88 for Puck-Mountain and τ 0 = 1 .
50 for InvertedPendulum respectively.
Training of density ratio ˆ w ( s ) and value function
ˆ V ( s )
We use a seperate training dataset with 200 trajectories whose horizon length is 1000 to learn the density ratio ˆ w ( s ) and the value function
Algorithm
Input : Transition data D
= { s i , a i , s (cid:48)
i , r i } ni =1 from the behavior policy π 0 ; a target policy π for which we want to estimate the expected reward.
Discount factor γ ∈ (0 , 1) , starting state
D
= { s (0) j } mj
=
from initial distribution.
Initial the density ratio w ( s ) =
w θ ( s ) to be a neural network parameterized by θ , f ( s ) =
f β ( s ) to be a neural network parameterized by β .
We need to ensure that the ﬁnal layer of θ is a softmax layer.
for iteration =
1,2,...,T do
Randomly choose a batch M ⊆ { 1 , . .
. , n } uniformly from the transition data D and
a batch
M 0 ⊆ { 1 , . . .
, m } uniformly from start states D 0 .
for iteration =
1,2,..., K do
Update the parameter β by β ← β + (cid:15) β ∇ β ˆ L ( w θ , φ β ) , where ˆ L ( w θ , f β ) = |M| (cid:88) i ∈M (cid:18)
[Equation]
(cid:19)
[Equation]
(cid:88)
[Equation]
f (
[Equation]
) end for
Update the parameter θ by θ ← θ − (cid:15) θ ∇ θ ˆ L ( w θ , f β ) .
end for
Output : the density ratio (cid:98) w = w θ .
Algorithm
Input : Transition data D
= { s i , a i , s (cid:48)
i , r i } ni =1 from the behavior policy π 0 ; a target policy π for which we want to estimate the expected reward.
Discount factor γ ∈ (0 , 1) .
Initial the value function V ( s ) =
V φ ( s ) to be a neural network parameterized by φ , f ( s ) =
f β ( s ) to be a neural network parameterized by β . for iteration =
1,2,...,T do
Randomly choose a batch M ⊆ { 1 , . .
. , n } uniformly from the transition data D .
for iteration =
1,2,..., K do
Update the parameter β by β ← β + (cid:15) β ∇ β ˆ L ( V φ , φ β ) , where
[Equation]
end for
Update the parameter φ by φ ← φ − (cid:15) φ ∇ φ ˆ L ( V φ , f β ) .
end for
Output : the density ratio (cid:98) V = V φ .
ˆ V ( s ) .
For the training of density ratio, we adapt the algorithm 2 in Liu et al.
(2018a) to train a neural network parameterized w θ ( s ) .
Instead of taking the test function f ( s ) into an RKHS H K , we parameterize the test function f ( s ) =
f β ( s ) to be a neural network with parameter β , and perform minimax optimization over parametr θ and β .
A detail description can be found in Algorithm 2.
Similarly, for the training of value function, we use primal-dual based optimization methods (Dai et al., 2017b;
Feng et al., 2019) to minimize the bellman residual:
[Equation]
where V φ ( s ) is the parameterized value function and f β ( s ) is the test function.
We also perform minimax over parameter φ and β .
A detail description can be found in Algorithm 3.
For the network structures, we use 32 × 32 feed forward neural networks to parameterize value function
V φ and density ratio w θ ( s ) , and we use one hidden neural network with 10 units to parameterize the test function f β ( s ) .
We use Adam Optimizer for all our experiments.
[Figure]
Estimate R π using (cid:98) V and (cid:98) w
Given data samples from the policy π 0 , We can directly use (cid:98) R π DR in equation (11) to estimate R π .
D A DDITIONAL E XPERIMENTAL R ESULTS
We add a standard model-based baseline in Figure 4 following the same procedure as Liu et al.
(2018a).
3 Figure 4 shows that the performance of the model-based approach largely depends of the size of the data, which is consistent with that in Liu et al.
(2018a).