Variational Inference for Policy Gradient
Tianbing Xu

TL;DR
This paper introduces a variational inference approach to improve policy gradient methods in reinforcement learning by explicitly minimizing KL divergence, enabling Bayesian neural network parameterizations.
Contribution
It develops a novel variational inference technique for policy gradient methods, integrating Bayesian neural networks into reinforcement learning algorithms.
Findings
Enhanced policy gradient methods with Bayesian neural networks.
Effective sample generation from posterior distributions.
Improved reinforcement learning performance.
Abstract
Inspired by the seminal work on Stein Variational Inference and Stein Variational Policy Gradient, we derived a method to generate samples from the posterior variational parameter distribution by \textit{explicitly} minimizing the KL divergence to match the target distribution in an amortize fashion. Consequently, we applied this varational inference technique into vanilla policy gradient, TRPO and PPO with Bayesian Neural Network parameterizations for reinforcement learning problems.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsReinforcement Learning in Robotics · Markov Chains and Monte Carlo Methods · Advanced Bandit Algorithms Research
MethodsEntropy Regularization · Proximal Policy Optimization · Trust Region Policy Optimization
Variational Inference for Policy Gradient
Tianbing Xu
(February 2018)
Abstract
Inspired by the seminal work on Stein Variational Inference [2] and Stein Variational Policy Gradient [3], we derived a method to generate samples from the posterior variational parameter distribution by explicitly minimizing the KL divergence to match the target distribution in an amortize fashion. Consequently, we applied this varational inference technique into vanilla policy gradient, TRPO and PPO with Bayesian Neural Network parameterizations for reinforcement learning problems.
1 Parametric Minimization of KL Divergence
Suppose we have a random sample from a base distribution , e.g. , we are able to generate an induced distribution by the general invertible and differentiable transformation (see Appendix A). Our goal is to regard as a variational distribution to match the true distribution such that is minimized.
Lemma 1**.**
[TABLE]
with (1), we can have the following identity for :
[TABLE]
Hence the gradient of with respect to the parameters of transformation mapping is:
[TABLE]
Note that the first term is the usual log-likelihood term, and the second term serves as a repulsive force preventing all ’s from collapsing towards the maximum likelihood estimation. We can perform stochastic gradient descent using (2) to find the optimal . This method is related to the interesting and seminal Stein Variational Inference [1], the major difference is that the later one uses kernelized Stein variational gradient, while we use log determinate as the repulsive force.
2 Bayesian Formulation of Variational RL
We generate the policy distribution from Bayesian Neural Network. Suppose is the parameter of the policy network, the parameter is able to generated from a base distribution with an invertible and differentiable transformation function . We may adopt complicated differentiable transformation functions . For a simple example, the weight for each connection of neuron could be . For each realized weight parameter , we are able to generate a stochastic multi-modal policy distribution represented as a Neural Network with several hidden layers.
is the expected cumulative reward under policy ,
[TABLE]
is a distribution over and is the Shannon entropy of . We want to find to maximize the following objective:
[TABLE]
[TABLE]
The optimal is:
[TABLE]
This formulation is originally proposed in [3]. The difficulty of this formulation is calculating the normalization factor . We are able to bypass it by calculating the gradient of the its log-probability which was a exciting idea from Stein variational inference[2] and similarly, here we can use Eq. 2. Suppose we generate sample of by transforming random noise using . Let be the induced variational distribution from the transformation. Our optimization objective is to match the induced variational distribution and the ’true’ policy parameter distribution by minimizing . The gradients for the parameters () of policy distribution are,
[TABLE]
where can be calculated using the standard policy gradient formula,
[TABLE]
We can sample different for exploration in different sessions. We may want to decrease during the training to anneal the temperature to stationary parameter distributions.
is the advantage function, it can be estimated as or let baseline , or , and is the state-action value and is the value function. For more sophisticated estimation, we can use GAE (Generalized Advantage Estimation, [5]).
Example 1: For a simple transformation of the following form:
[TABLE]
the sample gradient estimation w.r.t and is:
[TABLE]
3 Variational Policy Gradient with Transformation
We introduce our varational inference into vanilla policy gradient REINFORCE [7]. Given a realization of network parameter , in order to generate a stochastic policy distribution, we introduce another random noise . With the second invertible and differentiable transformation , it induces a stochastic policy distribution in the closed form,
[TABLE]
Hence, the policy gradient is,
[TABLE]
When the inverse of transformation is difficult to calculate, we could use directly,
[TABLE]
3.1 Simple Policy Network Parameterization
We adopt a very simple yet general representative generative model. The policy parameter is generated from noise with transformation , which is a neural network parameterized with . With another noise , we generate the action by another transformation , parameterized with , from policy network distribution.
[TABLE]
This induces a simple policy distribution,
[TABLE]
and are mean and variance networks, with weight parameter , they are used to generate the posterior distribution of action mean . For continuous control problems, we use MLP (multilayer perceptron) to represents the mean and variance networks. Then we can find the variational policy parameter distribution by minimizing the KL divergence between the variation distribution generated based on the transformation and the optimal posterior parameter distribution (energy-based model, Eq. 3) as .
From the full complete gradient of Eq.(4), we have,
[TABLE]
It is straightforward to auto diff and . is the backprop of variance network , for the simplest example, let a sigmoid function, we have,
[TABLE]
3.2 Auxiliary Policy Network Parameterization
For a more general parameterization of the policy, instead of regarding as a parameter of policy, we can take as a random variable, and introduce the auxilliary network parameter , then the action is generated from noise by transformation , it induces the corresponding policy distribution . An example of could be a MLP as,
[TABLE]
Similarly, the posterior of is,
[TABLE]
here the cumulative rewards,
[TABLE]
This gives us a more general representation of the policy, compared to the previous formulation in Section 3.1. Furthermore, it is easy to introduce multi-modal distribution for the stochastic actions.
The gradient of KL divergence between the variational distribution and posterior is Eq. 4. In addition, we need to learn network parameter ,
[TABLE]
4 Connection to TRPO
The motivation is to combine fast convergence with sample efficiency of TRPO [4] and the exploration introduced by variational inference of posterior policy parameter distribution.
The TRPO objective,
[TABLE]
The TRPO Variational Policy Gradient,
[TABLE]
TRPO Variational Policy Update:
[TABLE]
Another important point is how to calculate the divergence between the current and previous policies efficiently?
[TABLE]
To get the Fisher information matrix, first method is to compute the Hessian of averaged divergence,
[TABLE]
This is equivalent to calculate the second derivative of w.r.t. .
The other method is using Covariance matrix,
[TABLE]
5 Connection to PPO
It is natural to adopt our variational inference method to PPO (Proximal Policy Optimization) [6]. The objective function of PPO to be maximized is,
[TABLE]
where
PPO Variational Policy Gradient,
[TABLE]
The PPO Variational Policy Update is,
[TABLE]
Appendix A random variable transformation
Given random variable , we introduce the transformation function to generate random variable . The transformation function,
[TABLE]
needs to be invertible, the inverse image of of set ,
[TABLE]
The inverse image also needs to satisfied the following requirements.
2. 2.
3. 3.
, for any sets {, }
Assume the distribution of r.v. and are and , we have,
[TABLE]
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Yihao Feng, Dilin Wang, and Qiang Liu. Learning to draw samples with amortized stein variational gradient descent. In Conference on Uncertainty in Artificial Intelligence (UAI 2017) , 2017.
- 2[2] Qiang Liu and Dilin Wang. Stein variational gradient descent: A general purpose bayesian inference algorithm. In Advances in Neural Information Processing Systems 29 (NIPS 2016) , 2016.
- 3[3] Yang Liu, Prajit Ramachandran, Qiang Liu, and Jian Peng. Stein variational policy gradient. In Conference on Uncertainty in Artificial Intelligence (UAI 2017) , 2017.
- 4[4] John Schulman, Sergey Levine, Philipp Moritz, Michael I. Jordan, and Pieter Abbeel. Trust region policy optimization. In International Conference on Machine Learning (ICML 2015) , 2015.
- 5[5] John Schulman, Philipp Moritz, Sergey Levine, Michael I. Jordan, and Pieter Abbeel. High-dimensional continuous control using generalized advantage estimation. Co RR , abs/1506.02438, 2015.
- 6[6] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. Co RR , abs/1707.06347, 2017.
- 7[7] Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning , 8, 1992.
