Chapter 11 · Sutton & Barto

Off-policy methods with approximation

Learning about one policy from data generated by another worked well with tables. Combine it with function approximation and bootstrapping, and the weights can grow without bound, even on a tiny problem with exact features. This page reproduces the classic counterexample, explains why it happens, and shows a gradient-TD method that does converge.

01Semi-gradient off-policy TD

The simplest extension of off-policy learning to approximation is to multiply the semi-gradient TD update by the per-step importance-sampling ratio ρt = π(At|St) / b(At|St):

Semi-gradient off-policy TD(0)w ← w + α ρt δt ∇v̂(St, w),   δt = Rt+1 + γ v̂(St+1, w) − v̂(St, w)

This fixes the targets, which now have the right expected value under π. What it does not fix is the distribution of updates. States are updated as often as b visits them, not π, and the on-policy distribution was exactly what chapter 9's convergence guarantees relied on.

02Worked example: Baird's counterexample

Seven states, all rewards zero, γ = 0.99, so the true value of every state is 0. Each state has two actions. Dashed moves to one of the six upper states at random. Solid moves to the lower state 7. The behaviour policy picks dashed with probability 6/7 and solid with 1/7, so it visits all seven states equally often. The target policy π always picks solid.

The value estimate is linear with 8 weights. Upper state i has v̂ = 2wi + w8, and state 7 has v̂ = w7 + 2w8. The features are linearly independent, so they can represent any value function, including the true one (w = 0). The approximation is not the problem. Start from w = (1, 1, 1, 1, 1, 1, 10, 1).

Baird's counterexample

step 0 · √VE – · ‖w‖ –

The MDP (current estimates v̂ inside each state)

dashed: to a random upper state (b 6/7, π 0)solid: to state 7 (b 1/7, π 1)

Weights

w₁ … w₆w₇w₈

Errors (true v = 0)

√VE√PBE

What to try

03The deadly triad

Instability arises whenever three ingredients are combined:

Any two are safe. Drop function approximation and you have tabular Q-learning. Drop bootstrapping and you have Monte Carlo with importance sampling, which is high-variance but stable. Drop off-policy training and semi-gradient TD converges. All three together, as in Baird's example, can diverge. Planning, and learning about many policies in parallel, need off-policy updates, and large problems need approximation. Bootstrapping is the most tempting to give up, but it is usually what makes learning fast.

04Linear value-function geometry

To find a better objective, picture value functions as vectors with one entry per state, and the representable ones (Xw) as a subspace. Distance is measured with weights μ(s). Three errors matter:

Projected Bellman error, linear casePBE(w) = ( 𝔼b[ρ δ x] )⊤ ( 𝔼[x x⊤] )−1 ( 𝔼b[ρ δ x] )

In Baird's example the features span every value function, so Π is the identity and PBE = BE. That is why the chart above plots a single Bellman-error curve.

05Gradient-TD methods

The BE itself is not learnable from data: two MDPs can produce identical observable data yet have different Bellman errors. The PBE is learnable, and true stochastic gradient descent on it is possible. Its gradient is a product of three expectations, and the trick is to learn the middle two as a separate weight vector v ≈ 𝔼[xx⊤]−1𝔼[ρδx], by least squares, on a faster timescale:

TDC (TD with gradient correction)v ← v + β ρ (δ − v⊤x) x,   w ← w + α ρ ( δ x − γ x′ (x⊤v) )

The first term of the w update is ordinary off-policy TD. The second is the correction that stops divergence. TDC and its sibling GTD2 cost O(d) per step, about twice as much as TD, and are guaranteed to converge to the PBE minimum under linear approximation with any behaviour policy.

06Emphatic TD and variance

Another fix is to correct the distribution of updates directly. Emphatic TD reweights each update by an "emphasis" that accumulates importance-sampling ratios along the trajectory, so states are effectively updated as if visited on-policy. It is stable in expectation on Baird's example, but its variance is so high that the sampled version is hard to use there.

That points to the chapter's broader lesson: in off-policy learning, the variance of importance sampling is as serious a problem as instability. Tools that help include tree-backup and Retrace-style targets, which avoid ratios or truncate them; weighted importance sampling; and keeping the target and behaviour policies close together. Off-policy learning with approximation is still an active research area.