Search

Search papers and lessons

High-Dimensional Continuous Control Using Generalized Advantage Estimation

John Schulman, Philipp Moritz, Sergey Levine et al. · 2015

Schulman et al. (2015) pair a low-variance advantage estimator with trust-region updates, so simulated 3D robots learn to walk and stand up from raw joint data.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Reinforcement learning
  • Calculus
  • Linear algebra
  • Inference
  • ReadReady to readNot yet

TL;DR

Policy gradient methods teach a control policy by trying actions and nudging the policy toward the ones that paid off. They are simple and work with neural networks, but they need very many trials, and their learning is often unstable. Schulman and colleagues attacked both problems. They reduce the noise in the learning signal with a new estimator, the generalized advantage estimator, which has one knob that trades bias against variance. They also limit how far the policy and the value function may change in one update. With these two changes, neural network controllers learned to run and balance on simulated 3D bipedal and quadrupedal robots, and to get up from lying on their backs, using only the joint positions and velocities as input. The bipedal runs needed roughly 1 to 2 weeks of simulated experience.

Builds on: Policy Gradient, Generalized Advantage Estimation (GAE), Trust Region Policy Optimization (TRPO) · Leads to: Proximal Policy Optimization (PPO), Learning quadrupedal locomotion over challenging terrain

Why it mattered

The paper is one of the standard references for training continuous-control policies with on-policy reinforcement learning. The estimator it introduces, GAE, became the default advantage estimator in many later policy gradient systems, and the paper's experiments on MuJoCo locomotion tasks set a common benchmark. The paper has about 5,400 citations on Semantic Scholar. The direct successor, proximal policy optimization, replaces the trust-region step with a simpler clipped objective but keeps the same advantage estimate, so anyone who trains a robot or a language model with PPO-style updates is using the ideas introduced here.

The problem

Suppose a simulated robot receives a reward for moving forward and a penalty for wasting energy. Each episode yields one number, the total reward, but thousands of joint torques contributed to it. The learner has to decide which torques deserved credit. This is the credit assignment problem, and it has two consequences.

  1. Variance. If the learning signal for each action is the full return from that moment on, it depends on many random later events. The gradient estimate is then very noisy, and it needs many episodes to average out the noise.
  2. Stability. Estimators with less noise often lean on a learned value function. If that function is wrong, the estimate is biased, and a biased step can make the policy worse. Large policy steps make it worse faster.

The paper asks for an estimator of the advantage, that is, how much better an action was than the policy's usual behaviour, which is accurate enough to be useful and smooth enough to learn from, plus an update rule that does not jump too far in one step.

How it works

The method runs in batches. Here is one iteration, in the order the pipeline runs.

  1. Collect. Run the current policy πθ\pi_{\theta} in the simulator until a fixed number of timesteps NN is reached. The paper uses 50,000 timesteps per batch for bipedal walking and 200,000 for the quadruped and for standing up.
  2. Score each step with the value function. For every timestep tt, compute the temporal-difference residual δt=rt+γV(st+1)−V(st)\delta_t = r_t + \gamma V(s_{t+1}) - V(s_t), using the current value network VV. This residual is a one-step guess of how much better the action was than expected.
  3. Blend the residuals. Combine the residuals of the following steps with weights that shrink geometrically. This gives the advantage estimate A^t\hat{A}_t. Here λ\lambda controls how far ahead the estimator looks.
  4. Update the policy. Form the policy gradient from the A^t\hat{A}_t values, then take a trust-region step, which changes the policy only as much as a fixed budget of divergence allows.
  5. Update the value function. Fit VV to the observed discounted returns, again with a trust-region step, so the next batch gets better residuals.
  6. Repeat. Discard the batch and collect a new one with the updated policy.

Tiny trace. Take three timesteps with rewards r0=1r_0 = 1, r1=0r_1 = 0, r2=2r_2 = 2, value estimates V(s0)=0.5V(s_0) = 0.5, V(s1)=0.8V(s_1) = 0.8, V(s2)=1.0V(s_2) = 1.0, and V(s3)=0V(s_3) = 0 at the end. Use γ=1\gamma = 1 and λ=0.5\lambda = 0.5 for simplicity. Step 2 gives δ0=1+0.8−0.5=1.3\delta_0 = 1 + 0.8 - 0.5 = 1.3, δ1=0+1.0−0.8=0.2\delta_1 = 0 + 1.0 - 0.8 = 0.2, δ2=2+0−1.0=1.0\delta_2 = 2 + 0 - 1.0 = 1.0. Step 3 gives A^0=1.3+0.5×0.2+0.25×1.0=1.65\hat{A}_0 = 1.3 + 0.5 \times 0.2 + 0.25 \times 1.0 = 1.65. The first action looked better than the value function expected, and the estimate says so. Check: the same numbers with λ=1\lambda = 1 would give 2.52.5, which is the total reward 33 minus the baseline V(s0)=0.5V(s_0) = 0.5.

The diagram shows where each piece sits.

flowchart LR
  A["Batch of rollouts"] --> B["TD residuals delta_t using V"]
  B --> C["GAE advantages A_t with lambda"]
  C --> D["Policy gradient, trust-region step on theta"]
  C --> E["Value fit, trust-region step on phi"]
  D --> F["New policy"]
  E --> G["New value function"]
  F --> A
  G --> A

The math

A policy gradient estimator has the form

g^=1N∑n=1N∑tA^t n ∇θlog⁡πθ(at n∣st n)\hat{g} = \frac{1}{N}\sum_{n=1}^{N}\sum_{t}\hat{A}_t^{\,n}\,\nabla_{\theta}\log\pi_{\theta}(a_t^{\,n}\mid s_t^{\,n})

where nn indexes trajectories in the batch, θ\theta holds the policy parameters, and ∇θlog⁡πθ\nabla_{\theta}\log\pi_{\theta} is the score that says how to make the sampled action more likely. The paper's question is which A^t\hat{A}_t to use.

Step 1 in symbols: the residual

δtV=rt+γV(st+1)−V(st)\delta_t^{V} = r_t + \gamma V(s_{t+1}) - V(s_t)

Here rtr_t is the reward, γ\gamma is a discount between 0 and 1, and VV is the value estimate. If VV were exact, the expected residual would equal the advantage. Otherwise it is biased but has low variance.

Step 2 in symbols: the kk-step estimators

Summing kk residuals telescopes into a kk-step return minus a baseline:

A^t(k)=∑l=0k−1γlδt+lV=−V(st)+∑l=0k−1γlrt+l+γkV(st+k)\hat{A}_t^{(k)} = \sum_{l=0}^{k-1}\gamma^l \delta_{t+l}^{V} = -V(s_t) + \sum_{l=0}^{k-1}\gamma^l r_{t+l} + \gamma^k V(s_{t+k})

Large kk means less bias from VV and more variance from the rewards. Small kk means the reverse.

Step 3 in symbols: the exponential blend

Weight the kk-step estimators by (1−λ)λk−1(1-\lambda)\lambda^{k-1} and sum. The sum collapses to

A^tGAE(γ,λ)=∑l=0∞(γλ)l δt+lV\hat{A}_t^{\mathrm{GAE}(\gamma,\lambda)} = \sum_{l=0}^{\infty}(\gamma\lambda)^l\,\delta_{t+l}^{V}

Two special cases bracket the family. At λ=0\lambda = 0 you get the one-step residual δtV\delta_t^{V}, which has the least variance and the most bias. At λ=1\lambda = 1 you get the discounted return minus V(st)V(s_t). It does not depend on VV's errors, so it has no bias from VV, but it is noisy. (With γ<1\gamma \lt 1 it still carries the bias that the discount introduces, as discussed below.) Values in between trade one for the other. The paper's analysis says γ\gamma also introduces bias regardless of how good VV is, while λ\lambda introduces bias only through errors in VV. That is why the best λ\lambda found was usually much lower than the best γ\gamma.

Step 4 in symbols: the trust-region policy step

The policy update solves

min⁡θ  Lθold(θ)subject toDˉKL(πθold,πθ)≤ϵ\min_{\theta}\; L_{\theta_{\mathrm{old}}}(\theta) \quad \text{subject to} \quad \bar{D}_{\mathrm{KL}}(\pi_{\theta_{\mathrm{old}}}, \pi_{\theta}) \le \epsilon

with Lθold(θ)=1N∑nπθ(an∣sn)πθold(an∣sn)A^nL_{\theta_{\mathrm{old}}}(\theta) = \frac{1}{N}\sum_n \frac{\pi_{\theta}(a_n\mid s_n)}{\pi_{\theta_{\mathrm{old}}}(a_n\mid s_n)}\hat{A}_n. The constraint limits the average KL divergence between the old and new policies. The paper solves it approximately with conjugate gradient, which needs only products of the Fisher matrix (a matrix that measures how sensitive the policy's output is to small parameter changes) with vectors.

Step 5 in symbols: the value target

The value network is fitted to the discounted return V^t=∑l=0∞γlrt+l\hat{V}_t = \sum_{l=0}^{\infty}\gamma^l r_{t+l}, under a similar trust region that keeps the new value function within a fixed average distance of the old one.

Results

The paper reports learning curves, not a single headline score, and the parameter sweeps are the main evidence.

  • Cart-pole, 21 seeds. Batches of 20 trajectories, each up to 1,000 steps. The best performance came at intermediate values, with γ\gamma between 0.96 and 0.99 and λ\lambda between 0.92 and 0.99. Setting λ=0\lambda = 0 was clearly worse.
  • 3D bipedal locomotion, 9 seeds. The humanoid model has 33 state dimensions and 10 actuators. The best settings were γ\gamma between 0.99 and 0.995 and λ\lambda between 0.96 and 0.99. After 1,000 iterations the paper describes a fast, smooth and stable gait.
  • Quadruped locomotion and standing up, 5 seeds each. The quadruped model has 29 state dimensions and 8 actuators. The best quadruped results used a value function with λ=0.96\lambda = 0.96. For standing up, the value function always helped, and λ=0.96\lambda = 0.96 and λ=1\lambda = 1 gave about the same result.

What these numbers mean. The same network size and the same method worked across three different robots, which is evidence that the estimator is not tuned to one body. Choosing an intermediate λ\lambda between about 0.9 and 0.99 was the most reliable rule the paper found.

The limits. All experiments are in simulation, and the bipedal runs used about 1 to 2 weeks of simulated time. The parameters γ\gamma and λ\lambda were tuned by sweeping, not learned. The authors note that the link between value error and policy-gradient error is still open, so there is no formula that tells you the best λ\lambda in advance.

Reading guide

Read the paper in this order, with the lesson it depends on.

Check yourself

QuestionRecall: what is the name of the knob that trades bias for variance in the generalized advantage estimator, and what does a value of 0 give?Show answer

The knob is λ\lambda. At λ=0\lambda = 0 the estimator is the one-step residual δt=rt+γV(st+1)−V(st)\delta_t = r_t + \gamma V(s_{t+1}) - V(s_t). It has low variance and the most bias when VV is inaccurate.

QuestionCompute: with γ=1\gamma = 1, λ=0.5\lambda = 0.5, and residuals δ0=2\delta_0 = 2, δ1=1\delta_1 = 1, δ2=4\delta_2 = 4, what is A^0\hat{A}_0?Show answer

A^0=δ0+λδ1+λ2δ2=2+0.5×1+0.25×4=2+0.5+1=3.5\hat{A}_0 = \delta_0 + \lambda\delta_1 + \lambda^2\delta_2 = 2 + 0.5 \times 1 + 0.25 \times 4 = 2 + 0.5 + 1 = 3.5.

QuestionWhy: why is the one-step residual biased when the value function is wrong, while the raw discounted return is not?Show answer

The residual δt=rt+γV(st+1)−V(st)\delta_t = r_t + \gamma V(s_{t+1}) - V(s_t) uses VV at two states, so any error in VV passes straight into the estimate. The raw return uses only sampled rewards, so it does not depend on VV at all, but its variance is larger because it sums many random rewards.

QuestionA researcher picks λ=1\lambda = 1 and γ=0.99\gamma = 0.99 for a new robot with a poor value function. What should they expect, and what does the paper suggest?Show answer

With λ=1\lambda = 1 the estimator is the discounted return minus the baseline. It does not depend on the value function's quality, though γ=0.99\gamma = 0.99 still adds some bias, and its variance is high, so learning may be slow and noisy. The paper's sweeps suggest an intermediate λ\lambda around 0.9 to 0.99 usually works best, because it reduces variance while keeping bias from an inaccurate value function small.

Sources

Read the full paper

John Schulman, Philipp Moritz, Sergey Levine et al., 2015. arXiv:1506.02438