Bayesian policy gradient and actor-critic algorithms

Mohammad Ghavamzadeh, Yaakov Engel, Michal Valko

Introduction

Policy gradient (PG) methodsThe term has been coined in Sutton00PG, but here we use it more liberally to refer to a whole class of reinforcement learning algorithms. are reinforcement learning (RL) algorithms that maintain a parameterized action-selection policy and update the policy parameters by moving them in the direction of an estimate of the gradient of a performance measure. Early examples of PG algorithms are the class of REINFORCE algorithms (Williams92SS),Note that policy gradient methods have been studied in the control community (see e.g., Dyer70CT, Jacobson70DD, Hasdorff76GO) before REINFORCE. However, unlike REINFORCE that is model-free, they were all based on the exact model of the system (model-based). which are suitable for solving problems in which the goal is to optimize the average reward. Subsequent work (e.g., Kimura95RL, Marbach98SM, Baxter01IP) extended these algorithms to the cases of infinite-horizon Markov decision processes (MDPs) and partially observable MDPs (POMDPs), while also providing much needed theoretical analysis.It is important to note that the pioneering work of Gullapali and colleagues in the early 1990s (Gullapalli90SR, Gullapalli92LC, Gullapalli94AR) in applying policy gradient methods to robot learning problems had an important role in popularizing this class of algorithms. In fact policy gradient methods have been continuously proven to be one of the most effective class of algorithms in learning in robots. However, both the theoretical results and empirical evaluations have highlighted a major shortcoming of these algorithms, namely, the high variance of the gradient estimates. This problem may be traced to the fact that in most interesting cases, the time-average of the observed rewards is a high-variance (although unbiased) estimator of the true average reward, resulting in the sample-inefficiency of these algorithms.

One solution proposed for this problem was to use an artificial discount factor in these algorithms (Marbach98SM, Baxter01IP), however, this creates another problem by introducing bias into the gradient estimates. Another solution, which does not involve biasing the gradient estimate, is to subtract a reinforcement baseline from the average reward estimate in the updates of PG algorithms (e.g., Williams92SS, Marbach98SM, Sutton00PG). In Williams92SS an average reward baseline was used, and in Sutton00PG it was conjectured that an approximate value function would be a good choice for a state-dependent baseline. However, it was shown in Weaver01OR and Greensmith04VR, perhaps surprisingly, that the mean reward is in general not the optimal constant baseline, and that the true value function is generally not the optimal state-dependent baseline.

A different approach for speeding-up PG algorithms was proposed by Kakade02NP and refined and extended by Bagnell03CP and Peters03RL. The idea is to replace the policy gradient estimate with an estimate of the so-called natural policy gradient. This is motivated by the requirement that the policy updates should be invariant to bijective transformations of the parametrization. Put more simply, a change in the way the policy is parametrized should not influence the result of the policy update. In terms of the policy update rule, the move to natural-gradient amounts to linearly transforming the gradient using the inverse Fisher information matrix of the policy. In empirical evaluations, natural PG has been shown to significantly outperform conventional PG (e.g., Kakade02NP, Bagnell03CP, Peters03RL, Peters08RL).

Another approach for reducing the variance of policy gradient estimates, and as a result making the search in the policy-space more efficient and reliable, is to use an explicit representation for the value function of the policy. This class of PG algorithms are called actor-critic algorithms. Actor-critic (AC) algorithms comprise a family of RL methods that maintain two distinct algorithmic components: An actor, whose role is to maintain and update an action-selection policy; and a critic, whose role is to estimate the value function associated with the actor’s policy. Thus, the critic addresses the problem of prediction, whereas the actor is concerned with control. Actor-critic methods were among the earliest to be investigated in RL (Barto83NE, Sutton84TC). They were largely supplanted in the 1990’s by methods, such as SARSA (Rummery94OQ), that estimate action-value functions and use them directly to select actions without maintaining an explicit representation of the policy. This approach was appealing because of its simplicity, but when combined with function approximation was found to be unreliable, often failing to converge. These problems led to renewed interest in PG methods.

Actor-critic algorithms (e.g., Sutton00PG, Konda00AA, Peters05NA, Bhatnagar07IN) borrow elements from these two families of RL algorithms. Like value-function based methods, a critic maintains a value function estimate, while an actor maintains a separately parameterized stochastic action-selection policy, as in policy based methods. While the role of the actor is to select actions, the role of the critic is to evaluate the performance of the actor. This evaluation is used to provide the actor with a feedback signal that allows it to improve its performance. The actor typically updates its policy along an estimate of the gradient (or natural gradient) of some measure of performance with respect to the policy parameters. When the representations used for the actor and the critic are compatible, in the sense explained in Sutton00PG and Konda00AA, the resulting AC algorithm is simple, elegant, and provably convergent (under appropriate conditions) to a local maximum of the performance measure used by the critic, plus a measure of the temporal difference (TD) error inherent in the function approximation scheme (Konda00AA, Bhatnagar09NA).

Existing AC algorithms are based on parametric critics that are updated to optimize frequentist fitness criteria. By “frequentist” we mean algorithms that return a point estimate of the value function, rather than a complete posterior distribution computed using Bayes’ rule. A Bayesian class of critics based on Gaussian processes (GPs) has been proposed by Engel03BM, Engel05RL, called Gaussian process temporal difference (GPTD). By their Bayesian nature, these algorithms return a full posterior distribution over value functions. Moreover, while these algorithms may be used to learn a parametric representation for the posterior, they are generally capable of searching for value functions in an infinite-dimensional Hilbert space of functions, resulting in a non-parametric posterior.

Both conventional and natural policy gradient and actor-critic methods rely on Monte-Carlo (MC) techniques in estimating the gradient of the performance measure. MC estimation is a frequentist procedure, and as such violates the likelihood principle (Berger84LP).The likelihood principle states that in a parametric statistical model, all the information about a data sample that is required for inferring the model parameters is contained in the likelihood function of that sample. Moreover, although MC estimates are unbiased, they tend to suffer from high variance, or alternatively, require excessive sample sizes (see Ohagan87MC for a discussion). In the case of policy gradient estimation this is exacerbated by the fact that consistent policy improvement requires multiple gradient estimation steps.

In Ohagan91BQ a Bayesian alternative to MC estimation is proposed.Ohagan91BQ mentions that this approach may be traced even as far back as Poincare1896CP. The idea is to model integrals of the form f(x)g(x)dx\int f(x)g(x)dx as GPs. This is done by treating the first term ff in the integrand as a random function, the randomness of which reflects our subjective uncertainty concerning its true identity. This allows us to incorporate our prior knowledge of ff into its prior distribution. Observing (possibly noisy) samples of ff at a set of points {x1,,xM}\{x_{1},\ldots,x_{M}\} allows us to employ Bayes’ rule to compute a posterior distribution of ff conditioned on these samples. This, in turn, induces a posterior distribution over the value of the integral.

In this paper, we first propose a Bayesian framework for policy gradient estimation by modeling the gradient as a GP. Our Bayesian policy gradient (BPG) algorithms use GPs to define a prior distribution over the gradient of the expected return, and compute its posterior conditioned on the observed data. This reduces the number of samples needed to obtain accurate gradient estimates. Moreover, estimates of the natural gradient as well as a measure of the uncertainty in the gradient estimates, namely the gradient covariance, are provided at little extra cost. Additional gains may be attained by learning a transition model of the environment, allowing knowledge transfer between policies. Since our BPG models and algorithms consider complete system trajectories as their basic observable unit, they do not require the dynamics within each trajectory to be of any special form. In particular, it is not necessary for the dynamics to have the Markov property, allowing the resulting algorithms to handle partially observable MDPs, Markov games, and other non-Markovian systems. On the downside, BPG algorithms cannot take advantage of the Markov property when this property is satisfied. To address this issue, we supplement our BPG framework with actor-critic methods and propose an AC algorithm that incorporates GPTD as its critic. However, rather than merely plugging-in our critic into an existing AC algorithm, we show how the posterior moments returned by the GPTD critic allow us to obtain closed-form expressions for the posterior moments of the policy gradient. This is made possible by utilizing the Fisher kernel (ShaweTaylor04KM) as our prior covariance kernel for the GPTD state-action advantage values. Unlike the BPG methods, the Bayesian actor-critic (BAC) algorithm takes advantage of the Markov property of the system trajectories and uses individual state-action-reward transitions as its basic observable unit. This helps reduce variance in the gradient estimates, resulting in steeper learning curves when compared to BPG and the classic MC approach.

It is important to note that a short version of the two main parts of this paper, Bayesian policy gradient and Bayesian actor-critic, appeared in Ghavamzadeh06BP and Ghavamzadeh07BA, respectively. This paper extends these conference papers in the following ways:

We have included a discussion on using Bayesian Quadrature (BQ) for estimating vector-valued integrals to the paper. This is totally relevant to this work because the gradient of a policy (the quantity that we are interested in estimating using BQ) is a vector-valued integral when the size of the policy parameter vector is more than 1, which is usually the case. This also helps to better see the difference between the two models we propose for BPG. In Model 1, we place a vector-valued Gaussian process (GP) over a component of the gradient integrant, while in Model 2, we put a scalar-valued GP over a different component of the gradient integrant.

We describe the BPG and BAC algorithms in more details and show the details of using online sparsification in these algorithms. Moreover, we show how BPG can be extended to partially observable Markov decision processes (POMDPs) along the same lines that the standard PG algorithms can be used in such problems.

In comparison to Ghavamzadeh06BP, we report more details of the experiments and more experimental results, especially in using the posterior variance (covariance) of the gradient to select the step size for updating the policy parameters.

We include all the proofs in this paper (almost none was reported in the two conference papers), in particular, the proofs of Propositions 3, 4, 5, and 6. These proofs are important and the proof techniques are novel and definitely useful for the community. The importance of these proofs come from the fact that they show how with the right choice of GP prior (the one that uses the family of Fisher information kernels), we are able to use BQ and have a Bayesian estimate of the gradient integral, while initially everything indicates that BQ cannot be used for the estimation of this integral.

We apply the BAC algorithm to two new domains: “Mountain Car”, a 2-dimensional continuous state and 1-dimensional discrete action problem, and “Ship Steering”, a 4-dimensional continuous state and 1-dimensional continuous action problem.

Reinforcement Learning, Policy Gradient, and Actor-Critic Methods

Reinforcement learning (RL) (Bertsekas96NP, Sutton98IR) is term describing a class of learning problems in which an agent (or controller) interacts with a dynamic, stochastic, and incompletely known environment (or plant), with the goal of finding an action-selection strategy, or policy, to optimize some measure of its long-term performance. This interaction is conventionally modeled as a Markov decision process (MDP) (Puterman94MD), or if the environmental state is not completely observable, as a partially observable MDP (POMDP) (Astrom65OC, Smallwood73OC, Kaelbling98PA). In this work we restrict our attention to the discrete-time MDP setting.

In addition, we need to specify the rule according to which the agent selects an action at each possible state. We assume that this rule is stationary, i.e., does not depend explicitly on time. A stationary policy μ(x)P(A)\mu(\cdot|x)\in{\mathcal{P}}({\mathcal{A}}) is a probability distribution over actions, conditioned on the current state. A MDP controlled by a policy μ\mu induces a Markov chain over state-action pairs zt=(xt,at)Z=X×A{\boldsymbol{z}}_{t}=(x_{t},a_{t})\in{\mathcal{Z}}={\mathcal{X}}\times{\mathcal{A}}, with a transition probability density Pμ(ztzt1)=P(xtxt1,at1)μ(atxt)P^{\mu}({\boldsymbol{z}}_{t}|{\boldsymbol{z}}_{t-1})=P(x_{t}|x_{t-1},a_{t-1})\mu(a_{t}|x_{t}), and an initial state density P0μ(z0)=P0(x0)μ(a0x0)P_{0}^{\mu}({\boldsymbol{z}}_{0})=P_{0}(x_{0})\mu(a_{0}|x_{0}). We generically denote by ξ=(z0,z1,,zT)Ξ,  T{0,1,,}\xi=({\boldsymbol{z}}_{0},{\boldsymbol{z}}_{1},\ldots,{\boldsymbol{z}}_{T})\in\Xi,\;T\in\{0,1,\ldots,\infty\} a path generated by this Markov chain. Note that Ξ\Xi is the set of all possible trajectories that can be generated by the Markov chain induced by the current policy μ\mu. The probability (density) of such a path is given by

We denote by R(ξ)=t=0T1γtr(xt,at)R(\xi)=\sum_{t=0}^{T-1}\gamma^{t}r(x_{t},a_{t}) the (possibly discounted, γ\gamma\in) cumulative return of the path ξ\xi. R(ξ)R(\xi) is a random variable both because the path ξ\xi itself is a random variable, and because, even for a given path, each of the rewards sampled in it may be stochastic. The expected value of R(ξ)R(\xi) for a given path ξ\xi is denoted by Rˉ(ξ)\bar{R}(\xi). Finally, we define the expected return of policy μ\mu as

The tt-step state-action occupancy density of policy μ\mu is given by

It can be shown that under certain regularity conditions (Sutton00PG), the expected return of policy μ\mu may be written in terms of state-action pairs (rather than in terms of trajectories as in Equation 2) as

where πμ(z)=t=0γtPtμ(z)\pi^{\mu}({\boldsymbol{z}})=\sum_{t=0}^{\infty}\gamma^{t}{P_{t}^{\mu}}({\boldsymbol{z}}) is a discounted weighting of state-action pairs encountered while following policy μ\mu. Integrating aa out of πμ(z)=πμ(x,a)\pi^{\mu}({\boldsymbol{z}})=\pi^{\mu}(x,a) results in the corresponding discounted weighting of states encountered by following policy μ\mu: νμ(x)=Adaπμ(x,a)\nu^{\mu}(x)=\int_{{\mathcal{A}}}da\pi^{\mu}(x,a). Unlike νμ\nu^{\mu} and πμ\pi^{\mu}, (1γ)νμ(1-\gamma)\nu^{\mu} and (1γ)πμ(1-\gamma)\pi^{\mu} are distributions. They are analogous to the stationary distributions over states and state-action pairs of policy μ\mu in the undiscounted setting, respectively, since as γ1\gamma\rightarrow 1, they tend to these distributions, if they exist.

Our aim is to find a policy μ\mu^{*} that maximizes the expected return, i.e., μ=argmaxμη(μ)\mu^{*}=\mathop{\rm arg\,max}_{\mu}\eta(\mu). A policy μ\mu is assessed according to the expected cumulative rewards associated with states xx or state-action pairs z{\boldsymbol{z}}. For all states xXx\in{\mathcal{X}} and actions aAa\in{\mathcal{A}}, the action-value function and the value function of policy μ\mu are defined as

In policy gradient (PG) methods, we define a class of smoothly parameterized stochastic policies {μ(x;θ),xX,θΘ}\big\{\mu(\cdot|x;{\boldsymbol{\theta}}),x\in{\mathcal{X}},{\boldsymbol{\theta}}\in\Theta\big\}. We estimate the gradient of the expected return, defined by Equation 2 (or Equation 3), with respect to the policy parameters θ{\boldsymbol{\theta}}, from the observed system trajectories. We then improve the policy by adjusting the parameters in the direction of the gradient (e.g., Williams92SS, Marbach98SM, Baxter01IP). Since in this setting a policy μ\mu is represented by its parameters θ{\boldsymbol{\theta}}, policy dependent functions such as η(μ)\eta(\mu), Pr(ξ;μ)\Pr\big(\xi;\mu), πμ(z)\pi^{\mu}({\boldsymbol{z}}), νμ(x)\nu^{\mu}(x), Vμ(x)V^{\mu}(x), and Qμ(z)Q^{\mu}({\boldsymbol{z}}) may be written as η(θ)\eta({\boldsymbol{\theta}}), Pr(ξ;θ)\Pr(\xi;{\boldsymbol{\theta}}), π(z;θ)\pi({\boldsymbol{z}};{\boldsymbol{\theta}}), ν(x;θ)\nu(x;{\boldsymbol{\theta}}), V(x;θ)V(x;{\boldsymbol{\theta}}), and Q(z;θ)Q({\boldsymbol{z}};{\boldsymbol{\theta}}), respectively. We assume

For any state-action pair (x,a)(x,a) and any policy parameter θΘ{\boldsymbol{\theta}}\in\Theta, the policy μ(ax;θ)\mu(a|x;{\boldsymbol{\theta}}) is continuously differentiable in the parameters θ{\boldsymbol{\theta}}.

The score function or likelihood ratio method has become the most prominent technique for gradient estimation from simulation. It has been first proposed in the 1960’s (Aleksandrov68SO, Rubinstein69SP) for computing performance gradients in i.i.d. (independently and identically distributed) processes, and was then extended to regenerative processes including MDPs by Glynn86SA, Glynn90LR, Reiman86SA, Reiman89SA, Glynn95LR, and to episodic MDPs by Williams92SS. This method estimates the gradient of the expected return with respect to the policy parameters θ{\boldsymbol{\theta}}, defined by Equation 2, using the following equation:Throughout the paper, we use the notation \nabla to denote θ\nabla_{{\boldsymbol{\theta}}} – the gradient w.r.t. the policy parameters.

In Equation 4, the quantity Pr(ξ;θ)Pr(ξ;θ)=logPr(ξ;θ)\frac{\nabla\Pr(\xi;{\boldsymbol{\theta}})}{\Pr(\xi;{\boldsymbol{\theta}})}=\nabla\mathop{\rm log}\Pr(\xi;{\boldsymbol{\theta}}) is called the (Fisher) score function or likelihood ratio. Since the initial-state distribution P0P_{0} and the state-transition distribution PP are independent of the policy parameters θ{\boldsymbol{\theta}}, we may write the score function for a path ξ\xi using Equation 1 asTo simplify notation, we omit u{\boldsymbol{u}}’s dependence on the policy parameters θ{\boldsymbol{\theta}}, and denote u(ξ;θ){\boldsymbol{u}}(\xi;{\boldsymbol{\theta}}) as u(ξ){\boldsymbol{u}}(\xi) in the sequel.

Previous work on policy gradient used classical MC to estimate the gradient in Equation 4. These methods generate i.i.d. sample paths ξ1,,ξM\xi_{1},\ldots,\xi_{M} according to Pr(ξ;θ)\Pr(\xi;{\boldsymbol{\theta}}), and estimate the gradient η(θ)\nabla\eta({\boldsymbol{\theta}}) using the MC estimator

This is an unbiased estimate, and therefore, by the law of large numbers, η^(θ)η(θ)\widehat{\nabla\eta}({\boldsymbol{\theta}})\rightarrow\nabla\eta({\boldsymbol{\theta}}) as MM goes to infinity, with probability one.

The policy gradient theorem (Marbach98SM, Proposition 1; Sutton00PG, Theorem 1; Konda00AA, Theorem 1) states that the gradient of the expected return, defined by Equation 3, for parameterized policies satisfying Assumption 1 is given by

and thus, for any baseline b(x)b(x), the gradient of the expected return can be written as

The baseline may be chosen in such a way so as to minimize the variance of the gradient estimates (Greensmith04VR).

Now consider the actor-critic (AC) framework in which the action-value function for a fixed policy μ\mu, QμQ^{\mu}, is approximated by a learned function approximator. If the approximation is sufficiently good, we may hope to use it in place of QμQ^{\mu} in Equations 7 and 8, and still point roughly in the direction of the true gradient. Sutton00PG and Konda00AA showed that if the approximation Q^μ(;w)\hat{Q}^{\mu}(\cdot;{\boldsymbol{w}}) with parameter w{\boldsymbol{w}} is compatible, i.e., wQ^μ(x,a;w)=logμ(ax;θ)\nabla_{\boldsymbol{w}}\hat{Q}^{\mu}(x,a;{\boldsymbol{w}})=\nabla\mathop{\rm log}\mu(a|x;{\boldsymbol{\theta}}), and if it minimizes the mean squared error

An approximation for the action-value function, in terms of a linear combination of basis functions, may be written as Q^μ(z;w)=wψ(z)\hat{Q}^{\mu}({\boldsymbol{z}};{\boldsymbol{w}})={\boldsymbol{w}}^{\top}{\boldsymbol{\psi}}({\boldsymbol{z}}). This approximation is compatible if the ψ{\boldsymbol{\psi}}’s are compatible with the policy, i.e., ψ(z;θ)=logμ(ax;θ){\boldsymbol{\psi}}({\boldsymbol{z}};{\boldsymbol{\theta}})=\nabla\mathop{\rm log}\mu(a|x;{\boldsymbol{\theta}}). Note that compatibility is well defined under Assumption 1. Let Eμ(w){\mathcal{E}}^{\mu}({\boldsymbol{w}}) denote the mean squared error

of our compatible linear approximation wψ(z){\boldsymbol{w}}^{\top}{\boldsymbol{\psi}}({\boldsymbol{z}}) and an arbitrary baseline b(x)b(x). Let w=argminwEμ(w){\boldsymbol{w}}^{*}=\mathop{\rm arg\,min}_{\boldsymbol{w}}{\mathcal{E}}^{\mu}({\boldsymbol{w}}) denote the optimal parameter. It can be shown that the value of w{\boldsymbol{w}}^{*} does not depend on the baseline b(x)b(x). As a result, the mean squared-error problems of Equations 9 and 10 have the same solutions (see e.g., Bhatnagar07IN, Bhatnagar09NA). It can also be shown that if the parameter w{\boldsymbol{w}} is set to be equal to w{\boldsymbol{w}}^{*}, then the resulting mean squared error Eμ(w){\mathcal{E}}^{\mu}({\boldsymbol{w}}^{*}), now treated as a function of the baseline b(x)b(x), is further minimized by setting b(x)=Vμ(x)b(x)=V^{\mu}(x) (Bhatnagar07IN, Bhatnagar09NA). In other words, the variance in the action-value function estimator is minimized if the baseline is chosen to be the value function itself.

A convenient and rather flexible choice for a space of policies that ensures compatibility between the policy and the action-value representation is a parametric exponential family

where Zθ(x)=Adaexp(θϕ(x,a))Z_{\boldsymbol{\theta}}(x)=\int_{\mathcal{A}}da\exp\big({\boldsymbol{\theta}}^{\top}{\boldsymbol{\phi}}(x,a)\big) is a normalizing factor, referred to as the partition function. It is easy to show that ψ(z)=ϕ(z)Eax[ϕ(z)]{\boldsymbol{\psi}}({\boldsymbol{z}})={\boldsymbol{\phi}}({\boldsymbol{z}})-{\bf E}_{a|x}\left[{\boldsymbol{\phi}}({\boldsymbol{z}})\right], where Eax[]=Adaμ(ax;θ)[]{\bf E}_{a|x}[\cdot]=\int_{\mathcal{A}}da\mu(a|x;{\boldsymbol{\theta}})[\cdot], and as a result, Q^μ(z;w)=w(ϕ(z)Eax[ϕ(z)])+b(x)\hat{Q}^{\mu}({\boldsymbol{z}};{\boldsymbol{w}}^{*})={\boldsymbol{w}}^{*\top}\big({\boldsymbol{\phi}}({\boldsymbol{z}})-{\bf E}_{a|x}[{\boldsymbol{\phi}}({\boldsymbol{z}})]\big)+b(x) is a compatible action-value function for this family of policies. Note that Eax[Q^(z;w)]=b(x){\bf E}_{a|x}[\hat{Q}({\boldsymbol{z}};{\boldsymbol{w}}^{*})]=b(x), since Eax[ϕ(z)Eax[ϕ(z)]]=0{\bf E}_{a|x}\big[{\boldsymbol{\phi}}({\boldsymbol{z}})-{\bf E}_{a|x}[{\boldsymbol{\phi}}({\boldsymbol{z}})]\big]=0. This means that if Q^μ(z;w)\hat{Q}^{\mu}({\boldsymbol{z}};{\boldsymbol{w}}^{*}) approximates Qμ(z)Q^{\mu}({\boldsymbol{z}}), then b(x)b(x) must approximate the value function Vμ(x)V^{\mu}(x). The term A^μ(z;w)=Q^μ(z;w)b(x)=w(ϕ(z)Eax[ϕ(z)])\hat{A}^{\mu}({\boldsymbol{z}};{\boldsymbol{w}}^{*})=\hat{Q}^{\mu}({\boldsymbol{z}};{\boldsymbol{w}}^{*})-b(x)={\boldsymbol{w}}^{*\top}\big({\boldsymbol{\phi}}({\boldsymbol{z}})-{\bf E}_{a|x}[{\boldsymbol{\phi}}({\boldsymbol{z}})]\big) approximates the advantage function Aμ(z)=Qμ(z)Vμ(x)A^{\mu}({\boldsymbol{z}})=Q^{\mu}({\boldsymbol{z}})-V^{\mu}(x) (Baird93AU).

Bayesian Quadrature

Bayesian quadrature (BQ) (Ohagan91BQ) is, as its name suggests, a Bayesian method for evaluating an integral using samples of its integrand. We consider the problem of evaluating the integral

If g(x)g(x) is a probability density function, i.e., g(x)=p(x)g(x)=p(x), this becomes the problem of evaluating the expected value of f(x)f(x). A well known frequentist approach to evaluating such expectations is the Monte-Carlo (MC) method. For MC estimation of such expectations, it is typically required that samples x1,x2,,xMx_{1},x_{2},\ldots,x_{M} are drawn from p(x)p(x).If samples are drawn from some other distribution, importance sampling variants of MC may be used. The integral in Equation 11 is then estimated as

It is easy to show that ρ^MC\hat{\rho}_{MC} is an unbiased estimate of ρ\rho, with variance that diminishes to zero as MM\rightarrow\infty. However, as Ohagan87MC points out, MC estimation is fundamentally unsound, as it violates the likelihood principle, and moreover, does not make full use of the data at hand. The alternative proposed in Ohagan91BQ is based on the following reasoning: In the Bayesian approach, f()f(\cdot) is random simply because it is unknown. We are therefore uncertain about the value of f(x)f(x) until we actually evaluate it. In fact, even then, our uncertainty is not always completely removed, since measured samples of f(x)f(x) may be corrupted by noise. Modeling ff as a Gaussian process (GP) means that our uncertainty is completely accounted for by specifying a Normal prior distribution over functions. This prior distribution is specified by its mean and covariance, and is denoted by f()N(fˉ(),k(,))f(\cdot)\sim{\mathcal{N}}\big(\bar{f}(\cdot),k(\cdot,\cdot)\big). This is shorthand for the statement that ff is a GP with prior mean and covariance

respectively. The choice of kernel function kk allows us to incorporate prior knowledge on the smoothness properties of the integrand into the estimation procedure. When we are provided with a set of samples DM={(xi,y(xi))}i=1M{\mathcal{D}}_{M}=\big\{\big(x_{i},y(x_{i})\big)\big\}_{i=1}^{M}, where y(xi)y(x_{i}) is a (possibly noisy) sample of f(xi)f(x_{i}), we apply Bayes’ rule to condition the prior on these sampled values. If the measurement noise is normally distributed, the result is a Normal posterior distribution of fDMf|{\mathcal{D}}_{M}. The expressions for the posterior mean and covariance are standard:

Here and in the sequel, we make use of the definitions:

where K{\boldsymbol{K}} is the kernel (or Gram) matrix, and [Σ]i,j[{\boldsymbol{\Sigma}}]_{i,j} is the measurement noise covariance between the iith and jjth samples. It is typically assumed that the measurement noise is i.i.d., in which case Σ=σ2I{\boldsymbol{\Sigma}}=\sigma^{2}{\boldsymbol{I}}, where σ2\sigma^{2} is the noise variance and I{\boldsymbol{I}} is the (appropriately sized - here M×MM\times M) identity matrix.

Since integration is a linear operation, the posterior distribution of the integral in Equation 11 is also Gaussian, and the posterior moments are given by (Ohagan91BQ)

Substituting Equation 3 into Equation 3, we obtain

Note that ρ0\rho_{0} and b0b_{0} are the prior mean and variance of ρ\rho, respectively.

Rasmussen03BM experimentally demonstrated how this approach, when applied to the evaluation of an expectation, can outperform MC estimation by orders of magnitude in terms of the mean-squared error.

In order to prevent the problem from “degenerating into infinite regress”, as phrased by Ohagan91BQ,What O’Hagan means by “degenerating into infinite regress” is simply that if we cannot compute the posterior integrals of Equation 16 analytically, then we have started with estimating one integral (Equation 11) and ended up with three (Equation 16), and if we repeat this process, this can go forever and leave us with infinite integrals to evaluate. Therefore, for Bayesian MC to work, it is crucial to be able to analytically calculate the posterior integrals, and this can be achieved through the way we divide the integrant into two parts and the way we select the kernel function. we should choose the functions gg, kk, and fˉ\bar{f} so as to allow us to solve the integrals in Equation 16 analytically. For example, O’Hagan provides the analysis required for the case where the integrands in Equation 16 are products of multivariate Gaussians and polynomials, referred to as Bayes-Hermite quadrature. One of the contributions of our work is in providing analogous analysis for kernel functions that are based on the Fisher kernel (Jaakkola98EG, ShaweTaylor04KM).

It is important to note that in MC estimation, samples must be drawn from the distribution p(x)=g(x)p(x)=g(x), whereas in the Bayesian approach, samples may be drawn from arbitrary distributions. This affords us with flexibility in the choice of sample points, allowing us, for instance, to actively design the samples x1,,xMx_{1},\ldots,x_{M} so as to maximize information gain.

In the second model, a scalar-valued function is sampled from the GP prior distribution, which is specified by a single prior mean function and a single prior covariance-kernel function. Gaussian noise may be added, and the result is then multiplied by each of the components of the nn-valued function gg to produce the integrand. This model is significantly simpler, both conceptually and in terms of the number of parameters required to specify it. To see how a model of the first kind may arise, consider the following example.

Let ρ(θ)=f(x;θ)g(x)dx\rho({\boldsymbol{\theta}})=\int f(x;{\boldsymbol{\theta}})g(x)dx, where ff is a scalar GP, parameterized by a vector of parameters θ{\boldsymbol{\theta}}. Its prior mean and covariance functions must therefore depend on θ{\boldsymbol{\theta}}. We denote these dependencies by writing:

We choose fˉ(x;θ)\bar{f}(x;{\boldsymbol{\theta}}) and k(x,x;θ)k(x,x^{\prime};{\boldsymbol{\theta}}) so as to be once and twice differentiable in θ{\boldsymbol{\theta}}, respectively. Suppose now that we are not interested in estimating ρ(θ)\rho({\boldsymbol{\theta}}), but rather in its gradient with respect to the parameters θ{\boldsymbol{\theta}}: θρ(θ)=θf(x;θ)g(x)dx\nabla_{\boldsymbol{\theta}}\rho({\boldsymbol{\theta}})=\int\nabla_{\boldsymbol{\theta}}f(x;{\boldsymbol{\theta}})g(x)dx. It may be easily verified that the mean functions and covariance kernels of the vector-valued GP θf(x;θ)\nabla_{\boldsymbol{\theta}}f(x;{\boldsymbol{\theta}}) are given by

where θj\partial_{\theta_{j}} denotes the jjth component of θ\nabla_{\boldsymbol{\theta}}. \Box

Propositions 1 and 2 specify the form taken by the mean and covariance functions of the integral GP under the two models discussed above.

Let ff be a scalar-valued GP with mean function fˉ(x)=E[f(x)]\bar{f}(x)={\bf E}\big[f(x)\big] and covariance function k(x,x)=Cov[f(x),f(x)]k(x,x^{\prime})={\bf Cov}\big[f(x),f(x^{\prime})\big], and let gg be an nn-valued function. Then, the mean and covariance of ρ\rho defined by Equation 11 are of the following form:

The proofs of these two propositions follow straightforwardly from the definition of the covariance operator in terms of expectations, and the order-exchangeability of GP expectations and integration with respect to xx.

To wrap things up, we need to describe the form taken by the posterior moments of ff in the vector-valued GP case. Using the standard Gaussian conditioning formulas, it is straightforward to show that

where C=(K+Σ)1{\boldsymbol{C}}=({\boldsymbol{K}}+{\boldsymbol{\Sigma}})^{-1}. It should, however, be kept in mind that ignoring correlations between the components of ff, when such correlations exist, may result in suboptimal use of the available data (see Rasmussen06GP, Chapter 9 for references on GP regression with multiple outputs).

Bayesian Policy Gradient

In this section, we use vector-valued Bayesian quadrature to estimate the gradient of the expected return with respect to the policy parameters, allowing us to propose new Bayesian policy gradient (BPG) algorithms. In the frequentist approach to policy gradient, the performance measure used is η(θ)=Rˉ(ξ)Pr(ξ;θ)dξ\eta({\boldsymbol{\theta}})=\int\bar{R}(\xi)\Pr(\xi;{\boldsymbol{\theta}})d\xi (Equation 2). In order to serve as a useful performance measure, it has to be a deterministic function of the policy parameters θ{\boldsymbol{\theta}}. This is achieved by averaging the cumulative return R(ξ)R(\xi) over all possible paths ξ\xi and all possible returns accumulated in each path. In the Bayesian approach we have an additional source of randomness, namely, our subjective Bayesian uncertainty concerning the process generating the cumulative return. Let us denote

where ηB(θ)\eta_{B}({\boldsymbol{\theta}}) is a random variable because of the Bayesian uncertainty. Under the quadratic loss, the optimal Bayesian performance measure is the posterior expected value of ηB(θ)\eta_{B}({\boldsymbol{\theta}}), E[ηB(θ)DM]{\bf E}\big[\eta_{B}({\boldsymbol{\theta}})|{\mathcal{D}}_{M}\big]. However, since we are interested in optimizing the performance rather than evaluating it,Although evaluating the posterior distribution of performance is an interesting question in its own right. we would rather evaluate the posterior distribution of the gradient of ηB(θ)\eta_{B}({\boldsymbol{\theta}}) with respect to the policy parameters θ{\boldsymbol{\theta}}. The posterior mean of the gradient is We may interchange the order of the gradient and the expectation operators for the mean, E[ηB(θ)]=E[ηB(θ)]\nabla{\bf E}\big[\eta_{B}({\boldsymbol{\theta}})\big]={\bf E}\big[\nabla\eta_{B}({\boldsymbol{\theta}})\big], but the same is not true for the variance, namely, Var[ηB(θ)]Cov[ηB(θ)]\nabla{\bf Var}\big[\eta_{B}({\boldsymbol{\theta}})\big]\neq{\bf Cov}\big[\nabla\eta_{B}({\boldsymbol{\theta}})\big].

Consequently, in BPG we cast the problem of estimating the gradient of the expected return (Equation 20) in the form of Equation 11. As described in Section 3, we need to partition the integrand into two parts, f(ξ;θ)f(\xi;{\boldsymbol{\theta}}) and g(ξ;θ)g(\xi;{\boldsymbol{\theta}}). We will model ff as a GP and assume that gg is a function known to us. We will then proceed by calculating the posterior moments of the gradient ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}) conditioned on the observed data. Because in general, R(ξ)R(\xi) cannot be known exactly, even for a given ξ\xi (due to the stochasticity of the rewards), R(ξ)R(\xi) should always belong to the GP part of the model, i.e., f(ξ;θ)f(\xi;{\boldsymbol{\theta}}). Interestingly, in certain cases it is sufficient to know the Fisher information matrix corresponding to Pr(ξ;θ)\Pr(\xi;{\boldsymbol{\theta}}), rather than having exact knowledge of Pr(ξ;θ)\Pr(\xi;{\boldsymbol{\theta}}) itself. We make use of this fact in the sequel. In the next two sections, we investigate two different ways of partitioning the integrand in Equation 20, resulting in two distinct Bayesian policy gradient models.

In our first model, we define gg and ff as follows:

We place a vector-valued GP prior over f(ξ;θ)f(\xi;{\boldsymbol{\theta}}) which induces a GP prior over the corresponding noisy measurement y(ξ;θ)=R(ξ)logPr(ξ;θ)y(\xi;{\boldsymbol{\theta}})=R(\xi)\nabla\mathop{\rm log}\Pr(\xi;{\boldsymbol{\theta}}). We adopt the simplifying assumptions discussed at the end of Section 3.1: We assume that each component of f(ξ;θ)f(\xi;{\boldsymbol{\theta}}) may be evaluated independently of all other components, and use the same kernel function and noise covariance for all components of f(ξ;θ)f(\xi;{\boldsymbol{\theta}}). We therefore omit the component index jj from Kj,j{\boldsymbol{K}}_{j,j}, Σj,j{\boldsymbol{\Sigma}}_{j,j} and Cj,j{\boldsymbol{C}}_{j,j}, denoting them simply as K{\boldsymbol{K}}, Σ{\boldsymbol{\Sigma}} and C{\boldsymbol{C}}, respectively. Hence, for the jjth component of ff and yy we have, a priori

In this vector-valued GP model, the posterior mean and covariance of ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}) are

Our choice of kernel, which allows us to derive closed-form expressions for b{\boldsymbol{b}} and b0b_{0}, and as a result for the posterior moments of the gradient, is the quadratic Fisher kernel (Jaakkola98EG, ShaweTaylor04KM)

where u(ξ)=logPr(ξ;θ){\boldsymbol{u}}(\xi)=\nabla\mathop{\rm log}\Pr(\xi;{\boldsymbol{\theta}}) is the Fisher score function of the path ξ\xi defined by Equation 5, and G(θ){\boldsymbol{G}}({\boldsymbol{\theta}}) is the corresponding Fisher information matrix defined asTo simplify notation, we omit G{\boldsymbol{G}}’s dependence on the policy parameters θ{\boldsymbol{\theta}}, and denote G(θ){\boldsymbol{G}}({\boldsymbol{\theta}}) as G{\boldsymbol{G}} in the sequel.

Using the quadratic Fisher kernel from Equation 23, the integrals b{\boldsymbol{b}} and b0b_{0} in Equation 22 have the following closed form expressions

2 Model 2 – Scalar-Valued GP

In our second model, we define gg and ff as follows:

Now gg is a vector-valued function, while ff is a scalar valued GP representing the expected return of the path given as its argument. The noisy measurement corresponding to f(ξi)f(\xi_{i}) is y(ξi)=R(ξi)y(\xi_{i})=R(\xi_{i}), namely, the actual return accrued while following the path ξi\xi_{i}. In this model, the posterior mean and covariance of the gradient ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}) are

Here, our choice of kernel function, which again allows us to derive closed-form expressions for B{\boldsymbol{B}} and B0{\boldsymbol{B}}_{0}, is the Fisher kernel (Jaakkola98EG, ShaweTaylor04KM)

Using the Fisher kernel from Equation 27, the integrals B{\boldsymbol{B}} and B0{\boldsymbol{B}}_{0} in Equation 4.2 have the following closed-form expressions

where U=[u(ξ1),,u(ξM)]{\boldsymbol{U}}=\big[{\boldsymbol{u}}(\xi_{1}),\ldots,{\boldsymbol{u}}(\xi_{M})\big].

Table 1 summarizes the two BPG models presented in Sections 4.1 and 4.2. Our choice of Fisher-type kernels was motivated by the notion that a good representation should depend on the process generating the data (see Jaakkola98EG, ShaweTaylor04KM, for a thorough discussion). Our particular selection of linear and quadratic Fisher kernels were guided by the desideratum that the posterior moments of the gradient be analytically tractable as discussed in Section 3.

As described above, in either model, we are restricted in the choice of kernel (quadratic Fisher kernel in Model 1 and Fisher kernel in Model 2) in order to be able to derive closed-form expressions for the posterior mean and covariance of the gradient integral. The loss due to this restriction depends on the problem at hand and is hard to quantify. This loss is exactly the loss of selecting an inappropriate prior in any Bayesian algorithm or, more generally, of choosing a wrong representation (function space) in a machine learning algorithm (referred to as approximation error in approximation theory). However, the experimental results of Section 6 indicate that this restriction did not cause a significant error (especially for Model 1) in our gradient estimates, as those estimated by BPG were more accurate than the ones estimated by the MC-based method, given the same number of samples.

3 A Bayesian Policy Gradient Evaluation Algorithm

We can now use our two BPG models to define corresponding algorithms for evaluating the gradient of the expected return with respect to the policy parameters. Pseudo-code for these algorithms is shown in Algorithm 1. The generic algorithm (for either model) takes a set of policy parameters θ{\boldsymbol{\theta}} and a sample size MM as input, and returns an estimate of the posterior moments of the gradient of the expected return with respect to the policy parameters. This algorithm generates MM sample paths to evaluate the gradient. For each path ξi\xi_{i}, the algorithm first computes its score function u(ξi){\boldsymbol{u}}(\xi_{i}) (Line 6). The score function is needed for computing the kernel function kk, the measurement y{\boldsymbol{y}} in Model 1, and b{\boldsymbol{b}} or B{\boldsymbol{B}}. The algorithm then computes the return RR and the measurement y(ξi)y(\xi_{i}) for the observed path ξi\xi_{i} (Lines 7 and 9), and updates the kernel matrix K{\boldsymbol{K}} (Line 8) using

Finally, the algorithm adds the measurement error Σ{\boldsymbol{\Sigma}} to the covariance matrix K{\boldsymbol{K}} (Line 12) and computes the posterior moments of the policy gradient (Line 14). B(:,i){\boldsymbol{B}}(:,i) on Line 10 denotes the iith column of the matrix B{\boldsymbol{B}}.

The kernel functions used in Models 1 and 2 (Equations 23 and 27) are both based on the Fisher kernel. Computing the Fisher kernel requires calculating the Fisher information matrix G(θ){\boldsymbol{G}}({\boldsymbol{\theta}}) (Equation 24). Consequently, every time we update the policy parameters, we need to recompute G{\boldsymbol{G}}. In Algorithm 1 we assume that the Fisher information matrix is known. However, in most practical situations this will not be the case, and consequently the Fisher information matrix must be estimated. Let us briefly outline two possible approaches for estimating the Fisher information matrix in an online manner.

The BPG algorithm generates a number of sample paths using the current policy parameterized by θ{\boldsymbol{\theta}} in order to estimate the gradient ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}). We can use these generated sample paths to estimate the Fisher information matrix G(θ){\boldsymbol{G}}({\boldsymbol{\theta}}) in an online manner, by replacing the expectation in G{\boldsymbol{G}} with empirical averaging as G^M(θ)=1Mi=1Mu(ξi)u(ξi)\hat{{\boldsymbol{G}}}_{M}({\boldsymbol{\theta}})=\frac{1}{M}\sum_{i=1}^{M}{\boldsymbol{u}}(\xi_{i}){\boldsymbol{u}}(\xi_{i})^{\top}. It can be shown that G^M\hat{{\boldsymbol{G}}}_{M} is an unbiased estimator of G{\boldsymbol{G}}. One may obtain this estimate recursively G^i+1=(11i)G^i+1iu(ξi)u(ξi)\hat{{\boldsymbol{G}}}_{i+1}=(1-\frac{1}{i})\hat{{\boldsymbol{G}}}_{i}+\frac{1}{i}{\boldsymbol{u}}(\xi_{i}){\boldsymbol{u}}(\xi_{i})^{\top}, or more generally G^i+1=(1ζi)G^i+ζiu(ξi)u(ξi)\hat{{\boldsymbol{G}}}_{i+1}=(1-\zeta_{i})\hat{{\boldsymbol{G}}}_{i}+\zeta_{i}{\boldsymbol{u}}(\xi_{i}){\boldsymbol{u}}(\xi_{i})^{\top}, where ζi\zeta_{i} is a step-size with iζi=\sum_{i}\zeta_{i}=\infty and iζi2<\sum_{i}\zeta_{i}^{2}<\infty. Using the Sherman-Morrison matrix inversion lemma, it is possible to directly estimate the inverse of the Fisher information matrix as

The Fisher information matrix defined by Equation 24 depends on the probability distribution over paths. This distribution is a product of two factors, one corresponding to the current policy and the other corresponding to the MDP’s state-transition probability PP (see Equation 1). Thus if PP is known, the Fisher information matrix may be evaluated offline. We can model PP using a parameterized model and then estimate the maximum likelihood (ML) model parameters. This approach may lead to a model-based treatment of policy gradients, which could allow us to transfer information between different policies. Current policy gradient algorithms, including the algorithms described in this paper, are extremely wasteful of training data, since they do not have any disciplined way to use data collected for previous policy updates in computing the update of the current policy. Model-based policy gradient may help solve this problem.

4 BPG Online Sparsification

5 A Bayesian Policy Gradient Algorithm

So far we were concerned with estimating the gradient of the expected return with respect to the policy parameters. In this section, we present a Bayesian policy gradient (BPG) algorithm that employs the Bayesian gradient estimation methods proposed in Section 4.3 to update the policy parameters. The pseudo-code of this algorithm is shown in Algorithm 2. The algorithm starts with an initial vector of policy parameters θ0{\boldsymbol{\theta}}_{0}, and updates the parameters in the direction of the posterior mean of the gradient of the expected return estimated by Algorithm 1. This is repeated NN times, or alternatively, until the gradient estimate is sufficiently close to zero.

Extension to Partially Observable Markov Decision Processes

The Bayesian policy gradient models and algorithms of Section 4 can be extended to partially observable Markov decision processes (POMDPs) along the same lines as in Section 6 of Baxter01IP. In the partially observable case, the stochastic parameterized policy μ(;θ)\mu(\cdot|\cdot;{\boldsymbol{\theta}}) controls a POMDP, i.e., the policy has access to an observation process that depends on the state, but it may not observe the state itself directly.

Specifically, for each state xXx\in{\mathcal{X}}, an observation oOo\in{\mathcal{O}} is generated independently according to a probability distribution PoP_{o} over observations in O{\mathcal{O}}. We denote the probability of observation oo at state xx by Po(ox)P_{o}(o|x). A stationary stochastic parameterized policy μ(;θ)\mu(\cdot|\cdot;{\boldsymbol{\theta}}) is a function mapping observations oOo\in{\mathcal{O}} into probability distributions over the actions μ(o;θ)P(A)\mu(\cdot|o;{\boldsymbol{\theta}})\in{\mathcal{P}}({\mathcal{A}}). In this case, the probability of a path ξ=(x0,a0,x1,a1,,xT1,aT1,xT)\xi=(x_{0},a_{0},x_{1},a_{1},\ldots,x_{T-1},a_{T-1},x_{T}), T{0,1,,}T\in\{0,1,\ldots,\infty\} generated by the Markov chain induced by policy μ(;θ)\mu(\cdot|\cdot;{\boldsymbol{\theta}}) is given by

The Fisher score of this path may be written as

which is the same as in the observable case (Equation 5), except here the policy is defined over observations instead of states. As a result, the models and algorithms of Section 4 may be used in the partially observable case with no change, substituting observations for states.

Moreover, similarly to the gradient estimated by the GPOMDP algorithm in Baxter01IP, the gradient estimated by Algorithm 1, ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}), may be employed with the conjugate-gradients and line-search methods of Baxter01EI for making better use of gradient information. This allows us to exploit the information contained in the gradient estimate more aggressively than by simply adjusting the parameters by a small amount in the direction of ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}). Conjugate-gradients and line-search are two widely used techniques in non-stochastic optimization that allow us to find better gradient directions than the pure gradient direction, and to obtain better step sizes, respectively.

Note that in this section, we followed Baxter01IP (the GPOMDP algorithm) and considered stochastic policies that map observations to actions. However, as mentioned by Baxter01IP, it is immediate that the same algorithm works for any finite history of observations. Moreover, along the same way that Aberdeen01PG showed that GPOMDP can be extended to apply to policies with internal state, our BPG POMDP algorithm can also be extended to handle such policies.

BPG Experimental Results

In this section, we compare the Bayesian quadrature (BQ) and the plain MC gradient estimates on a simple bandit problem as well as on a continuous state and action linear quadratic regulator (LQR). We also evaluate the performance of the Bayesian policy gradient (BPG) algorithm described in Algorithm 2 on the LQR, and compare it with a Monte-Carlo based policy gradient (MCPG) algorithm.

Table 2 shows the exact gradient of the expected return and its MC and BQ estimates using 1010 and 100100 samples for two instances of the bandit problem corresponding to two different deterministic reward functions r(a)=ar(a)=a and r(a)=a2r(a)=a^{2}. The average over 10410^{4} runs of the MC and BQ estimates and their standard deviations are reported in Table 2. The true gradient is analytically tractable and is reported as “Exact” in Table 2 for reference.

As shown in Table 2, the variance of the BQ estimates are lower than the variance of the MC estimates by an order of magnitude for the small sample size (M=10M=10), and by 6 orders of magnitude for the large sample size (M=100M=100). The BQ estimate is also more accurate than the MC estimate for the large sample size, and is roughly the same for the small sample size.

2 Linear Quadratic Regulator

In this section, we consider the following linear system in which the goal is to minimize the expected return over 2020 steps.What we mean by reward and return in this section is in fact cost and loss, and this is why we are dealing with a minimization, and not a maximization, problem here. The reason for this is to maintain consistency in notations and definitions throughout the paper. Thus, it is an episodic problem with paths of length 2020.

We run two sets of experiments on this system. We first fix the set of policy parameters and compare the BQ and MC estimates of the gradient of the expected return using the same sample. We then proceed to solving the complete policy gradient problem and compare the performance of the BPG algorithm (with both conventional and natural gradients) with a Monte-Carlo based policy gradient (MCPG) algorithm.

In this section, we compare the BQ and MC estimates of the gradient of the expected return for the policy induced by parameters λ=0.2\lambda=-0.2 and σ=1\sigma=1. We use several different sample sizes (number of paths used for gradient estimation) M=5j  ,  j=1,,20M=5j\;,\;j=1,\ldots,20 for the BQ and MC estimates. For each sample size, we compute the MC and BQ estimators using the same sample, repeat this process 10410^{4} times, and then compute the average. The true gradient is analytically tractable and is used for comparison purposes.

Figure 1 shows the mean squared error (MSE) (left column) and the mean absolute angular error (right column) of the MC and BQ estimates of the gradient for several different sample sizes. The absolute angular error is the absolute value of the angle between the true and estimated gradients. In this figure, the BQ gradient estimates were calculated using Model 1 (top row) and Model 2 (bottom row) with sparsification. The error bars in the figures on the right column are the standard errors of the mean absolute angular errors.

We ran another set of experiments in which we added i.i.d. Gaussian noise to the rewards: rt=xt2+0.1at2+nr  ;  nrN(0,σr2)r_{t}=x_{t}^{2}+0.1a_{t}^{2}+n_{r}\;;\;n_{r}\sim{\mathcal{N}}(0,\sigma_{r}^{2}). Note that in Models 1 and 2, y(ξ)y(\xi), the noisy sample of f(ξ)f(\xi), is of the form R(ξ)logPr(ξ;θ)R(\xi)\nabla\mathop{\rm log}\Pr(\xi;{\boldsymbol{\theta}}) and R(ξ)R(\xi), respectively (see Sections 4.1 and 4.2). Moreover, since each reward rtr_{t} is a Gaussian random variable with variance σr2\sigma_{r}^{2}, the return R(ξ)=t=0T1rtR(\xi)=\sum_{t=0}^{T-1}r_{t} is also a Gaussian random variable with variance Tσr2T\sigma_{r}^{2}. Therefore in this case, the measurement noise covariance matrices for Models 1 and 2 may be written as Σ=Tσr2diag((θilogp(ξ1;θ))2,,(θilogp(ξM;θ))2){\boldsymbol{\Sigma}}=T\sigma_{r}^{2}\mathop{\rm diag}\Big(\big(\frac{\partial}{\partial\theta_{i}}\mathop{\rm log}p(\xi_{1};{\boldsymbol{\theta}})\big)^{2},\ldots,\big(\frac{\partial}{\partial\theta_{i}}\mathop{\rm log}p(\xi_{M};{\boldsymbol{\theta}})\big)^{2}\Big) and Σ=Tσr2I{\boldsymbol{\Sigma}}=T\sigma_{r}^{2}{\boldsymbol{I}}, respectively, where T=20T=20 is the path length.In Model 1, Σ{\boldsymbol{\Sigma}} is the measurement noise covariance matrix for the iith component of the gradient θiηB(θ)\frac{\partial}{\partial\theta_{i}}\eta_{B}({\boldsymbol{\theta}}). Note that θilogp(ξj;θ)\frac{\partial}{\partial\theta_{i}}\mathop{\rm log}p(\xi_{j};{\boldsymbol{\theta}}) depends only on the policy and can be calculated using Equation 5. We tried two different Gaussian reward noise standard deviations: σr=0.1  and  1\sigma_{r}=0.1\;\text{and}\;1 in our experiments. Adding noise to the rewards slightly increased the error of the BQ and MC estimates of the gradient. However, the graphs comparing these estimates remained quite similar to those shown in Figure 1. Hence in Figure 2, we compare the MSE (left column) and the mean absolute angular error (right column) of the BQ estimates with and without noise in the rewards as a function of the number of sample paths MM. In this figure, the noise in the rewards has variance σr2=1\sigma_{r}^{2}=1, and the BQ gradient estimates were calculated using Model 1 (top row) and Model 2 (bottom row) with sparsification.

2.2 Policy Optimization

In this section, we use Bayesian policy gradient (BPG) to optimize the policy parameters in the LQR problem. Figure 3 shows the performance of the BPG algorithm with the conventional (BPG) and natural (BPNG) gradient estimates, versus a MC-based policy gradient (MCPG) algorithm, for sample sizes (number of sample paths used to estimate the gradient of each policy) M=5M=5, 1010, 2020, and 4040. We use Algorithm 2 with the number of updates set to N=100N=100, and Model 1 with sparsification for the BPG and BPNG methods. Since Algorithm 2 computes the Fisher information matrix for each set of policy parameters, the estimate of the natural gradient is provided at little extra cost at each step. The returns obtained by these methods are averaged over 10410^{4} runs. The policy parameters are initialized randomly at each run. In order to ensure that the learned parameters do not exceed an acceptable range, the policy parameters are defined as λ=1.999+1.998/(1+eκ1)\lambda=-1.999+1.998/(1+e^{\kappa_{1}}) and σ=0.001+1/(1+eκ2)\sigma=0.001+1/(1+e^{\kappa_{2}}). The optimal solution is λ0.92,  σ=0.001,  ηB(λ,σ)=0.3067\lambda^{*}\approx-0.92,\;\sigma^{*}=0.001,\;\eta_{B}(\lambda^{*},\sigma^{*})=0.3067, corresponding to κ10.16\kappa^{*}_{1}\approx-0.16 and κ2\kappa^{*}_{2}\rightarrow\infty.

Figure 3 shows that the MCPG algorithm performs better than BPG and BPNG only for the smallest sample size (M=5M=5), whereas for larger samples BPG and BPNG dominate MCPG. The better performance of MCPG for very small sample size is due to the fact that in this case, the Bayesian estimators, BPG and BPNG, like any other Bayesian estimator or posterior in such case, rely more on the prior, and thus, are not accurate if the prior is not very informative. A similar phenomenon was also reported by Rasmussen03BM. We used two different learning rates for the two components of the gradient. For a fixed sample size, BPG and MCPG methods start with an initial learning rate and decrease it according to the schedule βj=β0(20/(20+j))\beta_{j}=\beta_{0}\big(20/(20+j)\big). The BPNG algorithm uses a fixed learning rate multiplied by the determinant of the Fisher information matrix. We tried many values for the initial learning rates used by these algorithms and those in Table 3 yielded the best performance of those we tried.

So far we have assumed that the Fisher information matrix is known. In the next experiment, we estimate it using both MC and a model-based maximum likelihood (ML) method, as discussed in Section 4.3. In the ML approach, we model the transition probability function as P(xt+1xt,at)=N(c1xt+c2at+c3,c42)P(x_{t+1}|x_{t},a_{t})={\mathcal{N}}(c_{1}x_{t}+c_{2}a_{t}+c_{3},c_{4}^{2}), and then estimate its parameters (c1,c2,c3,c4)(c_{1},c_{2},c_{3},c_{4}) using observing state transitions. Figure 4 shows that the BPG algorithm, when the Fisher information matrix is estimated using ML and MC, still performs better than MCPG. Top and bottom rows contain the results for the BPG algorithm with conventional (BPG-ML and BPG-MC) and natural (BPNG-ML and BPNG-MC) gradient estimates, respectively. Although the BPG-ML (BPNG-ML) outperforms BPG-MC (BPNG-MC) for small sample sizes, the difference in their performance disappears as we increase the sample size. One reason for the good performance of BPG-ML is that the form of the state transition function P(xt+1xt,at)P(x_{t+1}|x_{t},a_{t}) has been selected correctly. Here we used the same initial learning rates and learning rate schedules as in the experiments of Figure 3 (see Table 3).

Although the proposed Bayesian policy gradient algorithm (Algorithm 2) uses only the posterior mean of the gradient in its updates, it can be extended to make judicious use of the second moment information provided by the Bayesian policy gradient estimation algorithm (Algorithm 1). In the last experiment of this section, we use the posterior covariance of the gradient, provided by Algorithm 1, to select the learning rate and the direction of the updates in Algorithm 2. The idea is to use a small learning rate when the variance of the gradient estimate is large, and to have a large update when it is small. We refer to the resulting algorithm by the name BPG-var. This algorithm uses a fixed learning rate parameter (see Table 3) multiplied by [(1+n)ICov(ηB(θ)DM)]/(1+n)\Big[\big(1+n\big){\boldsymbol{I}}-{\bf Cov}\big(\nabla\eta_{B}({\boldsymbol{\theta}})|{\mathcal{D}}_{M}\big)\Big]/(1+n) in its updates. Note that n+1n+1 is b0b_{0} in the calculation of the posterior covariance of the gradient in Model 1 (see Proposition 3), and is used here as an upper bound for the posterior covariance of the gradient. Figure 5 compares the average expected return of BPG-var with BPG and MCPG for sample sizes M=5M=5, 1010, 2020, and 4040. The figure shows that BPG-var performs better than BPG and MCPG for all the sample sizes. It even has a better performance than MCPG for the smallest sample size (M=5M=5). Comparing Figures 3 and 5 shows that BPG-var converges faster than BPNG and has similar final performance. As we expected, BPG-var and BPG perform more and more alike as we increase the sample size. This is because by increasing the sample size the estimated gradient (the posterior mean of the gradient), and as a result, the update direction used by BPG becomes more reliable.

In an approach similar to the one used in the experiments of Figure 5, Vien11HM used BQ to estimate the Hessian matrix distribution, and then used its mean as learning rate schedule to improve the performance of BPG. They empirically showed that their method performs better than BPG and BPNG in terms of convergence speed.

Bayesian Actor-Critic

The models and algorithms of Section 4 consider complete trajectories as the basic observable unit, and thus, do not require the dynamics within each trajectory to be of any special form. In particular, it is not necessary for the dynamics to have the Markov property, allowing the resulting algorithms to handle partially observable MDPs, Markov games, and other non-Markovian systems. On the down side, these algorithms cannot take advantage of the Markov property when operating in Markovian systems. Moreover, since the unit of observation of these algorithms is the entire trajectory, their gradient estimates have larger variance than the algorithms that will be discussed in this section, whose unit of observation is (current state, action, next state), since they take advantage of the Markov property, especially when the size of the trajectories is large.

In this section, we apply the Bayesian quadrature idea to the policy gradient expression given by Equation 7, i.e.,

and derive a family of Bayesian actor-critic (BAC) algorithms. In this approach, we place a Gaussian process (GP) prior over action-value functions using a prior covariance kernel defined on state-action pairs: k(z,z)=Cov[Q(z),Q(z)]k({\boldsymbol{z}},{\boldsymbol{z}}^{\prime})={\bf Cov}\big[Q({\boldsymbol{z}}),Q({\boldsymbol{z}}^{\prime})\big]. We then compute the GP posterior conditioned on the sequence of individual observed transitions. In the same vein as Section 4, by an appropriate choice of a prior on action-value functions, we are able to derive closed-form expressions for the posterior moments of η(θ)\nabla\eta({\boldsymbol{\theta}}). The main questions here are: 1) how to compute the GP posterior of the action-value function given a sequence of observed transitions? and 2) how to choose a prior for the action-value function that allows us to derive closed-form expressions for the posterior moments of η(θ)\nabla\eta({\boldsymbol{\theta}})? Fortunately, well developed machinery for computing the posterior moments of Q(z)Q({\boldsymbol{z}}) is provided in a series of papers by Engel03BM, Engel05RL (for a thorough treatment see Engel05AR). In the next two sections, we will first briefly review some of the main results pertaining to the Gaussian process temporal difference (GPTD) model proposed in Engel05RL, and then will show how they may be combined with the Bayesian quadrature idea in developing a family of Bayesian actor-critic algorithms.

The Gaussian process temporal difference (GPTD) learning (Engel03BM, Engel05RL) model is based on a statistical generative model relating the observed reward signal rr to the unobserved action-value function QQ

where N(zi,zi+1)N({\boldsymbol{z}}_{i},{\boldsymbol{z}}_{i+1}) is a zero-mean noise signal that accounts for the discrepancy between r(zi)r({\boldsymbol{z}}_{i}) and Q(zi)γQ(zi+1)Q({\boldsymbol{z}}_{i})-\gamma Q({\boldsymbol{z}}_{i+1}). Let us define the finite-dimensional processes rt{\boldsymbol{r}}_{t}, QtQ_{t}, NtN_{t}, and the t×(t+1)t\times(t+1) matrix Ht{\boldsymbol{H}}_{t} as follows:

The set of Equations 29 for i=0,,t1i=0,\ldots,t-1 may be written as rt1=HtQt+Nt{\boldsymbol{r}}_{t-1}={\boldsymbol{H}}_{t}Q_{t}+N_{t}. Under certain assumptions on the distribution of the discounted return random process (Engel05RL), the covariance of the noise vector NtN_{t} is given by

In episodic tasks, if zt1{\boldsymbol{z}}_{t-1} is the last state-action pair in the episode (i.e., xt{\boldsymbol{x}}_{t} is a zero-reward absorbing terminal state), Ht{\boldsymbol{H}}_{t} becomes a square t×tt\times t invertible matrix of the form shown in Equation 31 with its last column removed. The effect on the noise covariance matrix Σt{\boldsymbol{\Sigma}}_{t} is that the bottom-right element becomes 11 instead of 1+γ21+\gamma^{2}.

Placing a GP prior on QQ and assuming that NtN_{t} is also normally distributed, we may use Bayes’ rule to obtain the posterior moments of QQ:

where Dt{\mathcal{D}}_{t} denotes the observed data up to and including time step tt. We used here the following definitions:

Note that Q^t(z)\hat{Q}_{t}({\boldsymbol{z}}) and S^t(z,z)\hat{S}_{t}({\boldsymbol{z}},{\boldsymbol{z}}^{\prime}) are the posterior mean and covariance functions of the posterior GP, respectively. As more samples are observed, the posterior covariance decreases, reflecting a growing confidence in the Q-function estimate Q^t\hat{Q}_{t}.

2 A Family of Bayesian Actor-Critic Algorithms

We are now in a position to describe the main idea behind our BAC approach. Making use of the linearity of Equation 7 in QQ and denoting g(z;θ)=πμ(z)logμ(ax;θ){\boldsymbol{g}}({\boldsymbol{z}};{\boldsymbol{\theta}})=\pi^{\mu}({\boldsymbol{z}})\nabla\mathop{\rm log}\mu({\boldsymbol{a}}|{\boldsymbol{x}};{\boldsymbol{\theta}}), we obtain the following expressions for the posterior moments of the policy gradient (Ohagan91BQ):

Substituting the expressions for the posterior moments of QQ from Equation 7.1 into Equation 7.2, we obtain

These equations provide us with the general form of the posterior policy gradient moments. We are now left with a computational issue, namely, how to compute the integrals appearing in these expressions? We need to be able to evaluate the following integrals:

Using these definitions, we may write the gradient posterior moments compactly as

In order to render these integrals analytically tractable, we choose our prior covariance kernel to be the sum of an arbitrary state-kernel kxk_{x} and the (invariant) Fisher kernel kFk_{F} between state-action pairs (see e.g., ShaweTaylor04KM, Chapter 12). The (policy dependent) Fisher information kernel and our overall state-action kernel are then given by

where u(z;θ){\boldsymbol{u}}({\boldsymbol{z}};{\boldsymbol{\theta}}) and G(θ){\boldsymbol{G}}({\boldsymbol{\theta}}) are the score function and Fisher information matrix defined asSimilar to u(ξ){\boldsymbol{u}}(\xi) and G{\boldsymbol{G}} defined by Equations 5 and 24, to simplify the notation, we omit the dependence of u{\boldsymbol{u}} and G{\boldsymbol{G}} to the policy parameters θ{\boldsymbol{\theta}}, and replace u(z;θ){\boldsymbol{u}}({\boldsymbol{z}};{\boldsymbol{\theta}}) and G(θ){\boldsymbol{G}}({\boldsymbol{\theta}}) with u(z){\boldsymbol{u}}({\boldsymbol{z}}) and G{\boldsymbol{G}} in the sequel.

Although here we have total flexibility in selecting the state kernel, we are restricted to the Fisher kernel for state-action pairs. This restriction may cause an error in approximating some action-value functions QQ. This error depends on the problem at hand and is hard to quantify. This is exactly the same as selecting an inaccurate prior in any Bayesian algorithm or choosing a wrong representation (function space) in any machine learning algorithm (referred to as approximation error in the approximation theory). However, this restriction did not cause a significant error in our experiments (see Section 8), as in almost all of them, the gradients estimated by BAC were more accurate than those estimated by the MC-based method, given the same number of samples.

Note that in Sections 4 to 6 we used a formulation in which the observable unit is a system trajectory, and thus, the expected return and its gradient are defined by Equations 2 and 4. In this formulation, the score function and Fisher information matrix are defined by Equations 5 and 24. However, in the formulation used in this section and in the rest of the paper, where the observable unit is an individual state-action-reward transition, the expected return and its gradient are defined by Equations 3 and 7. In this formulation, the score function and Fisher information matrix are defined by Equations 39 and 40, respectively.

A nice property of the Fisher kernel is that while kF(z,z)k_{F}({\boldsymbol{z}},{\boldsymbol{z}}^{\prime}) depends on the policy, it is invariant to policy reparameterization. In other words, it only depends on the actual probability mass assigned to each action and not on its explicit dependence on the policy parameters. As mentioned above, another attractive property of this particular choice of kernel is that it renders the integrals in Equation 36 analytically tractable, as made explicit in the following proposition

where Ut=[u(z0),u(z1),,u(zt)]{\boldsymbol{U}}_{t}=\big[{\boldsymbol{u}}({\boldsymbol{z}}_{0}),{\boldsymbol{u}}({\boldsymbol{z}}_{1}),\ldots,{\boldsymbol{u}}({\boldsymbol{z}}_{t})\big].

An immediate consequence of Proposition 6 is that, in order to compute the posterior moments of the policy gradient, we only need to be able to evaluate (or estimate) the score vectors u(zi),  i=0,,t{\boldsymbol{u}}({\boldsymbol{z}}_{i}),\;i=0,\ldots,t and the Fisher information matrix G{\boldsymbol{G}} of our policy. Evaluating the Fisher information matrix G{\boldsymbol{G}} is somewhat more challenging, since on top of taking the expectation with respect to the policy μ(ax;θ)\mu(a|x;{\boldsymbol{\theta}}), computing G{\boldsymbol{G}} involves an additional expectation over the state-occupancy density νμ(x)\nu^{\mu}(x), which is not generally known. In most practical situations we therefore have to resort to estimating G{\boldsymbol{G}} from data. When νμ\nu^{\mu} in the definition of the Fisher information matrix (Equation 40) is the stationary distribution over states under policy μ\mu, one straightforward method to estimate G{\boldsymbol{G}} from a trajectory z0,z1,,zt{\boldsymbol{z}}_{0},{\boldsymbol{z}}_{1},\ldots,{\boldsymbol{z}}_{t} is to use the (unbiased) estimator (see Proposition 6 for the definition of Ut{\boldsymbol{U}}_{t}):

In case νμ\nu^{\mu} in Equation 40 is a discounted weighting of states encountered by following policy μ\mu (as it is considered in this paper), a method for estimating G{\boldsymbol{G}} from a number of trajectories is shown in Algorithm 3. Note that (1γ)νμ(1-\gamma)\nu^{\mu} corresponds to the distribution of a Markov chain that starts from a state sampled according to P0P_{0} and at each step either follows the policy μ\mu with probability γ\gamma or restarts from a new initial state drawn from P0P_{0} with probability 1γ1-\gamma. It is easy to show that the average number of steps between two successive restarts of this distribution is 1/(1γ)1/(1-\gamma).

Algorithm 4 is a pseudocode sketch of the Bayesian actor-critic algorithm, using either the conventional gradient or the natural gradient in the policy update, and with G{\boldsymbol{G}} estimated using either G^t\hat{{\boldsymbol{G}}}_{t} in Equation 42 or G^(θ)\hat{{\boldsymbol{G}}}({\boldsymbol{\theta}}) in Algorithm 3.

3 BAC Online Sparsification

Using the sparsification method described above, the posterior moments of the gradient are approximated as

BAC Experimental Results

In this section, we empiricallyThe code for all the experiments of this section is available at https://sequel.lille.inria.fr/Software/BAC. evaluate the performance of the Bayesian actor-critic method presented in this paper in a 10-state random walk problem as well as in the widely used continuous-state-space mountain car problem (Sutton98IR) and ship steering problem (Miller90NN). In Section 8.1, we first compare BAC, Bayesian quadrature (BQ), and Monte Carlo (MC) gradient estimates in the 10-state random walk problem. We then evaluate the performance of the BAC algorithm on the same problem, and compare it with a Bayesian policy gradient (BPG) algorithm and a MC-based policy gradient (MCPG) algorithm. In Section 8.2, we compare the performance of the BAC algorithm with a MCPG algorithm on the mountain car problem. The BPG, BAC, and MCPG algorithms used in our experiments are Algorithms 2 and 4 presented in this paper, and Algorithm 1 in Baxter01IP, respectively. In Section 8.3, we compare the performance of the BAC algorithm with a MCPG algorithm on a problem in the ship steering domain. Similar to Section 8.2, the BAC, and MCPG algorithms used in our experiments are Algorithm 4 presented in this paper and Algorithm 1 in Baxter01IP, respectively.

In this section, we consider a 10-state random walk problem, X={1,2,,10}{\mathcal{X}}=\{1,2,\ldots,10\}, with states arranged linearly from state 1 on the left to state 10 on the right. The agent has two actions to choose from: A={left,right}{\mathcal{A}}=\{left,right\}. The left wall is a retaining barrier, meaning that if the leftleft action is taken at state 1, in the next time-step the state will be 1 again. State 10 is a zero reward absorbing state. The only stochasticity in the transitions is induced by the policy, which is defined as μ(rightx)=1/1+exp(θx)\mu(right|x)=1/1+\exp(-\theta_{x}) and μ(leftx)=1μ(rightx)\mu(left|x)=1-\mu(right|x), for all xXx\in{\mathcal{X}}. Note that each state xx has an independent parameter θx\theta_{x}. Each episode begins at state 1 and ends when the agent reaches state 10. The mean reward is 1 for states 1–9 and is 0 for state 10. The observed rewards for states 1–9 are obtained by corrupting the mean rewards with a 0.1 standard deviation i.i.d. Gaussian noise. The discount factor is γ=0.99\gamma=0.99. In the BAC experiments, we use the Gaussian state kernel kx(x,x)=exp(xx2/(2σk2))k_{x}(x,x^{\prime})=\exp(-||x-x^{\prime}||^{2}/(2\sigma_{k}^{2})) with σk=3\sigma_{k}=3 and the state-action kernel 0.01kF(z,z)0.01k_{F}({\boldsymbol{z}},{\boldsymbol{z}}^{\prime}).

We first compare the MC, BQ, and BAC estimates of η(θ)\nabla\eta({\boldsymbol{\theta}}) for the policy induced by the parameters θx=log(41/9)\theta_{x}=\mathop{\rm log}(41/9) for all xXx\in{\mathcal{X}}, which is equivalent to μ(rightx)=0.82\mu(right|x)=0.82. We use several different sample sizes: M=5j,  j=1,,20M=5j,\;j=1,\ldots,20. Here, by sample size we mean the number of episodes used to estimate the gradient. For each value of MM, we compute the gradient estimates 10310^{3} times. The true gradient is calculated analytically for reference. Figure 6 shows the mean squared error and the mean absolute angular error of MC, BQ, and BAC estimates of the gradient for different sample sizes MM. The error bars in the right figure are the standard errors of the mean absolute angular errors. The results depicted in Figure 6 indicate that the BAC gradient estimates are more accurate and have lower variance than their MC and BQ counterparts.

Next, we use BAC to optimize the policy parameters and compare its performance with a BPG algorithm and a MCPG algorithm for M=1,  25,  50M=1,\;25,\;50, and 7575. The BPG algorithm uses Model 1 of Section 4.1. We use Algorithm 4 with the number of policy updates set to 500500 and the same kernels as in the previous experiment. The Fisher information matrix is estimated using Algorithm 3. The returns obtained by these methods are averaged over 10310^{3} runs. For a fixed sample size MM, we tried many values of the learning rate, β\beta, for MCPG, BPG, and BAC, and those in Table 4 yielded the best performance. Note that the learning rate used for each algorithm in each experiment is fixed and does not converge to zero. BAC showed a very robust performance when we changed the learning rate. By robust we mean that it never generated a policy for which an episode does not end after 10610^{6} steps. This seems to be due to the fact that BAC gradient estimates are more accurate and have less variance than their MC and BPG counterparts. The performance of BPG improves as we increase the sample size MM. It performs worse than MCPG for M=1M=1 and 2525, but achieves a performance similar to BAC for M=100M=100.

Figure 7 depicts the results of these experiments. From left to right and top to bottom the sub-figures correspond to the experiment in which all the algorithms used M=1,  25,  50,M=1,\;25,\;50, and 7575 trajectories per policy update, respectively. Each curve depicts the difference between the exact average discounted return for the 500500 policies that follow each policy update and η\eta^{*} – the optimal average discounted return. All curves are averaged over 10310^{3} repetitions of the experiment. The BAC algorithm clearly learns significantly faster than the other algorithms (note that the vertical scale is logarithmic).

Remark: Since BQ (and as a result BPG) is based on defining a kernel over system trajectories (quadratic Fisher kernel in Model 1 and Fisher kernel in Model 2), its performance degrades when the system generates trajectories of different size. This effect can be observed by most kernels that have been used in the literature for the trajectories generated by dynamical systems. This can be also observed in our experiments: BQ performs much better than MC in the “Linear Quadratic Regulator” problem (Section 6.2), in which all the system trajectories are of size 20, while its superiority over MC is less apparent in the “Random Walk” problem (Section 8.1). This is why we are not going to use BQ and BPG in the “Mountain Car” (Section 8.2) and “Ship Steering” (Section 8.3) problems, in which the system trajectories have different lengths.

2 Mountain Car

In this section, we consider the mountain car problem as formulated in Sutton98IR, and report the results of applying the BAC and MCPG algorithms to optimize the policy parameters in this task. The state x{\boldsymbol{x}} consists of the position xx and the velocity x˙\dot{x} of the car: x=(x,x˙){\boldsymbol{x}}=(x,\dot{x}). The reward is 1-1 on all time steps until the car reaches its goal at the top of the hill, which ends the episode. There are three possible actions: forward, reverse, and zero. The car moves according to the following simplified dynamics:

When xt+1x_{t+1} reaches the left boundary, x˙t+1\dot{x}_{t+1} is set to zero and when it reaches the right boundary, the goal is reached and the episode ends. Each episode starts from a random position and velocity uniformly sampled from their domains. We use the discount factor γ=0.99\gamma=0.99.

In order to define the policy, we first map the states x=(x,x˙){\boldsymbol{x}}=(x,\dot{x}) to the unit square ×\times. The policy used in our experiments has the following form:

The policy feature vector is defined as ϕ(x,ai)=(ϕ(x)δa1ai,ϕ(x)δa2ai,ϕ(x)δa3ai)\phi({\boldsymbol{x}},a_{i})=\big(\phi({\boldsymbol{x}})^{\top}\delta_{a_{1}a_{i}},\phi({\boldsymbol{x}})^{\top}\delta_{a_{2}a_{i}},\phi({\boldsymbol{x}})^{\top}\delta_{a_{3}a_{i}}\big)^{\top}, where δajai\delta_{a_{j}a_{i}} is 11 if aj=aia_{j}=a_{i}, and is otherwise. The state feature vector ϕ(x)\phi({\boldsymbol{x}}) is composed of 1616 Gaussian functions arranged in a 4×44\times 4 grid over the unit square as follows:

where the xˉi\bar{{\boldsymbol{x}}}_{i}’s are the 1616 points of the grid {0,0.25,0.5,1}×{0,0.25,0.5,1}\{0,0.25,0.5,1\}\times\{0,0.25,0.5,1\} and κ=1.3×0.25\kappa=1.3\times 0.25.

In Figure 8, we compare the performance of BAC with a MCPG algorithm for M=5,  10,  20,M=5,\;10,\;20, and 4040 episodes used to estimate each gradient. For BAC, we use Algorithm 4 with the number of policy updates set to 500500, a Gaussian state kernel kx(x,x)=exp(xx2/(2σk2))k_{x}({\boldsymbol{x}},{\boldsymbol{x}}^{\prime})=\exp\big(-||{\boldsymbol{x}}-{\boldsymbol{x}}^{\prime}||^{2}/(2\sigma_{k}^{2})\big), with σk=1.3×0.25\sigma_{k}=1.3\times 0.25, and the state-action kernel kF(z,z)k_{F}({\boldsymbol{z}},{\boldsymbol{z}}^{\prime}). The Fisher information matrix is estimated using Algorithm 3. After every 5050 policy updates the learned policy is evaluated for 10310^{3} episodes to estimate accurately the average number of steps to goal. Each evaluation episode starts from a random position and velocity uniformly chosen from their ranges, and continues until the car either reaches the goal or a limit of 200200 time-steps is exceeded. The experiment is repeated 100100 times for the entire horizontal axis to obtain average results and confidence intervals. The error bars in this figure are the standard errors of the performance of the algorithms.

For a fixed sample size MM, each method starts with an initial learning rate and decreases it according to the schedule βt=β0βc/(βc+t)\beta_{t}=\beta_{0}\beta_{c}/(\beta_{c}+t). We tried many values of the learning rate parameters (β0,βc)(\beta_{0},\beta_{c}) for MCPG and BAC, and those in Table 5 yielded the best performance. Note that βc=\beta_{c}=\infty means that we used a fixed learning rate β0\beta_{0} for that experiment. The graphs indicate that BAC performs better and has lower variance than MCPG. It is able to find a good policy with only M=5M=5 sample size and its performance does not change much as the sample size is increased. On the other hand, the performance of MCPG improves and its variance is reduced as we increase the sample size. Note that for M=40M=40, MCPG finally achieves a similar performance (still with slower rate) as BAC.

3 Ship Steering

In this section, we perform comparative experiments between BAC and MCPG on a more challenging problem in the continuous state continuous action ship steering domain (Miller90NN).

In this domain, a ship is located in a 150×150150\times 150 meter square water surface. At any point in time tt, the state of the ship is described by four continuous variables that are defined below along with their range of values

and then map it to the allowed range [15,15][-15^{\circ},15^{\circ}] using the sigmoid transformation

For the BAC experiments, we used the Gaussian state kernel kx(x,x)=exp(xx2/(2σk2))k_{x}({\bf x},{\bf x}^{\prime})=\exp(-||{\bf x}-{\bf x}^{\prime}||^{2}/(2\sigma_{k}^{2})), with σk=1\sigma_{k}=1 and the state-action kernel kF(z,z)k_{F}({\boldsymbol{z}},{\boldsymbol{z}}^{\prime}), i.e., the Fisher kernel.

Second, we calculate the gradient using the online sparsification procedure described in Section 4.4. Finaly, we never explicitly calculate the inverse of the Fisher information matrix G^\hat{{\boldsymbol{G}}} and instead calculate the product of G^1\hat{{\boldsymbol{G}}}^{-1} with the score. For the numerical stability we also add 10610^{-6} to the diagonal of G^\hat{{\boldsymbol{G}}}.

Similar to the other experiments in the paper, we varied the number of trajectories used to estimate the gradient of a policy as M=5M=5, 1010, and 2020. Table 6 shows the best values of the learning rate β\beta for both MCPG and BAC for different values of MM. To evaluate each method, we ran 100100 independent learning trials. At each trial, we evaluate the performance of the policy every 100100 iterations by executing it 100100 (independent) times with θ1\theta_{1} and θ˙1\dot{\theta}_{1} randomly sampled. For each of these execution, we observe if the ship reached (x,y)(x_{*},y_{*}) within 500500 steps and estimate the policy success ratio. We set the total number of gradient updates to T=3000T=3000 for M=5M=5 and 1010 and to T=1000T=1000 for M=20M=20.

The results for all the experiments are presented in Figure 9 along with their standard deviations. Naturally, using more trajectories for the gradient update improves both methods. However, this improvement is bigger for the BAC method. In the case of M=5M=5, MCPG produces slightly better policies at the beginning of learning, but is soon outperformed by BAC. For M=10M=10 and 2020, BAC produces better policies from the beginning, especially for M=20M=20. This is consistent with the results of the other experimental domains reported in the paper. For all values of MM, BAC converges to a policy with a better success ratio than MCPG. Finally, as expected, BAC has usually less variance in its performance than MCPG.

Other Advancements in Bayesian Reinforcement Learning

The algorithms presented in this paper belong to the class of Bayesian model-free RL, as they do not assume that the system’s dynamic is known and do not explicitly construct a model of the system. In recent years, Bayesian methodology has been used to develop algorithms in several other areas of RL. In this section, we provide a brief overview of these results (for more details, see the survey by Ghavamzadeh15BR).

Another widely-used class of RL algorithms are those that build an explicit model of the system and use it to find a good (or optimal) policy, thus, are known as model-based RL algorithms. Recent years have witnessed many applications of the Bayesian methodology to this class of RL algorithms. The main idea of model-based Bayesian RL is to explicitly maintain a posterior over the model parameters and to use it to select actions in order to appropriately balance exploration and exploitation. The class of model-based Bayesian RL algorithms include those that work with MDPs and those that work with POMDPs (e.g., Ross08BAPOMDP, doshi08). The MDP-based algorithms can be further divided to those that are offline (e.g., duff01bamdpfsc, poupart06beetle), those that are online (e.g., dearden99model, strens00, wang05sparse, Ross08BAPOMDP), and those that have probably approximately correct (PAC)-guarantees (e.g., kolter09, asmuth09, sorg10).

The use of Bayesian methodology has also been explored to solve the inverse RL (IRL) problem, i.e., learning the underlying model of the decision-making agent (expert) from its observed behavior and the dynamics of the system (Russell98LA). The main idea of Bayesian IRL (BIRL) is to use a prior to encode the reward preference and to formulate the compatibility with the expert’s policy as a likelihood in order to derive a probability distribution over the space of reward functions, from which the expert’s reward function is somehow extracted. The most notable works in the area of BIRL include those by Ramachandran07BI, Choi11MA, Choi12NV, Michini12BN, Michini12IE.

Bayesian techniques have also been used to derive algorithms for the collaborative multi-agent RL problem. When dealing with multi-agent systems, the complexity of the decision problem is increased in the following way: while single-agent BRL requires maintaining a posterior over the MDP parameters (in the case of model-based methods) or over the value/policy (in the case of model-free methods), in multi-agent BRL, it is also necessary to keep a posterior over the policies of the other agents. Chalkiadakis13CM showed that this belief can be maintained in a tractable manner subject to certain structural assumptions on the domain, for example that the strategies of the agents are independent of each other.

Multi-task RL (MTRL) is another area that has witnessed the application of Bayesian methodology. All approaches to MTRL assume that the tasks share similarity in some components of the problem such as dynamics, reward structure, or value function. The Bayesian MTRL methods assume that the shared components are drawn from a common generative model (Wilson07MR, Mehta08TV, Lazaric10BM). In Mehta08TV, tasks share the same dynamics and reward features, and only differ in the weights of the reward function. The proposed method initializes the value function for a new task using the previously learned value functions as a prior. Wilson07MR and Lazaric10BM both assume that the distribution over some components of the tasks is drawn from a hierarchical Bayesian model.

Bayesian learning methods have also been used for regret minimization in multi-armed bandits. This area that goes back to the seminal work of Gittins79BP, has become very active with the Bayesian version of the upper confidence bound (UCB) algorithm (Kaufmann12BU) and the recent advancements in the analysis of Thompson Sampling (Agrawal11AT, Kaufmann12TS, agrawal2013further, agrawal2013thompson, Russo14IT, Gopalan14TS, guha2014stochastic, Liu2015prior) and its state-of-the-art empirical performance (Scott10MB, Chapelle11EE), which has also led to its use in several industrial applications (Graepel10WB, Tang13AA).

Discussion

In this paper, we first proposed an alternative approach to the conventional frequentist (Monte-Carlo based) policy gradient estimation procedure. Our approach is based on Bayesian quadrature (Ohagan91BQ), a Bayesian method for integral evaluation. The idea is to model the gradient of the expected return with respect to the policy parameters, which is of the form of an integral, as Gaussian processes (GPs). This is done by dividing the integrand into two parts, treating one as a random function (or random field), whose random nature reflects our subjective uncertainty concerning its true identity. This allows us to incorporate our prior knowledge of this term (part) into its prior distribution. Observing (possibly noisy) samples of this term allows us to employ Bayes’ rule to compute a posterior distribution of it conditioned on these samples. This in turn induces a posterior distribution over the value of the integral, which is the gradient of the expected return. By properly partitioning the integrand and by appropriately selecting a prior distribution, a closed-form expression for the posterior moments of the gradient of the expected return is obtained. We proposed two different ways of partitioning the integrand resulting in two distinct Bayesian models. For each model, we showed how the posterior moments of the gradient conditioned on the observed data are calculated. In line with previous work on Bayesian quadrature, our Bayesian approach tends to significantly reduce the number of samples needed to obtain accurate gradient estimates. Moreover, estimates of the natural gradient and the gradient covariance are provided at little extra cost. We performed detailed experimental comparisons of the Bayesian policy gradient (BPG) algorithms presented in the paper with classic Monte-Carlo based algorithms on a bandit problem as well as on a linear quadratic regulator problem. The experimental results are encouraging, but we conjecture that even better gains may be attained using this approach. This calls for additional theoretical and empirical work. It is important to note that the gradient estimated by Algorithm 1 may be employed in conjunction with conjugate-gradients and line-search methods for making better use of the gradient information. We also showed that the models and algorithms presented in this paper can be extended to partially observable problems without any change along the same lines as Baxter01IP. This is due to the fact that our BPG framework considers complete system trajectories as its basic observable unit, and thus, does not require the dynamic within each trajectory to be of any special form. This generality has the downside that our proposed framework cannot take advantage of the Markov property when the system is Markovian.

To address this issue, we then extended our BPG framework to actor-critic algorithms and presented a new Bayesian take on the actor-critic architecture. By using GPs and choosing their prior distributions to make them compatible with a parametric family of policies, we were able to derive closed-form expressions for the posterior distribution of the policy gradient updates. The posterior mean is used to update the policy and the posterior covariance to gauge the reliability of this update. Our Bayesian actor-critic (BAC) framework uses individual state-action-reward transitions as its basic observable unit, and thus, is able to take advantage of the Markov property of the system trajectories (when the system is indeed Markovian). This improvement seems to be borne out in our experiments, where BAC provides more accurate estimates of the policy gradient than either of the two BPG models for the same amount of data. Similar to BPG, another feature of BAC is that its natural-gradient variant is obtained at little extra cost. For both BPG and BAC, we derived the sparse form of the algorithms, which would make them significantly more time and memory efficient. Finally, we performed an experimental evaluation of the BAC algorithm, comparing it with classic Monte-Carlo based policy gradient algorithms, as well as our BPG algorithms, on a random walk problem, the widely used mountain car problem (Sutton98IR), and the continuous state and continuous action ship steering domain (Miller90NN).

Additional experimental work is required to investigate the behavior of BPG and BAC algorithms in larger and more realistic domains, involving continuous and high-dimensional state and action spaces. The BPG and BAC algorithms proposed in the paper use only the posterior mean of the gradient in their updates. We conjecture that the second-order statistics obtained from BPG and BAC (both in the actor and critic) may be used to devise more efficient algorithms. In one of the experiments in Section 6, we employed the covariance information provided by Algorithm 1 for risk-aware selection of the step size in the gradient updates, which showed promising performance. Other interesting directions for future work include 1) investigating other possible partitions of the integrand in the expression for ηB(θ)\nabla\eta_{B}({\boldsymbol{\theta}}) into a GP term and a deterministic term, 2) using other types of kernel functions such as sequence kernels, 3) combining our approach with MDP model estimation to allow transfer of learning between different policies (model-based Bayesian policy gradient), and 4) investigating more efficient methods for estimating the Fisher information matrix. Another direction is to derive a fully non-parametric actor-critic algorithm. In BAC, the critic is based on Gaussian process temporal difference learning, which is a non-parametric method, while the actor uses a family of parameterized policies. The idea here would be to replace the actor in the BAC algorithm with a non-parametric actor that performs gradient search in a function space (e.g., a reproducing kernel Hilbert space) of policies.

Part of the computational experiments was conducted using the Grid’5000 experimental testbed (https://www.grid5000.fr). Yaakov Engel was supported by an Alberta Ingenuity fellowship.

A Proof of Proposition 3

We start the proof with the M×1M\times 1 vector b{\boldsymbol{b}}, whose iith element can be written as

(a) substitutes k(ξ,ξi)k(\xi,\xi_{i}) with the quadratic Fisher kernel from Equation 23, (b) is algebra, (c) follows from (i) Pr(ξ;θ)dξ=1\int\Pr(\xi;{\boldsymbol{\theta}})d\xi=1, and (ii) u(ξ)Pr(ξ;θ)dξ=logPr(ξ;θ)Pr(ξ;θ)dξ\int{\boldsymbol{u}}(\xi)\Pr(\xi;{\boldsymbol{\theta}})d\xi=\int\nabla\mathop{\rm log}\Pr(\xi;{\boldsymbol{\theta}})\Pr(\xi;{\boldsymbol{\theta}})d\xi =Pr(ξ;θ)dξ=Pr(ξ;θ)dξ=(1)=0=\int\nabla\Pr(\xi;{\boldsymbol{\theta}})d\xi=\nabla\int\Pr(\xi;{\boldsymbol{\theta}})d\xi=\nabla(1)=0, (d) is the result of replacing the integral with the Fisher information matrix G{\boldsymbol{G}}, (e) is algebra, and thus, the claim follows. Now the proof for the scalar b0b_{0}

(a) substitutes k(ξ,ξ)k(\xi,\xi^{\prime}) with the quadratic Fisher kernel from Equation 23, (b) is algebra, (c) follows from (i) Pr(ξ;θ)Pr(ξ;θ)dξdξ=1\iint\Pr(\xi;{\boldsymbol{\theta}})\Pr(\xi^{\prime};{\boldsymbol{\theta}})d\xi d\xi^{\prime}=1, and (ii) u(ξ)Pr(ξ;θ)dξ=0\int{\boldsymbol{u}}(\xi)\Pr(\xi;{\boldsymbol{\theta}})d\xi=0, and finally (d) is the result of replacing the integral within the parentheses with the Fisher information matrix G{\boldsymbol{G}}.

The Fisher information matrix G{\boldsymbol{G}} is positive definite and symmetric. Thus, it can be written as G=VΛV{\boldsymbol{G}}={\boldsymbol{V}}{\boldsymbol{\Lambda}}{\boldsymbol{V}}^{\top}, where V=[v1,,vn]{\boldsymbol{V}}=[{\boldsymbol{v}}_{1},\ldots,{\boldsymbol{v}}_{n}] and Λ=diag[λ1,,λn]{\boldsymbol{\Lambda}}=\mathop{\rm diag}[\lambda_{1},\ldots,\lambda_{n}] are the matrix of orthonormal eigenvectors and the diagonal matrix of eigenvalues of matrix G{\boldsymbol{G}}, respectively. By replacing G1{\boldsymbol{G}}^{-1} with VΛ1V{\boldsymbol{V}}{\boldsymbol{\Lambda}}^{-1}{\boldsymbol{V}}^{\top} in Equation 44 we obtain

(a) and (b) are algebra, (c) is the result of switching the sum and the integral, (d) is algebra, (e) follows from the fact that viu(ξ){\boldsymbol{v}}_{i}^{\top}{\boldsymbol{u}}(\xi) is a scalar, and thus, can be replaced by its transpose, (f) is algebra, (g) substitutes the integral within the parentheses with the Fisher information matrix G{\boldsymbol{G}}, (h) replaces Gvi{\boldsymbol{G}}{\boldsymbol{v}}_{i} with λivi\lambda_{i}{\boldsymbol{v}}_{i}, (i) follows from the orthonormality of vi{\boldsymbol{v}}_{i}’s, and thus, the claim follows.

B Proof of Proposition 4

We start with the proof of B{\boldsymbol{B}}. This n×Mn\times M matrix may be written as

(a) substitutes k(ξ,ξi)k(\xi,\xi_{i}) with the Fisher kernel from Equation 27, (b) is algebra, (c) follows from Pr(ξ;θ)=u(ξ)Pr(ξ;θ)\nabla\Pr(\xi;{\boldsymbol{\theta}})={\boldsymbol{u}}(\xi)\Pr(\xi;{\boldsymbol{\theta}}), (d) substitutes the integral within the parentheses with the Fisher information matrix G{\boldsymbol{G}}, (e) is algebra, and thus, the claim follows. Now the proof for the n×nn\times n matrix B0{\boldsymbol{B}}_{0}

(a) follows from the fact that k(ξ,ξ)k(\xi,\xi^{\prime}) is scalar, (b) substitutes k(ξ,ξ)k(\xi,\xi^{\prime}) with the Fisher information kernel from Equation 27 and Pr(ξ;θ)\nabla\Pr(\xi;{\boldsymbol{\theta}}) with u(ξ)Pr(ξ;θ){\boldsymbol{u}}(\xi)\Pr(\xi;{\boldsymbol{\theta}}), (c) is algebra, (d) is the result of substituting the integrals within the parentheses with the Fisher information matrix G{\boldsymbol{G}}, and thus, the claim follows.

C Proof of Proposition 5

Sparsification does not change b0b_{0} and it remains equal to n+1n+1 (see Proposition 3), however it modifies b{\boldsymbol{b}} to

The claim follows using Lemma 1.3.2 in Engel05AR.

D Proof of Proposition 6

We start the proof with the n×(t+1)n\times(t+1) matrix Bt{\boldsymbol{B}}_{t}, whose iith column may be written as

The 1st line follows from the definition of matrix Bt{\boldsymbol{B}}_{t}, function g{\boldsymbol{g}}, and kernel kk, the 2nd line is algebra, the 3rd line follows from the definition of πμ\pi^{\mu} and the Fisher kernel kFk_{F}, the 4th line is algebra, the 5th line is the result of replacing the integral in the parentheses with the Fisher information matrix G{\boldsymbol{G}}, finally the 6th line is algebra, and the claim follows.

Now the proof for the n×nn\times n matrix B0{\boldsymbol{B}}_{0}

(a) follows from the definition of function g{\boldsymbol{g}} and kernel kk, (b) is algebra, (c) follows from the definition of πμ\pi^{\mu} and the Fisher kernel kFk_{F}, (c) is algebra, finally (d) follows from Adaμ(ax;θ)=0\int_{\mathcal{A}}da\nabla\mu(a|x;{\boldsymbol{\theta}})=0 and G=Zdzπμ(z)u(z)u(z){\boldsymbol{G}}=\int_{\mathcal{Z}}dz\pi^{\mu}({\boldsymbol{z}}){\boldsymbol{u}}({\boldsymbol{z}}){\boldsymbol{u}}({\boldsymbol{z}})^{\top}, and the claim follows.