Learning Continuous Control Policies by
Stochastic Value Gradients

arXiv:1510.09142v1 [cs.LG] 30 Oct 2015

Nicolas Heess∗ , Greg Wayne∗ , David Silver, Timothy Lillicrap, Yuval Tassa, Tom Erez
Google DeepMind
{heess, gregwayne, davidsilver, countzero, tassa, etom}@google.com
∗

These authors contributed equally.

Abstract
We present a unified framework for learning continuous control policies using
backpropagation. It supports stochastic control by treating stochasticity in the
Bellman equation as a deterministic function of exogenous noise. The product
is a spectrum of general policy gradient algorithms that range from model-free
methods with value functions to model-based methods without value functions.
We use learned models but only require observations from the environment instead of observations from model-predicted trajectories, minimizing the impact
of compounded model errors. We apply these algorithms first to a toy stochastic
control problem and then to several physics-based control problems in simulation.
One of these variants, SVG(1), shows the effectiveness of learning models, value
functions, and policies simultaneously in continuous domains.

1

Introduction

Policy gradient algorithms maximize the expectation of cumulative reward by following the gradient
of this expectation with respect to the policy parameters. Most existing algorithms estimate this gradient in a model-free manner by sampling returns from the real environment and rely on a likelihood
ratio estimator [32, 26]. Such estimates tend to have high variance and require large numbers of
samples or, conversely, low-dimensional policy parameterizations.
A second approach to estimate a policy gradient relies on backpropagation instead of likelihood ratio
methods. If a differentiable environment model is available, one can link together the policy, model,
and reward function to compute an analytic policy gradient by backpropagation of reward along a
trajectory [18, 11, 6, 9]. Instead of using entire trajectories, one can estimate future rewards using a
learned value function (a critic) and compute policy gradients from subsequences of trajectories. It
is also possible to backpropagate analytic action derivatives from a Q-function to compute the policy
gradient without a model [31, 21, 23]. Following Fairbank [8], we refer to methods that compute
the policy gradient through backpropagation as value gradient methods.
In this paper, we address two limitations of prior value gradient algorithms. The first is that, in
contrast to likelihood ratio methods, value gradient algorithms are only suitable for training deterministic policies. Stochastic policies have several advantages: for example, they can be beneficial for
partially observed problems [24]; they permit on-policy exploration; and because stochastic policies
can assign probability mass to off-policy trajectories, we can train a stochastic policy on samples
from an experience database in a principled manner. When an environment model is used, value
gradient algorithms have also been critically limited to operation in deterministic environments. By
exploiting a mathematical tool known as “re-parameterization” that has found recent use for generative models [20, 12], we extend the scope of value gradient algorithms to include the optimization
of stochastic policies in stochastic environments. We thus describe our framework as Stochastic
Value Gradient (SVG) methods. Secondly, we show that an environment dynamics model, value
function, and policy can be learned jointly with neural networks based only on environment interaction. Learned dynamics models are often inaccurate, which we mitigate by computing value
gradients along real system trajectories instead of planned ones, a feature shared by model-free
1

methods [32, 26]. This substantially reduces the impact of model error because we only use models
to compute policy gradients, not for prediction, combining advantages of model-based and modelfree methods with fewer of their drawbacks.
We present several algorithms that range from model-based to model-free methods, flexibly combining models of environment dynamics with value functions to optimize policies in stochastic or deterministic environments. Experimentally, we demonstrate that SVG methods can be applied using
generic neural networks with tens of thousands of parameters while making minimal assumptions
about plants or environments. By examining a simple stochastic control problem, we show that
SVG algorithms can optimize policies where model-based planning and likelihood ratio methods
cannot. We provide evidence that value function approximation can compensate for degraded models, demonstrating the increased robustness of SVG methods over model-based planning. Finally,
we use SVG algorithms to solve a variety of challenging, under-actuated, physical control problems,
including swimming of snakes, reaching, tracking, and grabbing with a robot arm, fall-recovery for
a monoped, and locomotion for a planar cheetah and biped.

2

Background

We consider discrete-time Markov Decision Processes (MDPs) with continuous states and actions
and denote the state and action at time step t by st ∈ RNS and at ∈ RNA , respectively. The MDP has
an initial state distribution s0 ∼ p0 (·), a transition distribution st+1 ∼ p(·|st , at ), and a (potentially
time-varying) reward function rt = r(st , at , t).1 We consider time-invariant stochastic policies
a ∼ p(·|s; θ), parameterized by θ. The goal of policy optimization is to find policy parameters θ that
maximize the expectedh sum of futurei rewards. We optimize either finite-horizon or infinite-horizon
P∞ t t 
PT
t t
sums, i.e., J(θ) = E
t=0 γ r θ or J(θ) = E
t=0 γ r θ where γ ∈ [0, 1] is a discount
factor.2 When possible, we represent a variable at the next time step using the “tick” notation, e.g.,
s0 , st+1 .
In what follows, we make extensive use of the state-action-value Q-function and state-value Vfunction.
#
"
#
"
X
X
t
t
t
τ −t τ t
τ −t τ t
(1)
Q (s, a) = E
γ r s = s, a = a, θ ; V (s) = E
γ r s = s, θ .
τ =t

τ =t

For finite-horizon problems, the value functions are time-dependent, e.g., V 0 , V t+1 (s0 ), and for
infinite-horizon problems the value functions are stationary, V 0 , V (s0 ). The relevant meaning
should be clear from the context. The state-value function can be expressed recursively using the
stochastic Bellman equation

Z 
Z
t
t
t+1 0
0
0
V (s) =
r +γ V
(s )p(s |s, a)ds p(a|s; θ)da.
(2)
We abbreviate partial differentiation using subscripts, gx , ∂g(x, y)/∂x.

3

Deterministic value gradients

The deterministic Bellman equation takes the form V (s) = r(s, a)+γV 0 (f (s, a)) for a deterministic
model s0 = f (s, a) and deterministic policy a = π(s; θ). Differentiating the equation with respect
to the state and policy yields an expression for the value gradient
Vs = rs + ra πs + γVs00 (fs + fa πs ),

(3)

γVs00 fa πθ

(4)

Vθ = ra πθ +

+

γVθ0 .

γVθ0

In eq. 4, the term
arises because the total derivative includes policy gradient contributions from
subsequent time steps (full derivation in Appendix A). For a purely model-based formalism, these
equations are used as a pair of coupled recursions that, starting from the termination of a trajectory,
proceed backward in time to compute the gradient of the value function with respect to the state
and policy parameters. Vθ0 returns the total policy gradient. When a state-value function is used
1
2

We make use of a time-varying reward function only in one problem to encode a terminal reward.
γ < 1 for the infinite-horizon case.

2

after one step in the recursion, ra πθ + γVs00 fa πθ directly expresses the contribution of the current
time step to the policy gradient. Summing these gradients over the trajectory gives the total policy
gradient. When a Q-function is used, the per-time step contribution to the policy gradient takes the
form Qa πθ .

4

Stochastic value gradients

One limitation of the gradient computation in eqs. 3 and 4 is that the model and policy must be
deterministic. Additionally, the accuracy of the policy gradient Vθ is highly sensitive to modeling
errors. We introduce two critical changes: First, in section 4.1, we transform the stochastic Bellman
equation (eq. 2) to permit backpropagating value information in a stochastic setting. This also
enables us to compute gradients along real trajectories, not ones sampled from a model, making the
approach robust to model error, leading to our first algorithm “SVG(∞),” described in section 4.2.
Second, in section 4.3, we show how value function critics can be integrated into this framework,
leading to the algorithms “SVG(1)” and “SVG(0)”, which expand the Bellman recursion for 1 and
0 steps, respectively. Value functions further increase robustness to model error and extend our
framework to infinite-horizon control.
4.1

Differentiating the stochastic Bellman equation

Re-parameterization of distributions Our goal is to backpropagate through the stochastic Bellman equation. To do so, we make use of a concept called “re-parameterization”, which permits us to
compute derivatives of deterministic and stochastic models in the same way. A very simple example
of re-parameterization is to write a conditional Gaussian density p(y|x) = N (y|µ(x), σ 2 (x)) as the
function y = µ(x) + σ(x)ξ, where ξ ∼ N (0, 1). From this point of view, one produces samples
procedurally by first sampling ξ, then deterministically constructing y. Here, we consider conditional densities whose samples are generated by a deterministic function of an input noise variable
and other conditioning variables: y = f (x, ξ), where ξ ∼ ρ(·), a fixed noise distribution. Rich
density models Rcan be expressed in this form [20, 12]. Expectations of a function g(y) become
Ep(y|x) g(y) = g(f (x, ξ))ρ(ξ)dξ.
The advantage of working with re-parameterized distributions is that we can now obtain a simple
Monte-Carlo estimator of the derivative of an expectation with respect to x:
∇x Ep(y|x) g(y) = Eρ(ξ) gy fx ≈

M
1 X
g y fx
M i=1

ξ=ξi

.

(5)

In contrast to likelihood ratio-based Monte Carlo estimators, ∇x log p(y|x)g(y), this formula makes
direct use of the Jacobian of g.
Re-parameterization of the Bellman equation We now re-parameterize the Bellman equation.
When re-parameterized, the stochastic policy takes the form a = π(s, η; θ), and the stochastic
environment the form s0 = f (s, a, ξ) for noise variables η ∼ ρ(η) and ξ ∼ ρ(ξ), respectively.
Inserting these functions into eq. (2) yields


 0

V (s) = Eρ(η) r(s, π(s, η; θ)) + γEρ(ξ) V (f (s, π(s, η; θ), ξ)) .
(6)
Differentiating eq. 6 with respect to the current state s and policy parameters θ gives


0
Vs = Eρ(η) rs + ra πs + γEρ(ξ) Vs0 (fs + fa πs ) ,


 0

0
Vθ = Eρ(η) ra πθ + γEρ(ξ) Vs0 fa πθ + Vθ .

(7)
(8)

We are interested in controlling systems with a priori unknown dynamics. Consequently, in the
following, we replace instances of f or its derivatives with a learned model f̂ .
Gradient evaluation by planning A planning method to compute a gradient estimate is to compute a trajectory by running the policy in loop with a model while sampling the associated noise
variables, yielding a trajectory τ = (s1 , η 1 , a1 , ξ 1 , s2 , η 2 , a2 , ξ 2 , . . . ). On this sampled trajectory, a
Monte-Carlo estimate of the policy gradient can be computed by the backward recursions:
3

vs = [rs + ra πs + γvs0 0 (f̂s + f̂a πs )]
vθ = [ra πθ + γ(vs0 0 f̂a πθ + vθ0 )]

η,ξ

η,ξ

,

,

(9)
(10)

where have written lower-case v to emphasize that the quantities are one-sample estimates3 , and
“ x ” means “evaluated at x”.
Gradient evaluation on real trajectories An important advantage of stochastic over deterministic models is that they can assign probability mass to observations produced by the real environment.
In a deterministic formulation, there is no principled way to account for mismatch between model
predictions and observed trajectories. In this case, the policy and environment noise (η, ξ) that produced the observed trajectory are considered unknown. By an application of Bayes’ rule, which we
explain in Appendix B, we can rewrite the expectations in equations 7 and 8 given the observations
(s, a, s0 ) as


Vs = Ep(a|s) Ep(s0 |s,a) Ep(η,ξ|s,a,s0 ) rs + ra π+ γVs00 (f̂s + f̂a πs ) ,


Vθ = Ep(a|s) Ep(s0 |s,a) Ep(η,ξ|s,a,s0 ) ra πθ + γ(Vs00 f̂a πθ + Vθ0 ) ,

(11)
(12)

where we can now replace the two outer expectations with samples derived from interaction with
the real environment. In the special case of additive noise, s0 = f̂ (s, a) + ξ, it is possible to use
a deterministic model to compute the derivatives (f̂s , f̂a ). The noise’s influence is restricted to the
gradient of the value of the next state, Vs00 , and does not affect the model Jacobian. If we consider it
desirable to capture more complicated environment noise, we can use a re-parameterized generative
model and infer the missing noise variables, possibly by sampling from p(η, ξ|s, a, s0 ).
4.2 SVG(∞)
SVG(∞) computes value gradients by backward recursions on finite-horizon trajectories. After
every episode, we train the model, f̂ , followed by the policy, π. We provide pseudocode for this in
Algorithm 1 but discuss further implementation details in section 5 and in the experiments.

Algorithm 1 SVG(∞)

Algorithm 2 SVG(1) with Replay

1: Given empty experience database D
2: for trajectory = 0 to ∞ do
3:
for t = 0 to T do
4:
Apply control a = π(s, η; θ), η ∼ ρ(η)
5:
Insert (s, a, r, s0 ) into D
6:
end for
7:
Train generative model f̂ using D
8:
vs0 = 0 (finite-horizon)
9:
vθ0 = 0 (finite-horizon)
10:
for t = T down to 0 do
11:
Infer ξ|(s, a, s0 ) and η|(s, a)
12:
vθ = [ra πθ + γ(vs0 0 f̂a πθ + vθ0 )] η,ξ

1: Given empty experience database D
2: for t = 0 to ∞ do
3:
Apply control π(s, η; θ), η ∼ ρ(η)
4:
Observe r, s0
5:
Insert (s, a, r, s0 ) into D
6:
// Model and critic updates
7:
Train generative model f̂ using D
8:
Train value function V̂ using D (Alg. 4)
9:
// Policy update
10:
Sample (sk , ak , rk , sk+1 ) from D (k ≤ t)

13:
vs = [rs + ra πs + γvs0 0 (f̂s + f̂a πs )]
14:
end for
15:
Apply gradient-based update using vθ0
16: end for

11:

w=

p(ak |sk ;θ t )
p(ak |sk ;θ k )
k
k
k

12:
Infer ξ |(s , a , sk+1 ) and η k |(sk , ak )
13:
vθ = w(ra + γ V̂s00 f̂a )πθ ηk ,ξk
14:
Apply gradient-based update using vθ
15: end for

η,ξ

4.3 SVG(1) and SVG(0)
In our framework, we may learn a parametric estimate of the expected value V̂ (s; ν) (critic) with
parameters ν. The derivative of the critic value with respect to the state, V̂s , can be used in place
of the sample gradient estimate given in eq. (9). The critic can reduce the variance of the gradient
estimates because V̂ approximates the expectation of future rewards while eq. (9) provides only a
3
In the finite-horizon formulation, the gradient calculation starts at the end of the trajectory for which the
only terms remaining in eq. (9) are vsT ≈ rsT + raT πsT . After the recursion, the total derivative of the value
function with respect to the policy parameters is given by vθ0 , which is a one-sample estimate of ∇θ J.

4

single-trajectory estimate. Additionally, the value function can be used at the end of an episode to
approximate the infinite-horizon policy gradient. Finally, eq. (9) involves the repeated multiplication
of Jacobians of the approximate model f̂s , f̂a . Just as model error can compound in forward planning,
model gradient error can compound during backpropagation. Furthermore, SVG(∞) is on-policy.
That is, after each episode, a single gradient-based update is made to the policy, and the policy
optimization does not revisit those trajectory data again. To increase data-efficiency, we construct
an off-policy, experience replay [15, 29] algorithm that uses models and value functions, SVG(1)
with Experience Replay (SVG(1)-ER). This algorithm also has the advantage that it can perform an
infinite-horizon computation.
To construct an off-policy estimator, we perform importance-weighting of the current policy distribution with respect to a proposal distribution, q(s, a):


p(a|s; θ)
V̂θ = Eq(s,a) Ep(s0 |s,a) Ep(η,ξ|s,a,s0 )
ra πθ + γ V̂s0 f̂a πθ .
(13)
q(a|s)
Specifically, we maintain a database with tuples of past state transitions (sk , ak , rk , sk+1 ). Each
proposal drawn from q is a sample of a tuple from the database. At time t, the importance-weight
p(ak |sk ;θ t )
k
w , p/q = p(a
k |sk ,θ k ) , where θ comprise the policy parameters in use at the historical time step k.
We do not importance-weight the marginal distribution over states q(s) generated by a policy; this
is widely considered to be intractable.
Similarly, we use experience replay for value function learning. Details can be found in Appendix
C. Pseudocode for the SVG(1) algorithm with Experience Replay is in Algorithm 2.
We also provide a model-free stochastic value gradient algorithm, SVG(0) (Algorithm 3 in the Appendix). This algorithm is very similar to SVG(1) and is the stochastic analogue of the recently introduced Deterministic Policy Gradient algorithm (DPG) [23, 14, 4]. Unlike DPG, instead of
 assuming

a deterministic policy, SVG(0) estimates the derivative around the policy noise Ep(η) Qa πθ η .4
This, for example, permits learning policy noise variance. The relative merit of SVG(1) versus
SVG(0) depends on whether the model or value function is easier to learn and is task-dependent.
We expect that model-based algorithms such as SVG(1) will show the strongest advantages in multitask settings where the system dynamics are fixed, but the reward function is variable. SVG(1)
performed well across all experiments, including ones introducing capacity constraints on the value
function and model. SVG(1)-ER demonstrated a significant advantage over all other tested algorithms.

5

Model and value learning

We can use almost any kind of differentiable, generative model. In our work, we have parameterized
the models as neural networks. Our framework supports nonlinear state- and action-dependent noise,
notable properties of biological actuators. For example, this can be described by the parametric
form f̂ (s, a, ξ) = µ̂(s, a) + σ̂(s, a)ξ. Model learning amounts to a purely supervised problem based
on observed state transitions. Our model and policy training occur jointly. There is no “motorbabbling” period used to identify the model. As new transitions are observed, the model is trained
first, followed by the value function (for SVG(1)), followed by the policy. To ensure that the model
does not forget information about state transitions, we maintain an experience database and cull
batches of examples from the database for every model update. Additionally, we model the statechange by s0 = f̂ (s, a, ξ) + s and have found that constructing models as separate sub-networks per
predicted state dimension improved model quality significantly.
Our framework also permits a variety of means to learn the value function models. We can use
temporal difference learning [25] or regression to empirical episode returns. Since SVG(1) is modelbased, we can also use Bellman residual minimization [3]. In practice, we used a version of “fitted”
policy evaluation. Pseudocode is available in Appendix C, Algorithm 4.

6

Experiments

We tested the SVG algorithms in two sets of experiments. In the first set of experiments (section
6.1), we test whether evaluating gradients on real environment trajectories and value function ap4

Note that π is a function of the state and noise variable.

5

Figure 1: From left to right: 7-Link Swimmer; Reacher; Gripper; Monoped; Half-Cheetah; Walker
proximation can reduce the impact of model error. In our second set (section 6.2), we show that
SVG(1) can be applied to several complicated, multidimensional physics environments involving
contact dynamics (Figure 1) in the MuJoCo simulator [28]. Below we only briefly summarize the
main properties of each environment: further details of the simulations can be found in Appendix
D and supplement. In all cases, we use generic, 2 hidden-layer neural networks with tanh activation functions to represent models, value functions, and policies. A video montage is available at
https://youtu.be/PYdL7bcn_cM.
6.1 Analyzing SVG
Gradient evaluation on real trajectories vs. planning To demonstrate the difficulty of planning
with a stochastic model, we first present a very simple control problem for which SVG(∞) easily
learns a control policy but for which an otherwise identical planner fails entirely. Our example is
based on a problem due to [16]. The policy directly controls the velocity of a point-mass “hand”
on a 2D plane. By means of a spring-coupling, the hand exerts a force on a ball mass; the ball
additionally experiences a gravitational force and random forces (Gaussian noise). The goal is to
bring hand and ball into one of two randomly chosen target configurations with a relevant reward
being provided only at the final time step.
With simulation time step 0.01s, this demands controlling and backpropagating the distal reward
along a trajectory of 1, 000 steps. Because this experiment has a non-stationary, time-dependent
value function, this problem also favors model-based value gradients over methods using value
functions. SVG(∞) easily learns this task, but the planner, which uses trajectories from the model,
shows little improvement. The planner simulates trajectories using the learned stochastic model
and backpropagates along those simulated trajectories (eqs. 9 and 10) [18]. The extremely long
time-horizon lets prediction error accumulate and thus renders roll-outs highly inaccurate, leading
to much worse final performance (c.f. Fig. 2, left).5
Robustness to degraded models and value functions We investigated the sensitivity of SVG(∞)
and SVG(1) to the quality of the learned model on Swimmer. Swimmer is a chain body with multiple
links immersed in a fluid environment with drag forces that allow the body to propel itself [5, 27].
We build chains of 3, 5, or 7 links, corresponding to 10, 14, or 18-dimensional state spaces with 2,
4, or 6-dimensional action spaces. The body is initialized in random configurations with respect to
a central goal location. Thus, to solve the task, the body must turn to re-orient and then produce an
undulation to move to the goal.
To assess the impact of model quality, we learned to control a link-3 swimmer with SVG(∞) and
SVG(1) while varying the capacity of the network used to model the environment (5, 10, or 20
hidden units for each state dimension subnetwork (Appendix D); i.e., in this task we intentionally
shrink the neural network model to investigate the sensitivity of our methods to model inaccuracy.
While with a high capacity model (20 hidden units per state dimension), both SVG(∞) and SVG(1)
successfully learn to solve the task, the performance of SVG(∞) drops significantly as model capacity is reduced (c.f. Fig. 3, middle). SVG(1) still works well for models with only 5 hidden units,
and it also scales up to 5 and 7-link versions of the swimmer (Figs. 3, right and 4, left). To compare
SVG(1) to conventional model-free approaches, we also tested a state-of-the-art actor-critic algorithm that learns a V -function and updates the policy using the TD-error δ = r + γV 0 − V as an
estimate of the advantage, yielding the policy gradient vθ = δ∇θ log π [30]. (SVG(1) and the AC
algorithm used the same code for learning V .) SVG(1) outperformed the model-free approach in
the 3-, 5-, and 7-link swimmer tasks (c.f. Fig. 3, left, right; Fig. 4, top left). In figure panels 2,
middle, 3, right, and 4, left column, we show that experience replay for the policy can improve the
data efficiency and performance of SVG(1).
5

We also tested REINFORCE on this problem but achieved very poor results due to the long horizon.

6

Hand

Cartpole

Cartpole

Figure 2: Left: Backpropagation through a model along observed stochastic trajectories is able
to optimize a stochastic policy in a stochastic environment, but an otherwise equivalent planning
algorithm that simulates the transitions with a learned stochastic model makes little progress due to
compounding model error. Middle: SVG and DPG algorithms on cart-pole. SVG(1)-ER learns the
fastest. Right: When the value function capacity is reduced from 200 hidden units in the first layer to
100 and then again to 50, SVG(1) exhibits less performance degradation than the Q-function-based
DPG, presumably because the dynamics model contains auxiliary information about the Q function.
Swimmer-3

Swimmer-5

Swimmer-3

Figure 3: Left: For a 3-link swimmer, with relatively simple dynamics, the compared methods
yield similar results and possibly a slight advantage to the purely model-based SVG(∞). Middle:
However, as the environment model’s capacity is reduced from 20 to 10 then to 5 hidden units
per state-dimension subnetwork, SVG(∞) dramatically deteriorates, whereas SVG(1) shows undisturbed performance. Right: For a 5-link swimmer, SVG(1)-ER learns faster and asymptotes at
higher performance than the other tested algorithms.
Similarly, we tested the impact of varying the capacity of the value function approximator (Fig. 2,
right) on a cart-pole. The V-function-based SVG(1) degrades less severely than the Q-functionbased DPG presumably because it computes the policy gradient with the aid of the dynamics model.
6.2 SVG in complex environments
In a second set of experiments we demonstrated that SVG(1)-ER can be applied to several challenging physical control problems with stochastic, non-linear, and discontinuous dynamics due to
contacts. Reacher is an arm stationed within a walled box with 6 state dimensions and 3 action
dimensions and the (x, y) coordinates of a target site, giving 8 state dimensions in total. In 4-Target
Reacher, the site was randomly placed at one of the four corners of the box, and the arm in a random
configuration at the beginning of each trial. In Moving-Target Reacher, the site moved at a randomized speed and heading in the box with reflections at the walls. Solving this latter problem implies
that the policy has generalized over the entire work space. Gripper augments the reacher arm with a
manipulator that can grab a ball in a randomized position and return it to a specified site. Monoped
has 14 state dimensions, 4 action dimensions, and ground contact dynamics. The monoped begins
falling from a height and must remain standing. Additionally, we apply Gaussian random noise
to the torques controlling the joints with a standard deviation of 5% of the total possible actuator
strength at all points in time, reducing the stability of upright postures. Half-Cheetah is a planar cat
robot designed to run based on [29] with 18 state dimensions and 6 action dimensions. Half-Cheetah
has a version with springs to aid balanced standing and a version without them. Walker is a planar
biped, based on the environment from [22].
Results Figure 4 shows learning curves for several repeats for each of the tasks. We found that
in all cases SVG(1) solved the problem well; we provide videos of the learned policies in the supplemental material. The 4-target reacher reliably finished at the target site, and in the tracking task
followed the moving target successfully. SVG(1)-ER has a clear advantage on this task as also borne
out in the cart-pole and swimmer experiments. The cheetah gaits varied slightly from experiment to
experiment but in all cases made good forward progress. For the monoped, the policies were able
to balance well beyond the 200 time steps of training episodes and were able to resist significantly
7

Avg. reward (arbitrary units)
Avg. reward (arbitrary units)

Swimmer-7

Monoped

Half-Cheetah

Gripper

2D-Walker

4-Target Reacher

Figure 4: Across several different domains, SVG(1)-ER reliably optimizes policies, clearly settling
into similar local optima. On the 4-target Reacher, SVG(1)-ER shows a noticeable efficiency and
performance gain relative to the other algorithms.

higher adversarial noise levels than used during training (up to 25% noise). We were able to learn
gripping and walking behavior, although walking policies that achieved similar reward levels did not
always exhibit equally good walking phenotypes.

7

Related work

Writing the noise variables as exogenous inputs to the system to allow direct differentiation with
respect to the system state (equation 7) is a known device in control theory [10, 7] where the model is
given analytically. The idea of using a model to optimize a parametric policy around real trajectories
is presented heuristically in [17] and [1] for deterministic policies and models. Also in the limit of
deterministic policies and models, the recursions we have derived in Algorithm 1 reduce to those
of [2]. Werbos defines an actor-critic algorithm called Heuristic Dynamic Programming that uses a
deterministic model to roll-forward one step to produce a state prediction that is evaluated by a value
function [31]. Deisenroth et al. have used Gaussian process models to compute policy gradients that
are sensitive to model-uncertainty [6], and Levine et al. have optimized impressive policies with the
aid of a non-parametric trajectory optimizer and locally-linear models [13]. Our work in contrast
has focused on using global, neural network models conjoined to value function approximators.

8

Discussion

We have shown that two potential problems with value gradient methods, their reliance on planning
and restriction to deterministic models, can be exorcised, broadening their relevance to reinforcement learning. We have shown experimentally that the SVG framework can train neural network
policies in a robust manner to solve interesting continuous control problems. The framework includes algorithm variants beyond the ones tested in this paper, for example, ones that combine a
value function with k steps of back-propagation through a model (SVG(k)). Augmenting SVG(1)
with experience replay led to the best results, and a similar extension could be applied to any SVG(k).
Furthermore, we did not harness sophisticated generative models of stochastic dynamics, but one
could readily do so, presenting great room for growth.

Acknowledgements We thank Arthur Guez, Danilo Rezende, Hado van Hasselt, John Schulman, Jonathan
Hunt, Nando de Freitas, Martin Riedmiller, Remi Munos, Shakir Mohamed, and Theophane Weber for helpful
discussions and John Schulman for sharing his walker model.

8

References
[1] P. Abbeel, M. Quigley, and A. Y. Ng. Using inaccurate models in reinforcement learning. In ICML, 2006.
[2] C. G. Atkeson. Efficient robust policy optimization. In ACC, 2012.
[3] L. Baird. Residual algorithms: Reinforcement learning with function approximation. In ICML, 1995.
[4] D. Balduzzi and M. Ghifary. Compatible value gradients for reinforcement learning of continuous deep
policies. arXiv preprint arXiv:1509.03005, 2015.
[5] R. Coulom. Reinforcement learning using neural networks, with applications to motor control. PhD
thesis, Institut National Polytechnique de Grenoble-INPG, 2002.
[6] M. Deisenroth and C. E. Rasmussen. Pilco: A model-based and data-efficient approach to policy search.
In (ICML), 2011.
[7] M. Fairbank. Value-gradient learning. PhD thesis, City University London, 2014.
[8] M. Fairbank and E. Alonso. Value-gradient learning. In IJCNN, 2012.
[9] I. Grondman. Online Model Learning Algorithms for Actor-Critic Control. PhD thesis, TU Delft, Delft
University of Technology, 2015.
[10] D. H. Jacobson and D. Q. Mayne. Differential dynamic programming. 1970.
[11] M. I. Jordan and D. E. Rumelhart. Forward models: Supervised learning with a distal teacher. Cognitive
science, 16(3):307–354, 1992.
[12] D. P. Kingma and M. Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
[13] S. Levine and P. Abbeel. Learning neural network policies with guided policy search under unknown
dynamics. In NIPS, 2014.
[14] T. P. Lillicrap, J. J. Hunt, A. Pritzel, N. Heess, T. Erez, Y. Tassa, D. Silver, and D. Wierstra. Continuous
control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
[15] L.-J. Lin. Self-improving reactive agents based on reinforcement learning, planning and teaching. Machine learning, 8(3-4):293–321, 1992.
[16] R. Munos. Policy gradient in continuous time. Journal of Machine Learning Research, 7:771–791, 2006.
[17] K. S. Narendra and K. Parthasarathy. Identification and control of dynamical systems using neural networks. IEEE Transactions on Neural Networks, 1(1):4–27, 1990.
[18] D. H. Nguyen and B. Widrow. Neural networks for self-learning control systems. IEEE Control Systems
Magazine, 10(3):18–23, 1990.
[19] R. Pascanu, T. Mikolov, and Y. Bengio. On the difficulty of training recurrent neural networks. In ICML,
2013.
[20] D. J. Rezende, S. Mohamed, and D. Wierstra. Stochastic backpropagation and approximate inference in
deep generative models. In ICML, 2014.
[21] Martin Riedmiller. Neural fitted q iteration–first experiences with a data efficient neural reinforcement
learning method. In Machine Learning: ECML 2005, pages 317–328. Springer, 2005.
[22] J. Schulman, S. Levine, P. Moritz, M. I. Jordan, and P. Abbeel. Trust region policy optimization. CoRR,
abs/1502.05477, 2015.
[23] D. Silver, G. Lever, N. Heess, T. Degris, D. Wierstra, and M. Riedmiller. Deterministic policy gradient
algorithms. In ICML, 2014.
[24] S. P. Singh. Learning without state-estimation in partially observable Markovian decision processes. In
ICML, 1994.
[25] Richard S Sutton. Learning to predict by the methods of temporal differences. Machine learning, 3(1):9–
44, 1988.
[26] R.S. Sutton, D. A. McAllester, S. P. Singh, and Y. Mansour. Policy gradient methods for reinforcement
learning with function approximation. In NIPS, 1999.
[27] Y. Tassa, T. Erez, and W.D. Smart. Receding horizon differential dynamic programming. In NIPS, 2008.
[28] E. Todorov, T. Erez, and Y. Tassa. Mujoco: A physics engine for model-based control. In IROS, 2012.
[29] P. Wawrzyński. A cat-like robot real-time learning to run. In Adaptive and Natural Computing Algorithms,
pages 380–390. Springer, 2009.
[30] P. Wawrzyński. Real-time reinforcement learning by sequential actor–critics and experience replay. Neural Networks, 22(10):1484–1497, 2009.
[31] P. J Werbos. A menu of designs for reinforcement learning over time. Neural networks for control, pages
67–95, 1990.

9

[32] R. J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning.
Machine learning, 8(3-4):229–256, 1992.

10

A

Derivation of recursive gradient of the deterministic value function

The use of derivatives in equation 4 is subtle, so we expand on the logic here. We first note that a change to the
policy parameters affects the immediate action as well as each future state and action. Thus, the total derivative
d
can be expanded to
dθ
X t
X dst ∂ 
da ∂
d
=
+
dθ
dθ ∂at
dθ ∂st
t>0
t≥0
 0
 X t
X dst ∂ 
da ∂
ds1 ∂
da ∂
=
+
+
+
.
dθ ∂a0
dθ ∂s1
dθ ∂at
dθ ∂st
t>1
t≥1

Let us define the operator

∇tθ


,

t0

∂
da
t0 ≥t dθ ∂at0

P

0

+

dst
∂
t0 >t dθ ∂st0

P


. The operator obeys the recursive

formula
∇tθ =



dat ∂
dst+1 ∂
+
t
dθ ∂a
dθ ∂st+1



∂
dst+1 ∂
+
t
∂a
dat ∂st+1



+ ∇t+1
.
θ

We can transform this to
∇tθ =

dat
dθ



.
+ ∇t+1
θ

The value function depends on the policy parameters V t (st ; θ). The deterministic Bellman equation can be
specified as V t (st ; θ) = r(st , at ) + γV t+1 (st+1 ; θ). Now, we can apply the operator ∇tθ :


∇tθ V t (st ; θ) = ∇tθ r(st , at ) + γV t+1 (st+1 ; θ)



 t
da
∂
dst+1 ∂
t
t
t+1 t+1
t+1
r(s , a ) + γV
(s ; θ)
=
+ ∇θ
+
dθ ∂at
dat ∂st+1
=

dat ∂
dat dst+1 ∂
r(st , at ) +
γV t+1 (st+1 ; θ) + ∇t+1
γV t+1 (st+1 ; θ).
θ
t
dθ ∂a
dθ dat ∂st+1

In the “tick” notation of the main text, this is equation 4.

B

Gradient calculation for noise models

Evaluating the Jacobian terms in equations in equations 9 and 10) may require knowledge of the noise variables
η and ξ. This poses no difficulty when we obtain trajectory samples by forward-sampling η, ξ and computing
(a, s0 ) using the policy and learned system model.
However, the same is not true when we sample trajectories from the real environment. Here, the noise variables
are unobserved and may need to be “filled in” to evaluate the Jacobians around the right arguments.
Equations 11 and 12 arise from an application of Bayes’ rule. We formally invert the forward sampling process
that generates samples from the joint distribution p(a, s0 , η, ξ|s). Instead of sampling η, ξ ∼ ρ and then
a ∼ p(a|s, η), s0 ∼ p(·|s, a, ξ), we first sample a ∼ p(a|s) and s0 ∼ p(s0 |s, a) using our policy and the real
environment. Given these data and a function g of them, we sample η, ξ ∼ p(η, ξ|s, a, s0 ) to produce
Eρ(ξ,η) Ep(a,s0 |s,ξ,η) g(s, a, s0 , ξ, η) = Ep(ξ,η,a,s0 |s) g(s, a, s0 , ξ, η)
= Ep(a,s0 |s) Ep(ξ,η|s,a,s0 ) g(s, a, s0 , ξ, η).

(14)

For example, in eq. 11, we plug in g(s, a, s0 , ξ, η) = rs + ra πs + γVs00 (f̂s + f̂a πs ).

C

Model and value learning

We found that the models exhibited the lowest per-step prediction error when the µ̂ and σ̂ vector components were computed by parallel subnetworks, producing one (µ̂, σ̂) pair for each state dimension, i.e.,
[(µ̂1 , σ̂1 ); (µ̂2 , σ̂2 ); . . . ]. (This was due to varied scaling of the dynamic range of the state dimensions.) In
the experiments in this paper, the σ̂ components were parametrized as constant biases per dimension. (As remarked in the main text, this implies that they do not contribute to the gradient calculation. However, in the
Hand environment, the planner agent forward-samples based on the learned standard deviations.)

11

Algorithm 3 SVG(0) with Replay
Algorithm 4 Fitted Policy Evaluation
1: Given empty experience database D
1: Given experience database D
2: for t = 0 to ∞ do
2: Given value function V̂ (·, ν), outer loop
3:
Apply control π(s, η; θ), η ∼ ρ(η)
time t
4:
Observe r, s0
3: ν new = ν
5:
Insert (s, a, r, s0 ) into D
4: for m = 0 to M do
6:
// Critic updates
5:
Sample (sk , ak , rk , sk+1 ) from D (k <
7:
Train value function Q̂ using D
t)
8:
// Policy update
6:
y m = rk + γ V̂ (sk+1 ; ν)
k
k k k+1
k+1
9:
Sample (s , a , r , s
,a
) from D
p(ak |sk ;θ t )
7:
w = p(a
k |sk ;θ k )
(k < t)
k
k
k
8:
∆ = ∇ν new w2 (y m − V̂ (sk ; ν new ))2
10:
Infer η |(s , a )
9:
Apply
gradient-based update to ν new
11:
vθ = Q̂a πθ ηk
using ∆
12:
Apply gradient-based update using vθ
10:
Every C updates, set ν = ν new (C =
13: end for
50)
11: end for

D

Experimental details

For a direct comparison we ran SVG(0), SVG(1), SVG(∞), and DPG without experience replay for the policy
updates since replay is not possible for SVG(∞). (All algorithms use replay for the value function updates.) We
further implemented SVG(1)-ER such that policy updates are performed at the end of each episode, following
the update of the value function, rather than following each step of interaction with the environment. For K
steps of replay for the policy we perform K gradient steps according to lines 10-14 in Algorithm 2, drawing
new data from the database D in each step. In some cases we found it helpful to apply an additional regularizer
that penalized Es [DKL [πθk−1 ||πθ ]] during each step of replay, where πθ denotes the policy at the beginning
of the update and πθk−1 the policy after k − 1 steps of replay. The expectation with respect to s is taken over
the empirical distribution of states in D. Following [30] we truncated importance weights (using a maximum
value of 5 for all experiments except for the 4-target reacher and gripper where we used 20).
Computing the policy gradient with SVG(∞) involves backpropagation through what is effectively a recurrent
network. (Each time-step involves a concatenation of two multi-layer networks for policy and dynamics model.
The full model is a chain of these pairs.) In line with findings for training standard recurrent networks, we
found that “clipping” the policy gradient improved stability. Following [19] we chose to limit the norm of the
policy gradient; i.e., we performed backpropagation for an episode as described above and then renormalized
v0

vθ0 if its norm exceeded a set threshold Vθmax : ṽθ0 = kvθ0 k min(Vθmax , kvθ0 k). We used this approach for all
θ
algorithms although it was primarily necessary for SVG(∞).
We optimized hyper-parameters separately for each algorithm by first identifying a reasonable range for the
relevant hyper-parameters and then performing a more systematic grid search. The main parameters optimized
were: learning rates for policy, value function, and model (as applicable); the number of updates per episode
for policy, value function, and model (as applicable); regularization as described above for SVG(1)-ER; Vθmax ;
the standard deviation of the Gaussian policy noise.

Hand
(
t

r (s, a) =

α1 ||a||2
t < 10s,
α2 [d(hand, 0) + d(ball, target)] t = 10s,

(15)

for Euclidean distance d(·, ·).

Swimmer r(s, a) = α1 r̂goal · vc.o.m + α2 ||a||2 , where r̂goal is a unit vector pointing from the nose to the
goal.
For the MuJoCo environment problems, we provide .xml task descriptions.

Discount factors Hand: 1.0; Swimmer: 0.995; Reacher: 0.98; Gripper: 0.98; Hopper: 0.95; Cheetah: 0.98;
Walker: 0.98

12

Table 1: Sizes of Network Hidden Layers.
TASK
H AND
C ARTPOLE
S WIMMER 3
S WIMMER 5
S WIMMER 7
R EACHER
M ONOPED
C HEETAH

P OLICY
100/100
100/100
50/50
100/100
100/100
100/100
100/100
100/100

VALUE F UNCTION
N/A
200/100†
200/100
200/100
200/100
400/200
400/200
400/200

∗

M ODEL∗
20/20
20/20
20/20†
20/20
40/40
40/40
50/50
40/40

We use one sub-network of this many hidden units per state-dimension. † With the exception of the results in
Figures 2 and 3, where the sizes are given.

13

