Hyoungseo Son
Reinforcement Learning Theory
Contents · Reinforcement Learning Theory

Part 1 · Bellman & Value Iteration

Part 2 · Policy Gradients

Part 3 · Trust Regions

Part 4 · Actor-Critic

  • Actor-Critic and Advantage Estimation

Part 4 · Actor-Critic

Actor-Critic and Advantage Estimation

The policy gradient needs one number per action: how much better was ata_t than the policy's average at sts_t. The raw Monte Carlo return answers this but with huge variance. Actor-critic learns a value function to serve as a baseline, and Generalized Advantage Estimation turns that baseline into a tunable dial between a low-variance biased estimate and a high-variance unbiased one.

The advantage function and baselines

The policy gradient can be written with any per-step weight Ψt\Psi_t,

θJ(θ)=Eτπθ ⁣[tθlogπθ(atst)Ψt].\nabla_\theta J(\theta) = \mathbb{E}_{\tau\sim\pi_\theta}\!\left[\sum_t \nabla_\theta \log\pi_\theta(a_t\mid s_t)\,\Psi_t\right].

Subtracting a state-only baseline b(st)b(s_t) from Ψt\Psi_t leaves the expectation unchanged, because at each state

Eaπ ⁣[θlogπθ(as)b(s)]=b(s)aθπθ(as)=b(s)θ1=0.\mathbb{E}_{a\sim\pi}\!\big[\nabla_\theta\log\pi_\theta(a\mid s)\,b(s)\big] = b(s)\sum_a \nabla_\theta\pi_\theta(a\mid s) = b(s)\,\nabla_\theta 1 = 0 .

The variance-reducing choice is b(s)=Vπ(s)b(s)=V^\pi(s), which turns the weight into the advantage1

Aπ(s,a)=Qπ(s,a)Vπ(s),Eaπ ⁣[Aπ(s,a)]=0.A^\pi(s,a) = Q^\pi(s,a) - V^\pi(s), \qquad \mathbb{E}_{a\sim\pi}\!\big[A^\pi(s,a)\big] = 0 .

It measures how much action aa beats the state's average, and it is centered at zero, so good actions get pushed up and bad ones down.

Actor-critic: the critic is the baseline

The actor is the policy πθ\pi_\theta; the critic is a learned VϕVπV_\phi \approx V^\pi, fit by regressing on returns or TD targets. The actor update uses the critic to form an advantage estimate A^t\hat A_t,

θJ(θ)E ⁣[tθlogπθ(atst)A^t].\nabla_\theta J(\theta) \approx \mathbb{E}\!\left[\sum_t \nabla_\theta \log\pi_\theta(a_t\mid s_t)\,\hat A_t\right].

The critic slashes variance relative to the raw return. The price is bias: when VϕVπV_\phi \ne V^\pi, that error leaks into A^t\hat A_t.

The TD error estimates the advantage

The one-step temporal-difference error is

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

If the critic is exact, V=VπV = V^\pi, then conditioning on (st,at)(s_t,a_t),

E[δtst,at]=E[rt+γVπ(st+1)st,at]Qπ(st,at)Vπ(st)=Aπ(st,at).\mathbb{E}\big[\delta_t \mid s_t, a_t\big] = \underbrace{\mathbb{E}\big[r_t + \gamma V^\pi(s_{t+1}) \mid s_t,a_t\big]}_{Q^\pi(s_t,a_t)} - V^\pi(s_t) = A^\pi(s_t,a_t).

So δt\delta_t is an unbiased one-sample estimate of the advantage, using only the current reward and one bootstrapped value. If the critic is wrong, δt\delta_t inherits its bias.

Generalized Advantage Estimation

Summing TD errors gives the kk-step advantage estimator

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

Small kk leans on the bootstrap V(st+k)V(s_{t+k}): low variance, high bias. Large kk leans on sampled rewards: high variance, low bias. GAE is their exponentially weighted average with decay λ\lambda,1

A^tGAE(γ,λ)=(1λ)k=1λk1A^t(k)=l=0(γλ)lδt+l,\hat A_t^{\text{GAE}(\gamma,\lambda)} = (1-\lambda)\sum_{k=1}^{\infty} \lambda^{k-1}\,\hat A_t^{(k)} = \sum_{l=0}^{\infty} (\gamma\lambda)^l\,\delta_{t+l},

which collapses to a one-line backward recursion, A^t=δt+γλA^t+1\hat A_t = \delta_t + \gamma\lambda\,\hat A_{t+1}. The two ends are the familiar estimators:

λ=0: A^t=δt(TD(0), low variance / biased),λ=1: A^t=l0γlrt+lV(st)(Monte Carlo, unbiased / high variance).\lambda = 0:\ \hat A_t = \delta_t \quad(\text{TD(0), low variance / biased}), \qquad \lambda = 1:\ \hat A_t = \sum_{l\ge 0}\gamma^l r_{t+l} - V(s_t)\quad(\text{Monte Carlo, unbiased / high variance}).

The weight (γλ)l(\gamma\lambda)^l decays with an effective horizon 1/(1γλ)1/(1-\gamma\lambda) steps: that is how far downstream reward is trusted before the critic takes over.

Worked example

Take a six-step episode with γ=0.9\gamma = 0.9, a single reward r=(0,0,0,0,0,1)r = (0,0,0,0,0,1) at the end, and an imperfect critic V=(0.4,0.5,0.6,0.7,0.8,0.9)V = (0.4,0.5,0.6,0.7,0.8,0.9) with V(terminal)=0V(\text{terminal}) = 0. The TD errors δt=rt+γV(st+1)V(st)\delta_t = r_t + \gamma V(s_{t+1}) - V(s_t) are

δ=(0.05, 0.04, 0.03, 0.02, 0.01, 0.10),\delta = \big(0.05,\ 0.04,\ 0.03,\ 0.02,\ 0.01,\ 0.10\big),

for instance δ0=0.9(0.5)0.4=0.05\delta_0 = 0.9(0.5) - 0.4 = 0.05 and δ5=1+0.9(0)0.9=0.10\delta_5 = 1 + 0.9(0) - 0.9 = 0.10. Now read the advantage at t=0t=0 through the dial A^0=l=05(γλ)lδl\hat A_0 = \sum_{l=0}^{5}(\gamma\lambda)^l \delta_l:

λ=0:A^0=δ0=0.050,\lambda = 0:\quad \hat A_0 = \delta_0 = 0.050 , λ=0.5 (γλ=0.45):A^0=0.05+0.45(0.04)+0.452(0.03)++0.455(0.10)=0.078,\lambda = 0.5\ (\gamma\lambda = 0.45):\quad \hat A_0 = 0.05 + 0.45(0.04) + 0.45^2(0.03) + \cdots + 0.45^5(0.10) = 0.078 , λ=1 (γλ=0.9):A^0=l=050.9lδl=0.950.4=0.5900.4=0.190.\lambda = 1\ (\gamma\lambda = 0.9):\quad \hat A_0 = \sum_{l=0}^{5}0.9^l\,\delta_l = 0.9^5 - 0.4 = 0.590 - 0.4 = 0.190 .

At λ=1\lambda = 1 the sum telescopes to the Monte Carlo return minus the baseline, confirming the identity. The effective horizon grows from 1/(10)=11/(1-0)=1 step through 1/(10.45)=1.821/(1-0.45)=1.82 to 1/(10.9)=101/(1-0.9)=10: as λ\lambda rises, the eventual reward at step 55 flows further back into A^0\hat A_0, climbing from 0.050.05 (the critic's local bootstrap) to 0.1900.190 (the actual discounted return).

TD error, GAE advantage, and the bias-variance dialinteractive
0012345step t
δ ₜ (TD error)Aₜ (GAE)±1σ over noisy returns
A₀(λ)
0.078
eff. horizon 1/(1−γλ)
1.82
std(A₀) · variance
0.100
|A₀(λ)−A₀(1)| · bias
0.112

λ = 0 is TD(0): short horizon, low variance, biased by the critic. λ = 1 is Monte Carlo: unbiased, but the whiskers blow up. Slide λ to trade one for the other.

The six-step episode above: muted bars are the TD errors δ_t, accent bars are the GAE advantages A_t, and the yellow whiskers are ±1σ of A_t across noisy returns. At λ = 0 the accent bars equal the TD errors and the whiskers are short. Raise λ toward 1 and A_t swells to the Monte Carlo return while the whiskers blow up. The readouts split the tradeoff: bias |A₀(λ)−A₀(1)| falls to zero as the estimate becomes unbiased, while std(A₀) and the effective horizon climb. Push σ up to make the variance dominate.

Reading the two readouts together is the whole story: bias shrinks and variance grows along one knob. This is the dial inside PPO, which computes its clipped-objective advantages with GAE at roughly γ0.99\gamma \approx 0.99 and λ0.95\lambda \approx 0.95, buying most of Monte Carlo's low bias while the critic keeps the variance in check.1 The same value baseline that made the plain policy gradient usable2 becomes, through λ\lambda, a continuous choice about how far to trust the world versus the critic.

Footnotes

  1. Schulman et al., High-Dimensional Continuous Control Using Generalized Advantage Estimation (2016). 2 3

  2. Sutton & Barto, Reinforcement Learning: An Introduction (2018).