S AMPLE - EFFICIENT P OLICY O PTIMIZATION WITH S TEIN C ONTROL V ARIATE
Anonymous authors
Paper under double-blind review
A BSTRACT
Policy gradient methods have achieved remarkable successes in solving challenging reinforcement learning problems.
However, it still often suffers from the large variance issue on policy gradient estimation, which leads to poor sample efﬁciency during training.
In this work, we propose a control variate method to effectively reduce variance for policy gradient methods.
Motivated by the Stein’s identity, our method extends the previous control variate methods used in REINFORCE and advantage actor-critic by introducing more general action-dependent baseline functions.
Empirical studies show that our method essentially improves the sample efﬁciency of the state-of-the-art policy gradient approaches.
I NTRODUCTION
Deep reinforcement learning (RL) provides a general framework for solving challenging goaloriented sequential decision-making problems, It has recently achieved remarkable successes in advancing the frontier of AI technologies (Silver et al., 2017; Mnih et al., 2013; Silver et al., 2016;
Schulman et al., 2017).
Policy gradient (PG) is one of the most successful model-free RL approaches that has been widely applied to high dimensional continuous control, vision-based navigation and video games (Schulman et al., 2016; Kakade, 2002; Schulman et al., 2015; Mnih et al., 2016).
Despite these successes, a key problem of policy gradient methods is that the gradient estimates often have high variance.
A naive solution to ﬁx this issue would be requiring a large amount of rollout samples to obtain a reliable gradient estimation in each step.
Regardless of the cost of generating large samples, in many practical applications like developing driverless cars, it may not even be possible to generate as many samples as we want.
A variety of variance reduction techniques have been proposed for policy gradient methods (See e.g. Weaver & Tao 2001, Greensmith et al. 2004,
Schulman et al.
2016 and Asadi et al. 2017).
In this work, we focus on the control variate method, one of the most widely used variance reduction techniques in policy gradient and variational inference.
The idea of the control variate method is to subtract a Monte Carlo gradient estimator by a baseline function that analytically has zero expectation, and hence introduces no additional bias.
The resulted estimator may achieve much lower variance if the baseline function is properly chosen such that it cancels out the variance of the original gradient estimator.
Different control variates yield different variance reduction methods.
Let us mention of several examples here.
In REINFORCE (Williams, 1992), a constant baseline function is chosen as control variate.
Advantage actor-critic (A2C) (Sutton & Barto, 1998; Mnih et al., 2016) considers a state-dependent baseline function as control variate.
This function is often set to be an estimated value function V ( s ) .
More recently, in Q-prop (Gu et al., 2016), a more general baseline function is proposed.
It linearly depends on actions, and shows promising results on several challenging tasks.
It is natural to expect even more ﬂexible baseline functions which can arbitrarily depend on both states and actions to yield powerful variance reduction.
Without a principled framework or guideline, however, constructing such a baseline function turns out to be fairly challenging.
To tackle this problem, we sort to the so-called Stein’s identity (Stein, 1986) which deﬁnes a broad class of identities that are sufﬁcient to fully characterize the distribution under consideration (e.g.,
Liu et al., 2016; Chwialkowski et al., 2016).
By applying the Stein’s identity and also drawing connection with the reparameterization trick (Kingma & Welling, 2013; Rezende et al., 2014), we construct the Stein control variate, a new control variate method that allows us to use arbitrary baseline functions that depend on both actions and states.
Our approach tremendously extends the existing control variates used in REINFORCE, A2C and Q-prop.
We evaluate our method on a variety of reinforcement learning tasks.
Our experiments show that our Stein control variate can signiﬁcantly reduce the variance of gradient estimation with more ﬂexible and nonlinear baseline functions.
When combined with different policy optimization methods, including both proximal policy optimization (PPO) (Schulman et al., 2017; Heess et al., 2017) and trust region policy optimization (Schulman et al., 2015; 2016), it greatly improves the sample efﬁciency of the entire policy optimization.
B ACKGROUND
In this section, we present basic materials on policy gradient and the control variate method for variance reduction.
The readers who are familiar with these topics can safely skip this section.
2. R EINFORCEMENT L EARNING AND P OLICY G RADIENT
Reinforcement learning considers the problem of ﬁnding an optimal policy for an agent which interacts with an uncertain environment and collects reward per action.
The goal of the agent is to maximize the long-term cumulative reward.
Formally, this problem can be formulated as a Markov decision process over the environment states s ∈ S and agent actions a ∈ A , under an unknown environmental dynamic deﬁned by a transition probability T ( s (cid:48) | s, a ) and a reward signal r ( s, a ) immediately following the action a performed at state s .
The agent’s action a is selected by a conditional probability distribution π ( a | s ) called policy.
In policy gradient methods, we consider a set of candidate policies π θ ( a | s ) parameterized by θ and obtain the optimal policy by maximizing the expected cumulative reward or return
[Equation]
where ρ π ( s ) =
(cid:80) ∞ t =1 γ t − 1 Pr( s t = s ) is the normalized discounted state visitation distribution with discount factor γ ∈ [0 , 1) .
To simplify the notation, we denote E s ∼ ρ π ,a ∼ π ( a | s ) [ · ] by simply E π [ · ] in the rest of paper.
According to the policy gradient theorem (Sutton & Barto, 1998), the gradient of
J ( θ ) can be written as
[Equation]
where Q π ( s, a )
=
E π (cid:2)(cid:80) ∞ t =1 γ t − 1 r ( s t , a t ) | s 1 = s, a 1 = a (cid:3) denotes the expected return under policy π starting from state s and action a .
Different policy gradient methods are based on different stochastic estimation of the expected gradient in Eq (1).
Perhaps the most straightforward way is to simulate the environment with the current policy π to obtain a trajectory { ( s t , a t , r t ) } nt =1 and estimate ∇ θ J ( θ ) using the Monte Carlo estimation:
[Equation]
where ˆ Q π ( s t , a t ) is an empirical estimate of Q π ( s t , a t ) , e.g., ˆ Q π ( s t , a t )
= (cid:80) j ≥ t γ j − t r j .
Unfortunately, this naive method often introduces large variance in gradient estimation.
It is almost always the case that we need to use control variates method for variance reduction, which we will introduce in the following.
It has been found that biased estimators help improve the performance, e.g., by using biased estimators of Q π or dropping the γ t − 1 term in Eq (2).
In this work, we are interested in improving the performance without introducing additional biases.
2. C ONTROL V ARIATE
The control variates method is one of the most widely used variance reduction techniques in policy gradient.
Suppose that we want to estimate the expectation µ = E τ [ g ( s, a )] with Monte Carlo samples ( s t , a t ) nt =1 drawn from some distribution τ, which is assumed to have a large variance var τ ( g ) .
The control variate is a function f
( s, a ) with a special structure such that it has a zero expectation under τ
E τ [ f ( s, a )] = 0 .
With f , we can have an alternative unbiased estimator
[Equation]
where the variance of this estimator is var τ ( g − f ) , instead of var τ ( g ) for the Monte Carlo estimator.
By taking f to be similar to g , e.g. f = g − µ in the ideal case, the variance of g − f can be signiﬁcantly reduced, thus resulting in a more reliable estimator.
The key step here is to ﬁnd an identity that yields a large class of functional f with zero expectation.
In most existing policy gradient methods, the following identity is used
[Equation]
for any function φ.
[Equation]
Combining it with the policy gradient theorem, we obtain
[Equation]
Note that we drop the γ t − 1 term in Eq (2) as we do in practice.
The introduction of the function φ does not change the expectation but can decrease the variance signiﬁcantly when it is chosen properly to cancel out the variance of Q π ( s, a ) .
In REINFORCE, φ is set to be a constant φ ( s ) =
b baseline, and b is usually set to approximate the average reward, or determined by minimizing var( ˆ ∇ θ J ( θ )) empirically.
In advantage actor-critic (A2C), φ ( s ) is set to be an estimator of the value function V π ( s ) =
E π ( a | s )
[ Q π ( s, a )] , so that ˆ Q π ( s, a ) − φ ( s ) is an estimator of the advantage function.
For notational consistency, we call φ the baseline function and f ( s, a ) =
∇ θ log π ( a | s ) φ ( s ) the corresponding control variate.
Although REINFORCE and A2C have been widely used, their applicability is limited by the possible choice of φ .
Ideally, we want to set φ to equal Q π ( s, a ) up to a constant to reduce the variance of ˆ ∇ θ J ( θ ) to close to zero.
However, this is impossible for REINFORCE or A2C because φ ( s ) only depends on state s but not action a by its construction.
Our goal is to develop a more general control variate that yields much smaller variance of gradient estimation than the one in Eq (4).
P OLICY G RADIENT WITH S TEIN CONTROL VARIATE
In this section, we present our Stein control variate for policy gradient methods.
In Section 3.
we start by introducing the Stein’s identity, then develop a variant that yields a new control variate for policy gradient, and ﬁnally discuss its connection to the reparameterization trick and the Qprop method.
We provide approaches to estimate the optimal baseline functions in Section 3.2, and discuss the special case of the Stein control variate for Gaussian policies in Section 3.3.
We apply our control variate to proximal policy optimization (PPO) in Section 3.4.
3. S TEIN C ONTROL V ARIATE
Given a policy π ( a | s ) , the Stein’s identity w.r.t π is
[Equation]
which holds for any real-valued function φ ( s, a ) with some proper conditions.
To see this, note the left hand side of Eq (5) is equivalent to (cid:82) ∇ a ( π ( a | s ) φ ( s, a ))
da , which equals zero if π ( a | s ) φ ( s, a ) equals zero on the boundary of the integral domain, or decay sufﬁciently fast (e.g., exponentially) when the integral domain is unbounded.
The power of the Stein’s identity lies in the fact that it deﬁnes an inﬁnity set of identities, indexed by arbitrary functional φ ( s, a ) , which is sufﬁcient to uniquely identify a distribution as shown in the work of Stein’s method for proving central limit theorems (Stein, 1986;
Barbour & Chen, 2005), goodness-of-ﬁt test (Chwialkowski et al., 2016; Liu et al., 2016), and approximate inference (Liu & Wang, 2016).
Oates & Girolami (2016) has applied the Stein’s identity as a control variate for general Monte Carlo estimation, which is shown to yield a zero-variance estimator because the control variate is so ﬂexible that it can arbitrarily approximate the function of interest with enough samples.
Unfortunately, for the particular case of policy gradient, it is not straightforward to directly apply the Stein’s identity (5) as a control variate, since the dimension of the left-hand side of (5) does not match the dimension of a policy gradient: the gradient in (5) is taken w.r.t.
the action a , while the policy gradient in (1) is taken w.r.t.
the parameter θ .
Therefore, we need a general approach to connect ∇ a log π ( a | s ) to ∇ θ log π ( a | s ) in order to apply the Stein’s identity as a control variate for policy gradient.
We show in the following theorem that this is possible when the policy is reparameterizable in that a ∼ π θ ( a | s ) can be viewed as generated by a = f θ ( s, ξ ) where ξ is a random noise drawn from some distribution independently of θ .
With an abuse of notation, we denote by π ( a, ξ | s ) the joint distribution of ( a, ξ ) conditioned on s , so that π ( a | s ) =
(cid:82) π ( a | s, ξ ) π ( ξ ) dξ , where π ( ξ ) denotes the distribution generating ξ and π ( a | s, ξ )
=
δ ( a − f ( s, ξ )) where δ is the Delta function.
Theorem 3.1.
With the reparameterizable policy deﬁned above, using Stein’s identity, we can derive
[Equation]
Proof.
See Appendix for the detail proof.
To help understand the intuition, we can consider the
Delta function as a Gaussian with a small variance h , i.e. π ( a | s, ξ ) ∝ exp( −(cid:107) a − f ( s, ξ ) (cid:107) 22 / 2 h ) , for which it is easy to show that
[Equation]
This allows us to convert between the derivative w.r.t.
a and w.r.t.
θ , and hence apply Stein’s identity in (5).
Stein Control Variate Using Eq (6) as a control variate, we obtain the following general formula of policy gradient:
[Equation]
where the choice of φ does not introduce bias to the expectation.
Given a sample set ( s t , a t , ξ t ) nt = where a t = f θ ( s t , ξ t ) , an estimator of the gradient is:
[Equation]
This estimator clearly generalizes the control variates used in A2C and REINFORCE.
To see this, let φ be action independent, i.e. φ ( s, a ) =
φ ( s ) or even φ ( s, a )
=
b , in both cases the last term in (9) equals to zero because ∇ a φ = 0 .
When φ is action-dependent, the last term (9) does not vanish in general, and in fact will play an important role for variance reduction as we will illustrate later.
Relation to Q-prop Q-prop is a recently introduced sample-efﬁcient policy gradient method that constructs a general control variate using Taylor expansion.
Here we show that Q-prop can be derived from (8) with a special φ that depends on the action linearly, so that its gradient w.r.t.
a is action-independent, i.e. ∇ a φ ( a, s ) = ∇ a φ ( s ) .
In this case, Eq (8) becomes
[Equation]
Furthermore, note that E π ( ξ ) [ ∇ θ f ( s, ξ )]
= ∇ θ E π ( ξ )
[ f ( s, ξ )] :
= ∇ θ µ π ( s ) , where µ π ( s ) is the expectation of the action conditioned on s .
Therefore,
[Equation]
which is the identity used in Q-prop to construct their control variate (see Eq 6 in Gu et al. 2016).
In
Q-prop, the baseline function is constructed empirically by the ﬁrst-order Taylor expansion as
[Equation]
[Equation]
where ˆ V π ( s ) and ˆ Q π ( s, a ) are parametric functions that the value function and Q function under policy π .
In contrast, our method allows us to use more general and ﬂexible, nonlinear baseline functions φ to construct the Stein control variate which is able to decrease the variance more significantly.
Relation to the reparameterization trick The identity (6) is closely connected to the reparameterization trick for gradient estimation which has been widely used in variational inference recently (Kingma & Welling, 2013; Rezende et al., 2014).
Speciﬁcally, let us consider an auxiliary objective function based on function φ :
[Equation]
Then by the log-derivative trick, we can obtain the gradient of this objective function as
[Equation]
which is the left-hand side of (6).
On the other hand, if a ∼ π ( a | s ) can be parameterized by a = f θ ( s, ξ ) , then L s ( θ ) =
E π ( ξ ) [ φ ( s, f θ ( s, ξ ))] , leading to the reparameterized gradient in Kingma & Welling (2013):
[Equation]
Equation (11) and (12) are equal to each other since both are ∇ θ L s ( θ ) .
This provides another way to prove the identity in (6).
3. C ONSTRUCTING THE B ASELINE F UNCTIONS FOR S TEIN C ONTROL V ARIATE
We need to develop practical approaches to choose the baseline functions φ in order to fully leverage the power of the ﬂexible Stein control variate.
In practice, we assume a ﬂexible parametric form φ w ( s, a ) with parameter w , e.g. linear functions or neural networks, and hope to optimize w efﬁciently for variance reduction.
Here we introduce two approaches for optimizing w and discuss some practical considerations.
Estimating φ by Fitting Q Function Eq (8) provides an interpolation between the log-likelihood ratio gradient (1) (by taking φ = 0 ) and a reparameterized gradient (12) (by taking φ ( s, a )
=
Q π ( s, a ) )
[Equation]
It is well known that the reparameterized gradient tends to yield much smaller variance than the log-likelihood ratio gradient from the variational inference literature (see e.g., Kingma & Welling, 2013; Rezende et al., 2014; Roeder et al., 2017; Tucker et al., 2017).
An intuitive way to see this is to consider the extreme case when the policy is deterministic.
In this case the variance of (11) is inﬁnite because log π ( a | s ) is either inﬁnite or does not exist, while the variance of (12) is zero because ξ is deterministic.
Because optimal policies often tend to be close to deterministic, the reparameterized gradient should be favored for smaller variance.
Therefore, one natural approach is to set φ to be close to Q function, that is, φ ( s, a ) =
ˆ Q π ( s, a ) so that the log-likelihood ratio term is small.
Any methods for Q function estimation can be used.
In our experiments, we optimize the parameter w in φ w ( s, a ) by
[Equation]
where R t an estimate of the reward starting from ( s t , a t ) .
It is worth noticing that with deterministic policies, (13) is simpliﬁed to the update of deep deterministic policy gradient (DDPG) (Lillicrap et al., 2015; Silver et al., 2014).
However, DDPG directly plugs an estimator ˆ Q π ( s, a ) into (13) to estimate the gradient, which may introduce large bias.
In constrast, our formula (8) provides an unbiased estimator where the log-likelihood ratio terms serve to correct the bias in the reparameterized gradient.
Estimating φ by Minimizing the Variance Another approach for obtaining φ is to directly minimize the variance of the gradient estimator.
Note that var( ˆ ∇ θ J ( θ ))
=
E [( ˆ ∇
[Equation]
)) 2 ] − E
[ ˆ ∇
[Equation] [Equation]
Since E [ ˆ ∇ θ J ( θ )]
= ∇ θ J ( θ ) which does not depend on φ , it is sufﬁcient to minimize the ﬁrst term.
Speciﬁcally, for φ w ( s, a ) we optimize w by min
w
[Equation]
In practice, we ﬁnd that it is difﬁcult to implement this efﬁciently using the auto-differentiation in the current deep learning platforms because it involves derivatives w.r.t.
both θ and a .
We develop a computational efﬁcient approximation for the special case of Gaussian policy as we will discuss in
Section 3.3.
Architectures of φ Given the similarity between φ and the Q function as we mentioned above, we may decompose φ into
[Equation]
The term ˆ V π ( s ) is parametric function approximation of the value function which we separately estimate in the same way as in A2C, and w is optimized using the method above with ﬁxed ˆ V π ( s ) .
Here the function ψ w ( s, a ) can be viewed as an estimate of the advantage function, whose parameter w is optimized using the two optimization methods introduced above.
To see, we rewrite our gradient estimator to be
[Equation]
where ˆ A π ( s t , a t ) =
ˆ Q π ( s t , a t ) − ˆ V π ( s t ) is an estimator of the advantage function.
If we set ψ w ( s, a ) = 0 , then Eq (16) clearly reduces to A2C.
We ﬁnd that separating ˆ V π ( s ) from ψ w ( s, a ) works well in practice, because it effectively provides a useful initial estimation of φ , and allows us to directly improve the φ on top of the value function baseline.
3. S TEIN CONTROL VARIATE FOR G AUSSIAN P OLICIES
Gaussian policies have been widely used and are shown to perform efﬁciently in many practical continuous reinforcement learning settings.
Because of their wide applicability, we derive the gradient estimator with the Stein control variate for Gaussian policies here and use it in our experiments.
Speciﬁcally, Gaussian policies take the form π ( a | s ) =
N ( a ; µ θ 1 ( s ) , Σ θ 2 ( s )) , where mean µ and covariance matrix Σ are often assumed to be parametric functions with parameters θ =
[ θ 1 , θ 2 ] .
This is equivalent to generating a by a = f θ ( s, ξ ) =
µ θ 1 ( s ) + Σ θ 2 ( s ) 1 / 2 ξ , where ξ ∼ N (0 , 1) .
Following Eq (8), the policy gradient w.r.t.
the mean parameter θ 1 is
[Equation]
For each coordinate θ (cid:96) in the variance parameter θ 2 , its gradient is computed as
[Equation]
[Equation]
where (cid:104) A, B (cid:105) :
= trace( AB ) for two d a × d a matrices.
Note that the second term in (18) contains ∇ a log π ( a | s ) , we can further apply Stein’s identity on it to obtain a simpliﬁed formula
[Equation]
(cid:21) .
The estimator in (19) may have lower variance compared to that in (18).
To see this, consider the case when φ ( s, a ) is a linear function of a (like the case of Q-prop), then the second term in (19) vanishes to zero, while that in (18) does not.
We also ﬁnd it is practically convenient to estimate the parameters w in φ by minimizing var( ˆ ∇ µ J )+ var( ˆ ∇ Σ J ) , instead of the exact variance var( ˆ ∇ θ J ) .
Further details can be found in Appendix 7.2.
3. PPO WITH S TEIN CONTROL VARIATE
Proximal Policy Optimization (PPO) (Schulman et al., 2017; Heess et al., 2017) is recently introduced for policy optimization.
It uses a proximal Kullback-Leibler (KL) divergence penalty to regularize and stabilize the policy gradient update.
Given an existing policy π old , PPO obtains a new policy by maximizing the following surrogate loss function
[Equation]
where the ﬁrst term is an approximation of the expected reward, and the second term enforces the the updated policy to be close to the previous policy under KL divergence.
The gradient of J ppo ( θ ) can be rewritten as
[Equation]
where w π ( s, a ) :
= π θ ( a | s ) /π
old ( a | s ) is the density ratio of the two polices, and Q πλ ( s, a ) :=
Q π ( s, a ) + λw π ( s, a ) − 1 where the second term comes from the KL penalty.
Note that E π old [ w π ( s, a ) f ( s, a )] =
E π
[ f ( s, a )] by canceling the density ratio.
Applying (6), we obtain
[Equation]
Putting everything together, we summarize our PPO algorithm with Stein control variates in Algorithm 1.
It is also straightforward to integrate the Stein control variate with TRPO.
R ELATED W ORK
The Stein’s identity has been shown to be a powerful tool in many areas of statistical learning and inference.
An incomplete list includes Liu & Wang (2016), Feng et al.
(2017), Liu (2017), Oates &
Girolami (2016), Gorham & Mackey (2015), Sedghi et al.
Liu et al.
(2016), Chwialkowski et al.
(2016), Liu & Lee (2017) and Han & Liu (2017).
This work was originally motivated by Oates & Girolami (2016), which uses the Stein’s identity as a control variate for general Monte Carlo estimation.
However, as discussed in Section 3.1, the original formulation of the Stein’s identity can not be directly applied to policy gradient, and we need the mechanism introduced in (6) that also connects to the reparameterization trick (Kingma & Welling, 2013; Rezende et al., 2014).
Control variate method is one of the most widely used variance reduction techniques in policy gradient (see e.g., Greensmith et al., 2004).
However, action-dependent baseline functions have not yet been well studied.
Besides Q-prop (Gu et al., 2016) which we draw close connection to, the work of Thomas & Brunskill (2017) also suggests a way to incorporate action-dependent baselines, but is restricted to the case of compatible function approximation.
More recently, Tucker et al.
(2017) studied a related action-dependent control variate for discrete variables in learning latent variable models.
E XPERIMENTS
We evaluated our control variate method when combining with PPO and TRPO on continuous control environments from the OpenAI Gym benchmark (Brockman et al., 2016) using the MuJoCo physics simulator (Todorov et al., 2012).
We show that by using our more ﬂexible baseline functions, we can signiﬁcantly improve the sample efﬁciency compared with methods based on the typical value function baseline and Q-prop.
All our experiments use Gaussian policies.
As suggested in Section 3.2, we assume the baseline to have a form of φ w ( s, a )
=
ˆ V π ( s ) + ψ w ( s, a ) , where ˆ V π is the valued function estimated separately in the same way as the value function baseline, and ψ w ( s, a ) is a parametric function whose value w is decided by minimizing either Eq (14) (denoted by FitQ ), or Eq (23) designed for Gaussian policy (denoted by MinVar ).
We tested three different architectures of ψ w ( s, a ) , including
Linear .
ψ w ( s, a ) =
(cid:104)∇ a q w ( a, µ π ( s )) , ( a − µ π ( s )) (cid:105) , where q w is a parametric function designed for estimating the Q function Q π .
This structure is motivated by Q-prop, which estimates w by ﬁtting q w ( a, s ) with Q π .
Our MinVar , and FitQ methods are different in that they optimize w as a part of φ w ( s, a ) by minimizing the objective in Eq (14) and Eq (23).
We show in Section 5.2 that our optimization methods yield better performance than Q-prop even with the same architecture of ψ w .
This is because our methods directly optimize for the baseline function φ w ( s, a ) , instead of q w ( s, a ) which serves an intermediate step.
Quadratic .
ψ w ( s, a )
= − ( a − µ w ( s ))
(cid:62) Σ w ( s ) − 1 ( a − µ w ( s )) .
In our experiments, we set µ w ( s ) to be a neural network, and Σ w ( s ) a positive diagonal matrix that is independent of the state s .
MLP .
ψ w ( s, a ) is assumed to be a neural network in which we ﬁrst encode the states s with a hidden layer, and then concatenate it with the action a and pass them into another hidden layer before the output.
Further, we denote by Value the typical value function baseline, which corresponds to setting ψ w ( s, a ) = 0 in our case.
All the results we report are averaged over three random seeds.
See
Appendix for implementation details.
5. C OMPARING THE V ARIANCE OF DIFFERENT G RADIENT E STIMATORS
We start with comparing the variance of the gradient estimators of the different control variates.
Figure 1 shows the result on Walker2d-v1, when we take a ﬁxed policy obtained by running the vanilla PPO for 200 steps and evaluate the variance of the different gradient estimators under different sample sizes n .
In order to obtain unbiased estimates of the variance, we estimate all the baseline functions using a hold-out dataset with a large sample size.
We ﬁnd that our methods, especially these using the MLP and Quadratic baselines, obtain signiﬁcantly lower variance than the typical value function baseline and Q-prop.
5. C OMPARISON WITH Q- PROP USING TRPO FOR POLICY OPTIMIZATION
Next we want to check whether our Stein control variate will improve the sample efﬁciency of policy gradient methods over existing control variate, e.g. Q-prop (Gu et al., 2016).
One major advantage of
Q-prop is that it can leverage the off-policy data to estimate q w ( s, a ) .
Here we compare our methods with the original implementation of Q-prop which incorporate this feature for policy optimization.
Because the best existing version of Q-prop is implemented with TRPO, we implement a variant of our method with TRPO for fair comparison.
The results on Hopper-v1 and Walker2d-v1 are shown in Figure 2, where we ﬁnd that all Stein control variates, even including FitQ+Linear
[Figure] [Figure]
and MinVar+Linear , outperform Q-prop on both tasks.
This is somewhat surprising because the
Q-prop compared here utilizes both on-policy and off-policy data to update w , while our methods use only on-policy data.
We expect that we can further boost the performance by leveraging the offpolicy data properly, which we leave it for future work.
In addition, we noticed that the Quadratic baseline generally does not perform as well as it promises in Figure 1; this is probably because that in the setting of policy training we optimize φ w for less numbers of iterations than what we do for evaluating a ﬁxed policy in Figure
[Figure]
and it seems that Quadratic require more iterations than
MLP to converge well in practice
[Figure]
5. PPO WITH D IFFERENT C ONTROL V ARIATES
Finally, we evaluate the different Stein control variates with the more recent proximal policy optimization (PPO) method which generally outperforms TRPO.
We ﬁrst test all the three types of φ listed above on Humanoid-v1 and HumanoidStandup-v1, and present the results in Table 1.
We can see that all the three types of Stein control variates consistently outperform the value function baseline, and Quadratic and MLP tend to outperform Linear in general.
We further evaluate our methods on a more extensive list of tasks shown in Figure 3, where we only show the result of PPO+MinVar+MLP and PPO+FitQ+MLP which we ﬁnd tend to perform the best according to Table 1.
We can see that our methods can signiﬁcantly outperform PPO+Value which is the vanilla PPO with the typical value function baseline (Heess et al., 2017).
It seems that MinVar tends to work better with MLP while FitQ works better with Quadratic in our settings.
In general, we ﬁnd that MinVar+MLP tends to perform the best in most cases.
Note that the MinVar here is based on minimizing the approximate objective (23) speciﬁc to Gaussian policy, and it is possible that we can further improve the performance by directly minimizing
[Table]
[Figure]
[Table]
the exact objective in (15) if an efﬁcient implementation is made possible.
We leave this a future direction.
C ONCLUSION
We developed the Stein control variate, a new and general variance reduction method for obtaining sample efﬁciency in policy gradient methods.
Our method generalizes several previous approaches.
We demonstrated its practical advantages over existing methods, including Q-prop and value-function control variate, in several challenging RL tasks.
In the future, we will investigate how to further boost the performance by utilizing the off-policy data, and search for more efﬁcient ways to optimize φ more efﬁcient for quadratic φ .
We would also like to point out that our method can be useful in other challenging optimization tasks such as variational inference and Bayesian optimization where gradient estimation from noisy data remains a major challenge.
A PPENDIX 7. P ROOF OF T HEOREM 3.
Proof.
Denote π ( a, ξ | s ) as the joint density function of ( a, ξ ) conditioned on s .
It can be written as
[Equation]
Taking the derivative of log π ( a
[Equation]
ξ | s ) w.r
[Equation]
t. a gives
[Equation]
Similarly, taking the derivative of log π ( a, ξ | s ) w.r.t.
θ , we have
[Equation]
Multiplying both sides with φ ( s, a ) and taking the conditional expectation yield
E
[Equation]
where the third equality comes from the Stein’s identity (5) of π ( a | ξ, s ) .
7. E STIMATING φ FOR G AUSSIAN P OLICIES
The parameters w in φ should be ideally estimated by minimizing the variance of the gradient estimator var( ∇ θ J ( θ )) using (15).
Unfortunately, it is computationally slow to directly solve (15) with the current deep learning platforms, due to the limitation of the auto-differentiation implementations.
In general, this problem might be solved with a customized implementation of gradient calculation.
In the case of Gaussian policies, we ﬁnd minimizing var( ˆ ∇ µ J ( θ ))
+ var( ˆ ∇ Σ J ( θ )) provides a good approximation.
More speciﬁcally, recall that Gaussian policy has a form of
[Equation]
where µ ( s ) and Σ( s ) are parametric functions of state s, and | Σ | is the determinant of Σ .
Following
Eq (8) we have
[Equation] [Equation]
where we use the fact that ∇ µ f θ ( s, ξ ) = 1 and
[Equation]
Similarly, we have
[Equation]
where
[Equation]
Because the baseline function does not change the expectations in (21) and (22), we can frame min w var( ˆ ∇ µ J ( θ ))
+ var( ˆ ∇ Σ J ( θ )) into
[Equation]
23) where g µ and g Σ are the integrands in (17) and (19) respectively, that is, g µ ( s, a ) = −∇ a log π ( a | s )( Q π ( s, a ) − φ ( s, a )) + ∇ a φ ( s, a ) and g Σ ( s, a )
= ∇ Σ log π ( a | s )( Q π ( s, a ) − φ ( s, a ))
+ 12 ∇ aa φ ( s, a ) .
Here (cid:107) A (cid:107) 2 F := (cid:80) ij A 2 ij is the matrix Frobenius norm.
7. E XPERIMENT D ETAILS
The advantage estimation ˆ A π ( s t , a t ) in Eq 16 is done by GAE with λ = 0 . 98 , and γ = 0 .(Schulman
et al., 2016), and correspondingly, ˆ Q π ( s t , a t ) =
ˆ A π ( s t , a t )
+ ˆ V π
( s t , a t ) in (9).
Observations and advantage are normalized as suggested by Heess et al.
The neural networks of the policies π ( a | s ) and baseline functions φ w ( s, a ) use Relu activation units, and the neural network of the value function ˆ V π ( s ) uses Tanh activation units.
All our results use Gaussian MLP policy in our experiments with a neural-network mean and a constant diagonal covariance matrix.
Denote by d s and d a the dimension of the states s and action a , respectively.
Network sizes are follows:
On Humanoid-v1 and HuamnoidStandup-v1 , we use ( d s , √ d a · 5 , 5) for both policy network and value network; On other Mujoco environments, we use (10 · d s , √ 10 · d s · 5 , 5) for both policy network and value network, with learning rate 0 .
√ ( d s · 5) for policy network and 0 .
√
( d s · 5) for value network.
The network for φ is (100, 100) with state as the input and the action concatenated with the second layer.
All experiments of PPO with Stein control variate selects the best learning rate from { 0.001, 0.0005, 0.0001 } for φ networks.
We use ADAM (Kingma & Ba, 2014) for gradient descent and evaluate the policy every 20 iterations.
Stein control variate is trained for the best iteration in range of { 250, 300, 400, 500, 800 } .