M IRROR D ESCENT P OLICY O PTIMIZATION
Anonymous authors
Paper under double-blind review
A BSTRACT
Mirror descent (MD), a well-known ﬁrst-order method in constrained convex optimization, has recently been shown as an important tool to analyze trust-region algorithms in reinforcement learning (RL).
However, there remains a considerable gap between such theoretically analyzed algorithms and the ones used in practice.
Inspired by this, we propose an efﬁcient RL algorithm, called mirror descent policy optimization (MDPO).
MDPO iteratively updates the policy by approximately solving a trust-region problem, whose objective function consists of two terms: a linearization of the standard RL objective and a proximity term that restricts two consecutive policies to be close to each other.
Each update performs this approximation by taking multiple gradient steps on this objective function.
We derive on-policy and off-policy variants of MDPO, while emphasizing important design choices motivated by the existing theory of MD in RL.
We highlight the connections between on-policy MDPO and two popular trust-region RL algorithms:
TRPO and PPO, and show that explicitly enforcing the trust-region constraint is in fact not a necessity for high performance gains in TRPO.
We then show how the popular soft actor-critic (SAC) algorithm can be derived by slight modiﬁcations of off-policy MDPO.
Overall, MDPO is derived from the MD principles, offers a uniﬁed approach to viewing a number of popular RL algorithms, and performs better than or on-par with TRPO, PPO, and SAC in a number of continuous and discrete control tasks.
I NTRODUCTION
An important class of RL algorithms consider an additional objective in their policy optimization that aims at constraining the consecutive policies to remain close to each other.
These algorithms are referred to as trust region or proximity-based , resonating the fact that they make the new policy to lie within a trust-region around the old one.
This class includes the theoretically grounded conservative policy iteration (CPI) algorithm
[14], as well as the state-of-the-art deep RL algorithms, such as trust-region policy optimization (TRPO) [25] and proximal policy optimization (PPO) [27].
The main difference between these algorithms is in the way that they enforce the trust-region constraint.
TRPO enforces it explicitly through a line-search procedure that ensures the new policy is selected such that its KL-divergence with the old policy is below a certain threshold.
PPO takes a more relaxed approach and updates its policies by solving an unconstrained optimization problem in which the ratio of the new to old policies is clipped to remain bounded.
It has been shown that this procedure does not prevent the policy ratios to go out of bound, and only reduces its probability [30, 8].
Mirror descent (MD) [5, 3] is a ﬁrst-order optimization method for solving constrained convex problems.
Although MD is theoretically well-understood in optimization [2, 13], only recently, has it been investigated for policy optimization in RL [24, 11, 19, 28].
Despite the progress made by these results in establishing connections between MD and trust-region policy optimization, there are still considerable gaps between the trust-region RL algorithms that have been theoretically analyzed in their tabular form [28] and those that are used in practice, such as TRPO and PPO.
In this paper, motivated by the theory of MD in tabular RL, our goal is to derive scaleable and practical RL algorithms from the MD principles, and to use the MD theory to better understand and explain the popular trust-region policy optimization methods.
Going beyond the tabular case, when the policy belongs to a parametric class, the trust-region problems for policy update in RL cannot be solved in closed-form.
We propose an algorithm, called mirror descent policy optimization (MDPO), that addresses this issue by approximately solving these trust-region problems via taking multiple gradient steps on their objective functions.
We derive on-policy and off-policy variants of MDPO (Section 4).
We highlight the connection between on-policy MDPO and TRPO and PPO (Section 4.1), and empirically compare it against these algorithms on several continuous control tasks from OpenAI Gym [6] (Section 5.3).
We then show that if we deﬁne the trust-region w.r.t.
the uniform policy , instead of the old one, our off-policy MDPO coincides with the popular soft actor-critic (SAC) algorithm [12].
We discuss this connection in detail (Section 4.2) and empirically compare these algorithms using the same set of continuous control problems (Section 5.4).
Our observations on the comparison between the MDPO algorithms and TRPO, PPO, and
SAC are a result of extensive empirical studies on different versions of these algorithms (Section 5 and Appendices E and F).
In particular, we ﬁrst compare the vanilla versions of these algorithms in order to better understand how the core of these methods work relative to each other.
We then add a number of code-level optimization techniques derived from the code-bases of
TRPO, PPO, and SAC to these algorithms to compare their best form (those that obtain the best results reported in the literature) against each other, while also evaluating MDPO with
PPO on 21 Atari games.
We address the common belief within the community that explicitly enforcing the trust-region constraint is a necessity for good performance in TRPO, by showing that MDPO, a trust-region method based on the MD principles, does not require enforcing a hard constraint and achieves strong performance by solely solving an unconstrained problem.
We address another common belief that PPO is a better performing algorithm than TRPO.
By reporting results of both the vanilla version and the version loaded with code-level optimization techniques for all algorithms, we show that in both cases, TRPO consistently outperforms PPO.
This is in line with some of the ﬁndings from a recent study on PPO and TRPO [8].
Finally, we provide an optimization perspective for SAC, instead of its initial motivation as an entropy-regularized (soft) approximate dynamic programming algorithm.
Through comprehensive experiments, we show that on-policy and off-policy MDPO achieve state-of-the-art performance across a number of benchmark tasks, and can be excellent alternatives to popular policy optimization algorithms, such as TRPO, PPO, and SAC.
P RELIMINARIES
In this paper, we assume that the agent’s interaction with the environment is modeled as a γ -discounted
Markov decision process (MDP), denoted by M = ( S , A , P, R, γ, µ ) , where S and A are the state and action spaces; P ≡ P ( s (cid:48) | s, a ) is the transition kernel; R ≡ r ( s, a ) is the reward function; γ ∈ (0 , 1) is the discount factor; and µ is the initial state distribution.
Let π : S → ∆ A be a stationary
Markovian policy, where ∆ A is the set of probability distributions on A .
The discounted frequency of visiting a state s by following a policy π is deﬁned as ρ π ( s ) ≡ (1 − γ )
E [ (cid:80) t ≥ 0 γ t I { s t =
s }| µ, π ] .
The value function of a policy π at a state s ∈ S is deﬁned as V π ( s ) ≡ E [ (cid:80) t ≥ 0 γ t r ( s t , a t ) | s 0 = s, π ] .
Similarly, the action-value function of π is deﬁned as Q π ( s, a ) =
E [ (cid:80) t ≥ 0 γ t r ( s t , a t ) | s 0 =
s, a 0 = a, π ] .
The difference between the action-value Q and value V functions is referred to as the advantage function A π ( s, a ) =
Q π ( s, a ) − V π ( s ) .
Since ﬁnding an optimal policy for an MDP involves solving a non-linear system of equations and the optimal policy may be deterministic (less explorative), many researchers have proposed to add a regularizer in the form of an entropy term to the reward function, and then solve the entropyregularized (or soft ) MDP (e.g., [15, 29, 24]).
In this formulation, the reward function is modiﬁed as r λ ( s, a )
=
r ( s, a )+ λH ( π ( ·| s )) , where λ is the regularization parameter and H is an entropy-related term, such as Shannon entropy [9, 22], Tsallis entropy [16, 23], or relative entropy [1, 21].
Setting λ = 0 , we return to the original formulation, also referred to as the hard MDP.
In what follows, we use the terms ‘regularized’ and ‘soft’ interchangeably.
2. M IRROR D ESCENT IN C ONVEX O PTIMIZATION
Mirror Descent (MD) [3] is a ﬁrst-order trust-region optimization method for solving constrained convex problems, i.e., x ∗ ∈ arg min x ∈ C f ( x ) , where f is a convex function and the constraint set C is convex compact.
In each iteration, MD minimizes a sum of two terms: 1) a linear approximation of the objective function f at the previous estimate x k , and 2) a proximity term that measures the distance between the updated x k +1 and current x k estimates.
MD is considered a trust-region method, since the proximity term keeps the updates x k and x k +1 close to each other.
We may write the MD update as
[Equation]
where B ψ ( x, x k ) :
= ψ ( x ) − ψ ( x k ) − (cid:104)∇ ψ ( x k ) , x − x k (cid:105) is the Bregman divergence associated with a strongly convex potential function ψ , and t k is a step-size determined by the MD analysis.
When ψ = 12 (cid:107)·(cid:107) 22 , the Bergman divergence is the Euclidean distance B ψ ( x, x k )
= 12 (cid:107) x − x k (cid:107) 22 , and (1) becomes the projected gradient descent algorithm [2].
When ψ is the negative Shannon entropy, the
Bregman divergence term takes the form of the KL divergence, i.e., B ψ ( x, x k ) =
KL ( x, x k ) .
In this case, when the constraint set C is the unit simplex, C = ∆ X , MD becomes the exponentiated gradient descent algorithm and (1) has the following closed form [3]:
[Equation]
where x ik and ∇ i f are the i th coordinates of x k and ∇ f .
M IRROR D ESCENT IN RL
The goal in RL is to ﬁnd an optimal policy π ∗ .
Two common notions of optimality, and as a result, two distinct ways to formulate RL as an optimization problem are as follows:
[Equation]
In (3a), the value function is optimized over the entire state space S .
This formulation is mainly used in value function based RL algorithms.
On the other hand, the formulation in (3b) is more common in policy optimization, where a scalar that is the value function at the initial state ( s ∼ µ ) is optimized.
Unlike the MD optimization problem, the objective function is not convex in π in either of the above two RL optimization problems.
Despite this issue, [11] and [28] have shown that we can still use the general MD update rule (1) and derive MD-style RL algorithms with the update rules
[Equation]
for the optimization problems (3a) and (3b), respectively.
Note that while in (4), the policy is optimized uniformly over the state space S , in (5), it is optimized over the measure ρ π k , i.e., the state frequency induced by the current policy π k .
M IRROR D ESCENT P OLICY O PTIMIZATION
In this section, we derive on-policy and off-policy RL algorithms based on the MD-style update rules (4) and (5).
We refer to our algorithms as mirror descent policy optimization (MDPO).
Since the trust-region optimization problems in the update rules (4) and (5) cannot be solved in closed-form, we approximate these updates with multiple steps of stochastic gradient descent (SGD) on the objective functions of these optimization problems.
In our on-policy MDPO algorithm, described in Section 4.1, we use the update rule (5) and compute the SGD updates using the Monte-Carlo (MC) estimate of the advantage function A π k gathered by following the current policy π k .
On the other hand, our off-policy MDPO algorithm, described in Section 4.2, is based on the update rule (4) and calculates the SGD update by estimating A π k using samples from a replay buffer.
In our MDPO algorithms, we deﬁne the policy space, Π , as a class of smoothly parameterized stochastic polices, i.e., Π = { π ( ·| s ; θ ) : s ∈ S , θ ∈ Θ } .
We refer to θ as the policy parameter.
We will use π and θ to represent a policy, and Π and Θ to represent the policy space, interchangeably.
4. O N -P OLICY MDPO
In this section, we derive an on-policy RL algorithm based on the MD-based update rule (5), whose pseudo-code is shown in Algorithm 1 in Appendix A.
We refer to this algorithm as on-policy MDPO.
We may write the update rule (5) for the policy space Θ (deﬁned above) as
[Equation]
Each policy update in (6) requires solving a constrained (over Θ ) optimization problem.
In on-policy
MDPO, instead of solving this problem, we update the policy by performing multiple SGD steps on the objective function Ψ ( θ, θ k ) .
Interestingly, performing only a single SGD step on Ψ( θ, θ k ) is not sufﬁcient as ∇ θ KL ( · ; π θ , π θ k ) | θ = θ k = 0 , and thus, if we perform a single-step SGD, i.e.,
[Equation]
the resulting algorithm would be equivalent to vanilla policy gradient and misses the entire purpose of enforcing the trust-region constraint.
As a result, the policy update at each iteration k of on-policy
MDPO involves m SGD steps as
[Equation]
where the gradient of the objective function
[Equation]
can be estimated in an on-policy fashion using the data generated by the current policy π θ k .
Since in practice, the policy space is often selected as Gaussian, we use the closed-form of KL in this estimation.
Our on-policy MDPO algorithm
(Algorithm 1, Appendix A) has close connections to two popular on-policy trust-region RL algorithms: TRPO [25] and PPO [27].
We now discuss the similarities and differences between on-policy MDPO and these algorithms.
Comparison with TRPO .
At each iteration k , TRPO considers the constrained optimization problem
[Equation] [Equation]
and updates its policy parameter by taking a step in the direction of the natural gradient of the objective function in (8) as θ k +1 ← θ k + ηF − 1 E s ∼ ρθk a ∼ π θk
[Equation]
∇ log π
[Equation]
k ( a | s ) A θ k ( s, a ) (cid:3) , where F = E s ∼ ρθk a ∼ π θk (cid:2) ∇ log π θ k ( a | s ) ∇ log π θ k ( a | s ) (cid:62) (cid:3) is the Fisher information matrix for the current policy π θ k .
It then explicitly enforces the trust-region constraint in (8) by a line-search : computing the KL-term for θ = θ k +1 and checking if it is larger than the threshold δ , in which case, the step size is reduced until the constraint is satisﬁed.
In comparison to TRPO, ﬁrst, on-policy MDPO does not explicitly enforce the trust-region constraint, but approximately satisﬁes it by performing multiple steps of SGD on the objective function of the optimization problem in the MD-style update rule (6).
We say “ it approximately satisﬁes the constraint ” because instead of fully solving (6), it takes multiple steps in the direction of the gradient of its objective function.
Second, on-policy MDPO uses simple SGD instead of natural gradient, and thus, does not have to deal with the computational overhead of computing (or approximating) the inverse of the Fisher information matrix.
1 Third, the direction of KL in on-policy MDPO, KL ( π, π k ) , is consistent with that in the MD update rule in convex optimization and is different than that in
TRPO, KL ( π k , π ) .
This does not cause any sampling problem for either algorithm, as both calculate the KL-term in closed-form (Gaussian policies).
Fourth, while TRPO uses heuristics to deﬁne the step-size and to reduce it in case the trust-region constraint is violated, on-policy MDPO uses a simple schedule, motivated by the theory of MD [3], and sets t k =1 − k/K , where K is the maximum number of iterations.
This way it anneals the step-size t k from 1 to 0 over the iterations of the algorithm.
Comparison with PPO .
At each iteration k , PPO performs multiple steps of SGD on the objective function of the following unconstrained optimization problem:
[Equation]
in which the hyper-parameter (cid:15) determines how the policy ratio, π θ /π θ k , is clipped.
It is easy to see that the gradient of the objective function in (9) is zero for the state-action pairs at which the policy ratio is clipped and is non-zero, otherwise.
However, since the gradient is averaged over all the state-action pairs in the batch, the policy is updated even if its ratio is out of bound for some state-action pairs.
This phenomenon, which has been reported in [30] and [8], shows that clipping in
PPO does not prevent the policy ratios to go out of bound, but it only reduces its probability.
This means that despite using clipping, PPO does not guarantee that the trust-region constraint is always satisﬁed.
In fact, recent results, including those in [8] and our experiments in Section 5.3, show that most of the improved performance exhibited by PPO is due to code-level optimization techniques, such as learning rate annealing, observation and reward normalization, and in particular, the use of generalized advantage estimation (GAE) [26].
Although both on-policy MDPO and PPO take multiple SGD steps on the objective function of unconstrained optimization problems (6) and (9), respectively, the way they handle the trust-region constraint is completely different.
Another interesting observation is that the adaptive and ﬁxed KL algorithms (we refer to as KL-PPO here), proposed in the PPO paper [27], have policy update rules similar to on-policy MDPO.
However, these algorithms have not been used much in practice, because it was shown in the same paper that they perform much worse than PPO.
Despite the similarities, there are three main differences between the update rules of KL-PPO and on-policy MDPO.
First, KL-PPO uses mini-batches whereas MDPO uses the entire data for their multiple ( m ) gradient updates at each round.
Second, the scheduling scheme used for the t k parameter is quite different in KL-PPO and MDPO.
In particular, KL-PPO either uses a ﬁxed t k or deﬁnes an adaptive scheme that updates (increase/decrease) t k based on the
KL divergence magnitude at that time step.
On the other hand, on-policy MDPO uses an annealed schedule to update t k , starting from 1 and slowly bringing it down to near 0 .
Third, similar to TRPO, the direction of KL in KL-PPO, KL ( π k , π ) , is different than that in on-policy MDPO, KL ( π, π k ) .
Since in our experiments, on-policy MDPO performs signiﬁcantly better than PPO (see Section 5.3), we conjecture that either any or a combination of the above differences, especially the ﬁrst two, is the reason for the inferior performance of KL-PPO, compared to PPO, as reported in [27].
4. O FF -P OLICY MDPO
In this section, we derive an off-policy RL algorithm based on the MD update rule (4).
We refer to this as off-policy MDPO and provide the pseudo-code in Algorithm 2 in Appendix A. To emulate the uniform sampling over the state space required by (4), Algorithm 2 samples a batch of states from a replay buffer D (Line 4).
While this sampling scheme is not truly uniform, it makes the update less dependent on the current policy.
Similar to the on-policy case, we write the update rule (4) for the policy class Θ as
[Equation]
Ψ( θ, θ k ) , where Ψ( θ, θ k ) = E s ∼D (cid:104) E
[Equation]
The main idea in Algorithm 2 is to estimate the advantage or action-value function of the current policy, A θ k or Q θ k , in an off-policy fashion, using a batch of data randomly sampled from the replay buffer D .
In a similar manner to the policy update of our on-policy MDPO algorithm (Algorithm 1), described in Section 4.1, we then update the policy by taking multiple SGD steps on the objective function Ψ ( θ, θ k ) of the optimization problem (10) (by keeping θ k ﬁxed). A more presentable form of the policy loss in Ψ can be written as follows:
[Equation] [Equation] In particular, the ﬁrst two terms here are obtained just by opening the KL, whereas the advantage estimate is replaced by a neural network estimate Q ψ , which is learned from off-policy data in a
TD (0) fashion. Furthermore, solely as an implementation detail, another neural network V φ is used in conjunction with Q ψ , which is ﬁt to the Q ψ estimate of the current policy.
Finally, the policy loss also uses the reparameterization trick where (cid:101) a θ ( (cid:15), s ) is the action generated by sampling the (cid:15) noise from a zero-mean normal distribution N .
We can easily modify Algorithm 2 to optimize soft (entropy regularized) MDPs.
In this case, in the critic update (Line 12 of Algorithm 2), the Q ψ update remains unchanged, while in the V φ update, the target changes from E a ∼ π θk +
[ Q ψ ( · , a )] to E a {+∼ π θk +
+} [ Q ψ ( · , a ) − λ log π ( a |· )] .
The loss function (11) used for the actor (policy) update (Lines 7-9 of Algorithm 2) is also modiﬁed, Q ψ becomes the soft Q -function and a term λt k log π θ k
( (cid:101) a θ ( (cid:15), s ) | s ) is added inside the expectation.
We denote these changes explicitly in Algorithm 3. Similarly to on-policy MDPO that has close connection to TRPO and PPO, discussed in Section 4.1, off-policy MDPO (Algorithm 2 and 3) is related to the popular soft actor-critic (SAC) algorithm [12].
We now derive SAC by slight modiﬁcations in the derivation of off-policy MDPO.
This gives an optimization interpretation to SAC, which we then use to show strong ties between the two algorithms.
Comparison with SAC .
Soft actor-critic is an approximate policy iteration algorithm in soft MDPs.
At each iteration k , it ﬁrst estimates the (soft) Q -function of the current policy, Q π k , and then sets the next policy to the (soft) greedy policy w.r.t.
the estimated Q -function as
[Equation]
(12) where Z SAC ( s ) =
E a ∼ π k ( ·| s )
[Equation] exp (cid:0) Q π k
( s, a ) (cid:1)(cid:3) is a normalization term.
However, since tractable policies are preferred in practice, SAC suggests to project the improved policy back into the policy space considered by the algorithm, using the following optimization problem:
[Equation]
This update rule computes the next policy as the one with the minimum KL-divergence to the term on the RHS of (12)
Since the optimization problem in (13) is invariant to the normalization term, unlike (12), the policy update (13) does not need to compute Z SAC ( s ) .
By writing the KL deﬁnition and using the reparameterization trick in (13), SAC updates its policy by minimizing the following loss function:
[Equation]
Comparing the loss in (14) with the one used in off-policy MDPO (Eq. 11), we notice that despite the similarities, the main difference is the absence of the current policy, π θ k , in the SAC loss function.
To explain the relationship between off-policy MDPO and SAC, recall from Section 2.1 that if the constraint set is the unit simplex, i.e., C = ∆ X , the MD update has the closed-form shown in (2).
Thus, if the policy class (constraint set) Π in the update rule (4) is the entire space of stochastic policies, then we may write (4) in closed-form as (see e.g., [20, 28]) [Equation]
[Equation]
where Z ( s ) =
E a ∼ π k ( ·| s ) (cid:2) exp (cid:0)
t k Q π k ( s, a ) (cid:1)(cid:3) is a normalization term.
The closed-form solution (15) is equivalent to solving the constrained optimization problem (4) in two phases (see [13]): 1) solving the unconstrained version of (4) that leads to the numerator of (15), followed by 2) projecting this (unconstrained) solution back into the constrained set (all stochastic policies) using the same choice of Bregman divergence (KL in our case), which accounts for the normalization term in (15).
Hence, when we optimize over the parameterized policy space Θ (instead of all stochastic policies), the MD update would be equivalent to ﬁnding a policy θ ∈ Θ with minimum KL-divergence to the solution of the unconstrained optimization problem obtained in the ﬁrst phase (the numerator of Eq. 15).
This leads to the following policy update rule:
[Equation]
If we write the deﬁnition of KL and use the reparameterization trick in (16), we will rederive the loss function (11) used by our off-policy MDPO algorithm.
2 Note that both SAC (13) and off-policy
MDPO (16) use KL projection to project back to the set of policies.
For SAC, the authors argue that any projection can be chosen arbitrarily.
However, our derivation clearly shows that the selection of
KL projection is dictated by the choice of the Bregman divergence.
As mentioned earlier, the main difference between the loss functions used in the policy updates of
SAC (14) and off-policy MDPO (11) is the absence of the current policy, π θ k , in the SAC’s loss function.
The current policy, π θ k , appears in the policy update of off-policy MDPO, because it is a trust-region algorithm, and thus, tries to keep the new policy close to the old one.
On the other hand, following the original interpretation of SAC as an approximate dynamic programming algorithm, its policy update does not contain a term to keep the new and old policies close to each other.
It is interesting to note that SAC’s loss function can be re-obtained by repeating the derivation which leads to off-policy MDPO, and replacing the current policy, π θ k , with the uniform policy in the objective (10) of off-policy MDPO.
Therefore, SAC can be considered as a trust-region algorithm w.r.t.
the uniform policy (or an entropy regularized algorithm).
This means its update encourages the new policy to remain explorative , by keeping it close to the uniform policy.
Trust-PCL [21] uses the path consistency idea along with entropy regularization and an additional term for remaining close to a past policy.
In principle, this resembles the off-policy MDPO algorithm. However, Trust-PCL uses a multi-step consistency loss whereas off-policy MDPO uses single transitions.
Moreover, besides different derivations, there remain implementation-level details between the two, as Trust-PCL only uses a V network while off-policy MDPO uses a Q function as well.
Due to space constraints, we defer a discussion on the forward and reverse KL directions (including the ECPO [20] algorithm) to Appendix D.
E XPERIMENTAL R ESULTS
In this section, we empirically evaluate our on-policy and off-policy MDPO algorithms on a number of continuous control tasks from OpenAI Gym [6], and compare them with state-of-the-art baselines: TRPO, PPO, and SAC.
We report all experimental details, including the hyper-parameter values used by the algorithms, in Appendix B.
In the tabular results, both in the main paper and in Appendices E and F, we report the ﬁnal training scores averaged over 5 runs and their 95% conﬁdence intervals (CI).
We bold-face the values with the best mean scores.
We also compare on-policy MDPO and PPO on 21 Atari games from the ALE benchmark [4], showing averages over 5 random seeds.
We strictly follow the hyperparameters reported in the PPO paper, and use m =for all games.
For off-policy MDPO, we experiment with two potential functions ψ to deﬁne the Bregman divergence B ψ : 1) Shannon entropy, which results in the KL version (described in
Section 4.2), and 2) Tsallis entropy, which results in the
Tsallis version of off-policy MDPO.
We refer the reader to
Appendix C for the complete description and detailed derivation of the Tsallis version.
Note that we did not pursue a similar bifurcation between Tsallis and KL induced Bregman divergences for the on-policy case since the exact derivations are more tedious there.
Another important point to note is that the Tsallis entropy gives us a range of entropies, controlled by the parameter q ∈ (0 , 2] (see Appendix C).
Two special cases are 1) Shannon entropy for q = 1 . 0 , and 2) sparse Tsallis for q = 2 .
5. O N M ULTIPLE SGD S TEPS
In on-policy MDPO, we implement the multi-step update at each MD iteration of the algorithm, by sampling M trajectories from the current policy, generating estimates of the advantage function, and [Table] performing m gradient steps using the same set of trajectories.
We evaluated on-policy MDPO for different values of m in all tasks.
We show the results for Walker2d in Figure 2 (top).
The results for all tasks show a clear trade-off between m and the performance.
Moreover, m = 10 seems to be the best value across the tasks.
This is why we use m = 10 in all our on-policy MDPO experiments.
Our results clearly indicate that using m = 1 leads to inferior performance as compared to m = 10 , reafﬁrming the theory that suggests solving the trust-region problem in RL requires taking several gradient steps at each MD iteration.
Finally, we ran a similar experiment for TRPO which shows that performing multiple gradient steps at each iteration of TRPO does not lead to any improvement.
In fact our results showed that in some cases, it even leads to worse performance than when performing a single-step update.
For off-policy MDPO, performing multiple SGD steps at each MD iteration (Lines 6 to 10 in
Algorithm 2) becomes increasingly time-consuming as the value of m grows.
This is because offpolicy algorithms perform substantially more gradient updates than their on-policy counterparts (a gradient step per environment step vs. a gradient step per almost 1 , 000 environment steps).
To address this issue, we resort to staying close to an m -step old copy of the current policy, while performing a single gradient update at each iteration of the algorithm.
This copy is updated every m iterations with the parameters of the current policy.
Our results for the Hopper domain in Appendix G.1 show that the performance of MDPO can be improved by performing m gradient updates at each iteration, but we omit from performing these experiments at scale because of their unreasonably high wall-clock time.
Finally, we evaluated off-policy MDPO for different values of m in all tasks and show the results for Walker2d in Figure 2 (bottom).
We found it hard to identify a single best value of m for all tasks.
However, m = 1000 had the most reasonable performance across the tasks, and thus, we use it in all our off-policy MDPO experiments.
5. O N C ODE - LEVEL O PTIMIZATIONS
There are certain “code-level optimization techniques" used in code-bases of TRPO, PPO, and SAC that result in enhanced performance.
In [8], the authors provided a case study of these techniques in
TRPO and PPO.
We provide a detailed description of these techniques in Appendix B, and report the performance of the algorithms without these techniques (vanilla or minimal version) and with these techniques (loaded and loaded+GAE versions) in Appendices E and F. Note that the loaded+GAE version of TRPO and PPO match their state-of-the-art results in the literature.
Overall, the key takeaway from our results is that MDPO performs signiﬁcantly better than PPO and on-par or better than TRPO and SAC, while being much simpler to implement, and more general as being derived from the theory of MD in RL.
In the next two sections, we report our main observations from our on-policy and off-policy experiments.
5. O N - POLICY R ESULTS
We implemented three versions of on-policy MDPO, TRPO, and PPO: 1) the vanilla or minimal version, 2) the loaded version in which we add the code-level optimization techniques to these algorithms, and 3) the loaded version plus GAE, whose results are reported in Table 1.
The results for all three versions are reported in Appendix E.
We elicit the following observations from our results.
First, on-policy MDPO performs better than or on par with TRPO and better than PPO across all tasks.
This contradicts the common belief that explicitly enforcing the constraint (e.g., through line-search) as done in TRPO is necessary for achieving good performance.
Second, on-policy MDPO can be implemented more efﬁciently than
TRPO, because it does not require the extra line-search step.
Notably, TRPO suffers from scaling issues as it requires computing the correct step-size of the gradient update using a line search, which presents as an incompatible part of the computation graph in popular auto-diff packages, such as
TensorFlow.
Moreover, MDPO performs signiﬁcantly better than PPO, while remaining equally efﬁcient in terms of implementation.
Third, TRPO performs better than PPO consistently, both in the vanilla case and when the code-level optimizations (including GAE) are added to both algorithms.
This is in contrast to the common belief that PPO is a better performing algorithm than TRPO.
Our observation is in line with what noted in the empirical study of these two algorithms in [8], and we believe it further reinforces it.
Adding code-level optimizations and GAE improve the performance of
PPO, but not enough to outperform TRPO, when it also beneﬁts from these additions.
Lastly, fourth, it was shown in [30] that PPO is prone to instability issues.
Our experiments show that this is indeed the case as PPO’s performance improves until the standard time-step mark of 1 M, and then decreases in some tasks.
For example, in the Ant-v2 domain, both PPO and TRPO get to a similar score ( 1000) around the 1M mark
but then PPO’s performance decreases whereas TRPO continues to increase, as can be seen in Table 1 and
Appendix E.
Atari results .
To show that MDPO can be robustly used as an excellent substitute for PPO, we compare the two algorithms on 21 games from the ALE benchmark.
Our results show that MDPO performs better or on par than PPO on 15 out of 21 games, while performing better than PPO on 6 out of 21 games.
Due to space constraints, we report the full training plots in Appendix 10.
Interestingly, both MDPO and PPO behave quite differently in a lot of games.
Since we do not optimize any hyperparameters for MDPO, it might be possible to get more gains with further ﬁnetuning.
Note that it is well known that TRPO leads to much inferior performance than PPO on the ALE benchmark.
Indeed, comparing our results with those in the TRPO paper, we see that both MDPO and PPO win in 5 out of the 6 games reported in the TRPO paper.
5. O FF - POLICY R ESULTS
Similar to the on-policy case, we implemented both vanilla and loaded versions of off-policy MDPO and SAC.
We report the results of the loaded version in this section (Table 1), and the complete results in Appendix F.
We observe the following from these results.
First, off-policy MDPO-KL performs on par with SAC across all tasks.
Second, off-policy MDPO-Tsallis that has an extra hyper-parameter q to tune can outperform SAC across all tasks.
We observe that the best performing values of q are different for each domain but always lie in the interval [1 . 0 , 2 . 0] .
Third, off-policy MDPO results in a performance increase in most tasks, both in terms of sample efﬁciency and ﬁnal performance, in comparison to on-policy MDPO.
This is consistent with the common belief about the superiority of off-policy to on-policy algorithms.
Similar to off-policy MDPO, we can incorporate the Tsallis entropy in SAC.
In [17], the authors showed performance improvement over SAC by properly tuning the value of q in SAC-Tsallis.
However, in domains like Humanoid-v2 and Ant-v2, they only reported results for the 1M time-step mark, instead of the standard 3M.
In our preliminary experiments with SAC-Tsallis in Appendix G.3, we did not see much improvement over SAC by tuning q , unlike what we observed in our MDPOTsallis results.
More experiments and further investigation are hence needed to better understand the effect of Tsallis entropy (and q ) in these algorithms.
C ONCLUSIONS
We derived on-policy and off-policy algorithms from the theory of MD in RL.
Each policy update in our MDPO algorithms is formulated as a trust-region optimization problem.
However, our algorithms do not update their policies by solving these problems, instead, update them by taking multiple gradient steps on the objective function of these problems.
We described in detail the relationship between on-policy MDPO and TRPO and PPO.
We also discussed how SAC can be derived by slight modiﬁcations of off-policy MDPO.
Finally, using a comprehensive set of experiments, we showed that on-policy and off-policy MDPO can achieve performance better than or equal to these three popular RL algorithms, and thus can be considered as excellent alternatives to them.
We can think of several future directions.
In addition to evaluating MDPO algorithms in more complex and realistic problems, we would like to see their performance in discrete action problems in comparison with algorithms like DQN and PPO.
Investigating the use of Bregman divergences other than KL seems to be promising.
Our work with Tsallis entropy is in this direction but more algorithmic and empirical work needs to be done.
Finally, there are recent theoretical results on incorporating exploration into the MD-based updates.
Applying exploration to MDPO could prove most beneﬁcial, especially in complex environments. Appendix A P SEUDOCODES
Below we provide the pseudocodes for the two MDPO algorithms, on-policy and off-policy.
Algorithm
1: Initialize Value network V φ ; Policy networks π new π old ; 2: k
K do 3: # On policy Data Generation 4:
Simulate the current policy π θ k for M steps; 5: for t = 1 , . .
, M do 6:
Calculate return R t =
R ( s t , a t )=
(cid:80) Mj
=
t γ j − t r j ; Estimate advantage A ( s t , a t )=
R ( s t , a t ) − V φ ( s t ) ; 7: end for 8: # Policy Improvement (Actor Update) 9: θ (0) k
= θ k ; 10: for i = 0 , . . .
, m − 1 do 11: θ ( i +1)
k ← θ ( i ) k + η ∇ θ Ψ
( θ, θ k ) | θ
{+= θ ( i ) k ; (Eq. 7) 12: end for 13: θ k +
+}
= θ ( m ) k ; 14: # Policy Evaluation (Critic Update) 15:
Update φ by minimizing the N -minibatch ( N ≤ M ) loss function L V φ = 1 N (cid:80)
Nt =1 (cid:2)
V φ ( s t ) − R t (cid:3) 2 ; 16: end for θ
) k θ
k ← θ ( i ) k
+ η ∇ θ L ( θ θ k )
| θ
= θ i ) k
[Equation]
[Equation]
[Table]
[Equation]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
∇
[Equation]
[Equation]
[Equation]
[Table]
B E XPERIMENTAL D ETAILS B. S ETUP
We evaluate all algorithms on OpenAI Gym [6] based continuous control tasks, including Hopper-v2,
Walker2d-v2, HalfCheetah-v2, Ant-v2, Humanoid-v2 and HumanoidStandup-v2.
All experiments are run across 5 random seeds.
Each plot shows the empirical mean of the random runs while the shaded region represents a 95 % conﬁdence interval ( empirical mean ± 1 .
96 × empirical standard deviation / √ n = 5 ).
We report results in both ﬁgure and tabular forms.
The tabular results denote the mean ﬁnal training performance and the best values with overlapping conﬁdence intervals are bolded.
For all off-policy experiments, we use λ = 0 .
2 across all tasks, which is known to be the best performing value for all tasks according to [12] (In our experiments, a value of 0.2 worked equally well for Humanoid as the reported 0.05 in the SAC paper).
We report all details of our off-policy experiments including hyperparameter values in Table 3.
Moreover, since doing multiple gradient steps at each iteration becomes quite time consuming for the off-policy case, we get around this issue by ﬁxing the old policy ( π θ k ) for m number of gradient steps, in order to mimic the effect from taking multiple gradients steps at each iteration.
This ensures that the total number of environment steps are always equal to the total number of gradients steps, irrespective of the value of m .
Finally, for all experiments, we use a ﬁxed Bregman stepsize ( 1 /t k ) as opposed to an annealed version like in the on-policy case.
B. C ODE - LEVEL O PTIMIZATION T ECHNIQUES
The widely available OpenAI Baselines [7] based PPO implementation uses the following ﬁve major modiﬁcations to the original algorithm presented in [27] – value function clipping, reward normalization, observation normalization, orthogonal weight initialization and an annealed learning rate schedule for the Adam optimizer.
These are referred to as code level optimization techniques (as mentioned in above sections) and are originally noted in [8].
Following the original notation, we refer to the vanilla or minimal version of PPO, i.e. without these modiﬁcations as PPO-M.
Then, we consider two PPO versions which include all such code level optimizations, with the hyperparameters given in [27].
One of them does not use GAE while the other version includes GAE.
Therefore they are referred to as PPO-LOADED and PPO-LOADED+GAE respectively.
These versions, although being far from the theory, have been shown to be the best performing ones, and so form as a good baseline.
We do a similar bifurcation for TRPO and on-policy MDPO.
We report all details of our on-policy experiments including hyperparameter values in Table 2.
Similarly, for the off-policy MDPO versions, we again restrain from using the optimization tricks mentioned above.
However we do employ three techniques that are common in actor-critic based algorithms, namely: using separate Q and V functions as in [12], using two Q functions to reduce overestimation bias and using soft target updates for the value function.
Prior work [10, 18] has shown these techniques help improve stability.
Similar to the on-policy experiments, we include a minimal and loaded version for the off-policy experiments as well, which are described in Appendix D. In particular, this branching is done based on the neural network and batch sizes used.
Since the standard values in all on-policy algorithms is different from the standard values used by most off-policy approaches, we show results for both set of values.
This elicits a better comparison between on-policy and off-policy methods.
[Table]
[Table]
[Table]
[Table]
C T SALLIS - BASED B REGMAN D IVERGENCE
As described in section 2.1, the MD update contains a Bregman divergence term.
A Bregman divergence is a measure of distance between two points, induced by a strongly convex function ψ .
In the case where the potential function ψ is the negative Shannon entropy, the resulting Bregman is the
KL divergence.
Similarly, when ψ is the negative Tsallis entropy, for a real number q , i.e.,
[Equation]
we obtain the Tsallis Bregamn divergence, i.e.,
[Equation]
Note that the last term on the RHS of (18) is independent of the policy π being optimized.
Also note that as q → 1 , the Tsallis entropy collapses to the Shannon entropy − (cid:80) a π ( a | s ) log π ( a | s ) , and thus, it generalizes the Shannon entropy.
Moreover, for q = 2 , the Tsallis entropy is called the sparse
Tsallis entropy.
At ﬁrst glance, the above expression is very different from the deﬁnition of the KL divergence.
However, by deﬁning the function log q as
[Equation]
we may write the negative Tsallis entropy, deﬁned by (17), as
[Equation]
and the Tsallis Bregman, deﬁned by (18), in a similar manner to the KL divergence as
B ψ ( π, π k ) =
[Equation]
With this convenient deﬁnition, we can write the Tsallis-based version of the off-policy MDPO objective deﬁned in (11) as
[Equation]
Note that the last term on the RHS of (20) is independent of the policy being optimized (i.e., π or θ ), and thus, does not appear in the loss function L Tsallis ( θ, θ k ) in (21).
Note that on-policy MDPO uses a closed form version for the Bregman divergence (since both policies are Gaussian in our implementation, a closed form of their KL exists).
Such a closed form version for the Tsallis based Bregman is quite cumbersome to handle in terms of implementation, and thus we did not pursue the Tsallis based version in the on-policy experiments.
However, in principle, it is very much feasible and we leave this for future investigation.
D R EVERSE VS . F ORWARD KL D IRECTION
Similar to the on-policy case, the mode-seeking or reverse direction of the KL term in off-policy
MDPO (Eq. 16) is consistent with that in the MD update rule in convex optimization.
With this direction of KL, the optimization problems for policy update in both off-policy MDPO and SAC are invariant to the normalization term Z ( s ) .
Thus, these algorithms can update their policies without computing Z ( s ) .
In [20], the authors proposed an algorithm, called exploratory conservative policy optimization (ECPO), that resembles our soft off-policy MDPO, except in the direction of KL.
Switching the direction of KL to mean-seeking or forward has the extra overhead of estimating the normalization term for ECPO.
However, in [20], they argue that it results in better performance.
They empirically show that ECPO performs better than several algorithms, including one that is close to off-policy MDPO, which they refer to as policy mirror descent (PMD), and report poor performance for it.
We did not use their code-base and exact conﬁguration, but we did not observe such poor performance for our off-policy MDPO.
In fact, experimental results of Section 5.4 show that off-policy MDPO performs better than or on-par with SAC in six commonly used MuJoCo domains.
More experiments and further investigation are deﬁnitely required to better understand the effect of the KL direction in MDPO algorithms.
E O N - POLICY R ESULTS
Here, we report the results for all on-policy algorithms, i.e. TRPO, PPO and MDPO.
We have three variants here, 1) the minimal version , i.e. {TRPO, PPO, MDPO}-M, which makes use of no code level optimizations, 2) the loaded version , i.e. {TRPO, PPO, MDPO}-LOADED, which includes all code level optimizations, and 3) the loaded+GAE version, i.e. {TRPO, PPO, MDPO}-LOADED+GAE, which includes all code level optimizations and also includes the use of GAE.
We see that the overall performance increases in most cases as compared to the minimal versions.
However, the trend in performance between these algorithms remains consistent to the main results.
MDPO
TRPO
PPO
[Table]
[Figure]
[Figure]
MDPO
TRPO
PPO
Hopper-v
[Table]
[Table]
Walker2d-
[Table]
HalfCheetah-
[Table]
Ant-
[Table]
Humanoid-
[Table]
HumanoidStandup
[Table]
[Figure]
F O FF - POLICY R ESULTS
Here, we report the results for all off-policy algorithms,
i
[Table]
e. MDPO and SAC.
We have two variants here, 1) the minimal version ,
i
[Table]
e. MDPO-M and SAC-M, which uses the standard neural network and batch sizes (64) and 2) the loaded version , i
[Table]
e. MDPO-LOADED and SAC-LOADED, which uses a neural network and batch size of 256.
We see that the overall performance increases in most cases as compared to the minimal versions, i
[Table]
e. SAC-M, MDPO-M.
However, the trend in performance between these algorithms remains consistent to the main results.
[Table]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
MDPO-KL
MDPO-Tsallis, q best
SAC
Hopper-v 2428 ( ± 395) 2428 ( ± 395) , q = 1.
1870 ( ± 404)
Walker2d-v 3591 ( ± 366) 4028 ( ± 287) , q = 2.
3738 ( ± 312)
HalfCheetah-v 11823 ( ± 154) 11823 ( ± 154) , q = 1.
11928 ( ± 342)
Ant-v 4434 ( ± 749) 5486 ( ± 737) , q = 2.
4989 ( ± 579)
Humanoid-v 5323 ( ± 348) 5611 ( ± 260) , q = 1.
5191 ( ± 312)
HumanoidStandup-v 143955 ( ± 4499) 165882 ( ± 16604) , q = 1.
154765 ( ± 11721)
[Figure]
G A DDITIONAL E XPERIMENTS
G.
[Figure]
For off-policy MDPO, we use a modiﬁed version of doing multi-step updates at each iteration (see section 5.1) due to computational reasons.
In order to ensure a fair comparison, we used the single-step gradient updates for SAC in our main experiments.
Here, we resort to the original algorithm presented in Algorithm 2, wherein we do m gradient steps at each iteration.
We compare this version of MDPO-KL with a similar multi-step version of SAC, as is originally reported in [12].
In Figure 8 we see that doing multiple updates helps improve the score of both
MDPO and SAC, as is expected.
G. D IFFERENT T SALLIS E NTROPIES FOR B REGMAN AND MDP R EGULARIZATION
So far in the paper, we have used the same Tsallis entropy (same q value) for deﬁning the Bregman divergence as well as the MDP regularizer.
Here, we test the performance for when the two tsallis entropies are different.
For this, we sample from a set of three q values { 1 . 0 , 1 . 5 , 2 . 0 } and report the results for every possible combination of q values used for deﬁning the Bregman divergence and the
MDP regularizer.
We test this on the Walker2d-v2, Humanoid-v2, and Ant-v2 domains (domains where we see the most improvement due to the addition of Tsallis entropy) and observe that sticking to the same q values for both cases results in the best performance across all three domains (see
Table 9).
[Figure]
[Table]
[Figure]
[Table]
G. T SALLIS - BASED SAC
We test performance of SAC-Tsallis while varying the q values.
In our preliminary experiments with
SAC-Tsallis in Table
[Table]
we did not see much improvement over SAC by tuning q , unlike what we observed in our MDPO-Tsallis results.
More experiments and further investigation are deﬁnitely needed to better understand the effect of Tsallis entropy (and q ) in these algorithms.
[Figure]