Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Compatible Features & Two-Timescale Actor–Critic

When a critic leaves the gradient unbiased, and why actor–critic converges.

A critic that approximates QπQ^\pi badly would seem to doom the actor to a wrong gradient. Not necessarily: if the critic's features are the actor's own score functions and its weights solve a least-squares problem, the gradient is exact, and the weights themselves are the natural gradient. This lesson proves both facts, then turns to the stochastic-approximation theory that explains why an actor and a critic learning at the same time converge, and to what finite-time analyses add.

What you’ll learn

  • State and prove the compatible function approximation theorem, and explain why only the projection of QπQ^\pi onto the span of the score functions matters.
  • Show that compatible critic weights are the natural gradient F−1∇JF^{-1}\nabla J, and describe natural actor–critic algorithms.
  • State the two-timescale stochastic approximation theorem and the Konda–Tsitsiklis convergence result for actor–critic, with their conditions.
  • Summarize finite-time sample-complexity results for actor–critic and what they assume.

When a critic leaves the gradient exact

Write ψ(s,a)=∇log⁡π(a∣s)\boldsymbol\psi(s,a)=\nabla\log\pi(a\mid s) for the score and ν(s,a)=dμπ(s) π(a∣s)\nu(s,a)=d^\pi_\mu(s)\,\pi(a\mid s) for the on-policy state–action distribution, with inner product ⟨f,g⟩ν=∑s,aν(s,a)f(s,a)g(s,a)\langle f,g\rangle_\nu=\sum_{s,a}\nu(s,a)f(s,a)g(s,a). The discounted policy gradient theorem is then a set of inner products:

∂J∂θi=11−γ ⟨Qπ,ψi⟩ν,i=1,…,n\frac{\partial J}{\partial\theta_i}=\frac{1}{1-\gamma}\,\big\langle Q^\pi,\psi_i\big\rangle_\nu,\qquad i=1,\dots,n

Konda and Tsitsiklis drew the consequence. QπQ^\pi lives in a space with one dimension per state–action pair, yet the gradient sees it only through its inner products with the nn score functions, one per policy parameter. Any function with the same projection onto Ψ=span⁡(ψ1,…,ψn)\Psi=\operatorname{span}(\psi_1,\dots,\psi_n) gives the same gradient, so a critic need only learn that projection, a much smaller object.

DerivationProof: the normal equations
  1. Eν[(Qπ(S,A)−w⋆⊤ψ(S,A)) ψ(S,A)]=0\E_\nu\Big[\big(Q^\pi(S,A)-\mathbf w^{\star\top}\boldsymbol\psi(S,A)\big)\,\boldsymbol\psi(S,A)\Big]=\mathbf 0

    At the minimizer the residual is orthogonal to every feature, the normal equations of least squares:

  2. Eν[fw⋆ ψ]=Eν[Qπ ψ]=(1−γ) ∇J\E_\nu\big[f_{\mathbf w^\star}\,\boldsymbol\psi\big]=\E_\nu\big[Q^\pi\,\boldsymbol\psi\big]=(1-\gamma)\,\nabla J

    Rearranged, they say the critic and QπQ^\pi have the same inner products with the scores. The critic may be wrong everywhere; its error is orthogonal to the only directions the gradient looks at. ■\blacksquare

Three consequences.

  • A compatible critic estimates advantages. Because EA∼π[ψ(s,A)]=0\E_{A\sim\pi}[\boldsymbol\psi(s,A)]=\mathbf 0, every fwf_{\mathbf w} has mean zero under the policy in each state. It can represent advantage-like functions but not Vπ(s)V^\pi(s), so its least-squares fit to QπQ^\pi is also its fit to AπA^\pi, and in practice it is paired with a separate state-value function for bootstrapping and baselines.
  • For a Gaussian policy it is local and linear. With mean mθ(s)m_{\boldsymbol\theta}(s) and fixed σ\sigma, ψ=∇θmθ(s) (a−mθ(s))/σ2\boldsymbol\psi=\nabla_{\boldsymbol\theta}m_{\boldsymbol\theta}(s)\,\big(a-m_{\boldsymbol\theta}(s)\big)/\sigma^2, so fwf_{\mathbf w} is linear in a−m(s)a-m(s): a first-order model of the advantage around the mean action, the object the deterministic policy gradient differentiates.
  • TD learning does not minimize this error. The theorem needs the least-squares fit of QπQ^\pi under ν\nu, which Monte Carlo regression on samples from ν\nu provides. TD(λ) with λ<1\lambda<1 converges elsewhere, to the fixed point of a projected Bellman equation (The Projected Bellman Equation & LSTD). The gap returns in the convergence theorems below.

Compatible weights are the natural gradient

The normal equations say more. Expanded, they read Eν[ψψ⊤] w⋆=Eν[ψ Qπ]\E_\nu[\boldsymbol\psi\boldsymbol\psi^\top]\,\mathbf w^\star=\E_\nu[\boldsymbol\psi\,Q^\pi], and the matrix on the left is the policy's Fisher information averaged over states.

DerivationA two-action check
  1. F=p(1−p)2+(1−p)p2=p(1−p),∇J=p(1−p)(Q(a1)−Q(a2))F=p(1-p)^2+(1-p)p^2=p(1-p),\qquad\nabla J=p(1-p)\big(Q(a_1)-Q(a_2)\big)

    One state, two actions, π(a1)=p=σ(θ)\pi(a_1)=p=\sigma(\theta), values Q(a1)Q(a_1) and Q(a2)Q(a_2). The scores are ψ(a1)=1−p\psi(a_1)=1-p and ψ(a2)=−p\psi(a_2)=-p, so

  2. fw⋆(a1)=(1−p)(Q(a1)−Q(a2))=Q(a1)−Vπ,fw⋆(a2)=−p (Q(a1)−Q(a2))=Q(a2)−Vπf_{w^\star}(a_1)=(1-p)\big(Q(a_1)-Q(a_2)\big)=Q(a_1)-V^\pi,\qquad f_{w^\star}(a_2)=-p\,\big(Q(a_1)-Q(a_2)\big)=Q(a_2)-V^\pi

    Hence w⋆=F−1∇J=Q(a1)−Q(a2)w^\star=F^{-1}\nabla J=Q(a_1)-Q(a_2), whatever pp, and the fitted critic is exactly the advantage Aπ(a)=Q(a)−VπA^\pi(a)=Q(a)-V^\pi:

  3. The plain gradient shrinks like p(1−p)p(1-p) as the policy becomes deterministic; the natural gradient does not, because dividing by the Fisher information undoes exactly that shrinkage. For a tabular softmax policy the same computation gives w⋆\mathbf w^\star equal to the advantages up to a constant in each state: the multiplicative-weights update of Global Convergence of Policy Gradients.

Natural actor–critic. Peters and Schaal (2008) built natural actor–critic algorithms on this identity: estimate the compatible weights by least squares, with LSTD-Q(λ) or, in the episodic version eNAC, by regressing returns on summed scores, and step the actor along them. Bhatnagar, Sutton, Ghavamzadeh and Lee (2009) gave four incremental natural actor–critic algorithms with two-timescale convergence proofs for the average-reward criterion. Thomas (2014) later showed that several discounted natural actor–critics, including NAC-LSTD and eNAC, drop the factor γt\gamma^t and so are biased estimates of the discounted natural gradient (The Policy Gradient Theorem in Depth).

Check your understanding

Why is a compatible critic fw=w⊤ψf_{\mathbf w}=\mathbf w^\top\boldsymbol\psi usually paired with a separate state-value function?

  1. Because compatible features are too expensive to compute
  2. Because the compatible critic gives a biased gradient
  3. Because fwf_{\mathbf w} has mean zero under the policy in every state, so it can represent advantages but not Vπ(s)V^\pi(s), which bootstrapped targets and baselines need
  4. Because the natural gradient needs two critics
Show the answer

C. Because fwf_{\mathbf w} has mean zero under the policy in every state, so it can represent advantages but not Vπ(s)V^\pi(s), which bootstrapped targets and baselines need

∑aπ(a∣s) w⊤ψ(s,a)=w⊤0=0\sum_a\pi(a\mid s)\,\mathbf w^\top\boldsymbol\psi(s,a)=\mathbf w^\top\mathbf 0=0. The compatible critic therefore spans only advantage-like functions. A TD critic needs values to bootstrap from, and those come from a separate V(s)V(s), which, being a function of the state alone, does not change the gradient.

Two timescales

The compatible-features theorem assumes the critic has converged for the current policy. In an actor–critic both learn at once. Two-timescale stochastic approximation makes the intuitive fix rigorous: let the critic run on a faster timescale (the ODE method behind it is introduced in Convergence of TD: Stochastic Approximation).

Seen from the slow actor, the critic has always just converged, so the actor follows g(w⋆(θ),θ)g\big(\mathbf w^\star(\boldsymbol\theta),\boldsymbol\theta\big); seen from the fast critic, the actor stands still. For actor–critic the slow ODE is approximately gradient ascent on a non-concave objective, which has no globally stable equilibrium in general, so the conclusions weaken to statements about stationary points.

DerivationWhy λ must approach 1 (proof idea)
  1. Q^TD(1)=ΠνQπ⟹⟨Q^TD(1),ψ⟩ν=⟨Qπ,ψ⟩ν\hat Q_{\text{TD}(1)}=\Pi_\nu Q^\pi\quad\Longrightarrow\quad\big\langle\hat Q_{\text{TD}(1)},\boldsymbol\psi\big\rangle_\nu=\big\langle Q^\pi,\boldsymbol\psi\big\rangle_\nu

    Freeze the actor at θ\boldsymbol\theta. A TD(1) critic converges to the least-squares projection ΠνQπ\Pi_\nu Q^\pi onto its features, and by the compatible-features argument that projection yields the exact gradient:

  2. θ˙=−∇cˉ(θ)+ϵλ(θ),sup⁡θ∥ϵλ(θ)∥→0  as λ→1\dot{\boldsymbol\theta}=-\nabla\bar c(\boldsymbol\theta)+\boldsymbol\epsilon_\lambda(\boldsymbol\theta),\qquad\sup_{\boldsymbol\theta}\norm{\boldsymbol\epsilon_\lambda(\boldsymbol\theta)}\to0\ \text{ as }\lambda\to1

    A TD(λ) critic with λ<1\lambda<1 converges instead to the fixed point of a projected Bellman equation, which differs from ΠνQπ\Pi_\nu Q^\pi unless QπQ^\pi lies in the span of the features. The actor then follows a perturbed gradient, with a perturbation that shrinks as λ→1\lambda\to1:

  3. Use cˉ\bar c as a Lyapunov function. Along the actor's ODE it decreases whenever ∥∇cˉ∥\norm{\nabla\bar c} exceeds ∥ϵλ∥\norm{\boldsymbol\epsilon_\lambda}, so trajectories keep returning to the region where the gradient is at most the perturbation. Translating this from the ODE back to the stochastic iterates gives a lim inf⁡\liminf statement whose gap closes only as λ→1\lambda\to1.

Bhatnagar et al. (2009) extended this line to TD(0) critics and natural gradients. Their guarantees take the same conditional form: when the critic's approximation error is small enough, the actor converges almost surely to a small neighborhood of the local maxima of the average reward.

Finite-time results, and the gap to practice

Asymptotic theorems say nothing about how many samples are needed. Since about 2019, finite-time analyses of actor–critic have appeared, typically for linear critics and Markovian sampling. Two examples:

  • Wu, Zhang, Xu and Gu (2020): two-timescale actor–critic reaches an ε\varepsilon-stationary point, E∥∇J∥2≤ε\E\norm{\nabla J}^2\le\varepsilon up to the critic's approximation error, with O~(ε−2.5)\tilde O(\varepsilon^{-2.5}) samples.
  • Xu, Wang and Liang (2020): with mini-batches and several critic updates per actor step, actor–critic needs O((1−γ)−2ε−2log⁡(1/ε))O\big((1-\gamma)^{-2}\varepsilon^{-2}\log(1/\varepsilon)\big) samples to reach an ε\varepsilon-stationary point, and natural actor–critic O((1−γ)−4ε−3log⁡(1/ε))O\big((1-\gamma)^{-4}\varepsilon^{-3}\log(1/\varepsilon)\big) samples to come within ε\varepsilon of the global optimum, up to the approximation errors of the actor's and the critic's function classes.

The natural actor–critic result is a global one because natural gradients inherit the gradient-domination structure of Global Convergence of Policy Gradients, with an extra error term for how well the compatible features can represent the advantage.

Key takeaways

  • The policy gradient sees QπQ^\pi only through its projection onto the span of the score functions; a critic linear in the scores and fitted by least squares under dμπ⊗πd^\pi_\mu\otimes\pi gives the exact gradient.
  • Compatible critics have mean zero under the policy, so they estimate advantages, and their weights are the natural gradient, w⋆=(1−γ)F−1∇J\mathbf w^\star=(1-\gamma)F^{-1}\nabla J: following them is natural actor–critic.
  • Two-timescale stochastic approximation lets a fast critic track a slow actor. Konda and Tsitsiklis proved lim inf⁡∥∇cˉ∥=0\liminf\norm{\nabla\bar c}=0 with a TD(1) critic, and <ε<\varepsilon with TD(λ) for λ\lambda near 1.
  • Finite-time analyses give polynomial sample complexities, such as O~(ε−2.5)\tilde O(\varepsilon^{-2.5}) for two-timescale actor–critic, for linear critics under Markovian sampling; deep actor–critics meet such conditions only loosely.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Under which conditions does the compatible function approximation theorem make the critic-based policy gradient exact?

  1. The critic is any neural network trained by TD(0)
  2. The critic is linear in the score features (or in features whose span contains them) and is the least-squares fit of QπQ^\pi under the on-policy state–action distribution
  3. The critic is exact in every state
  4. The policy is deterministic
Show the answer

B. The critic is linear in the score features (or in features whose span contains them) and is the least-squares fit of QπQ^\pi under the on-policy state–action distribution

The proof uses only the normal equations of that least-squares problem: the residual Qπ−fw⋆Q^\pi-f_{\mathbf w^\star} is orthogonal to every score function, which is all the gradient sees. An exact critic would also do, but it is far more than needed.

Question 2

In the two-action example with π(a1)=p\pi(a_1)=p and a logistic parameterization, what are the compatible critic's least-squares weights w⋆w^\star?

  1. p(1−p)(Q(a1)−Q(a2))p(1-p)\big(Q(a_1)-Q(a_2)\big)
  2. Vπ=p Q(a1)+(1−p) Q(a2)V^\pi=p\,Q(a_1)+(1-p)\,Q(a_2)
  3. 00
  4. Q(a1)−Q(a2)Q(a_1)-Q(a_2), whatever the value of pp
Show the answer

D. Q(a1)−Q(a2)Q(a_1)-Q(a_2), whatever the value of pp

F=p(1−p)F=p(1-p) and ∇J=p(1−p)(Q(a1)−Q(a2))\nabla J=p(1-p)\big(Q(a_1)-Q(a_2)\big), so w⋆=F−1∇J=Q(a1)−Q(a2)w^\star=F^{-1}\nabla J=Q(a_1)-Q(a_2). It is the natural gradient, and unlike the plain gradient it does not vanish as p→0p\to0 or 11.

Question 3

In two-timescale actor–critic with step sizes αk\alpha_k for the critic and βk\beta_k for the actor, which condition says that the actor is the slower learner?

  1. βk/αk→0\beta_k/\alpha_k\to0
  2. αk/βk→0\alpha_k/\beta_k\to0
  3. αk=βk\alpha_k=\beta_k for all kk
  4. ∑kβk<∞\sum_k\beta_k<\infty
Show the answer

A. βk/αk→0\beta_k/\alpha_k\to0

If βk/αk→0\beta_k/\alpha_k\to0, then over any stretch in which the critic moves an appreciable amount, the actor barely moves, so the critic can track w⋆(θ)\mathbf w^\star(\boldsymbol\theta) for an effectively frozen policy. Both sums must still diverge, so that each learner can travel arbitrarily far.

Question 4

Why does Konda and Tsitsiklis's result for a TD(λ) critic with λ<1\lambda<1 guarantee only lim inf⁡k∥∇cˉ(θk)∥<ε\liminf_k\norm{\nabla\bar c(\boldsymbol\theta_k)}<\varepsilon, for λ\lambda near 1?

  1. Because TD(λ) diverges for λ<1\lambda<1
  2. Because the step sizes cannot satisfy the two-timescale conditions when λ<1\lambda<1
  3. Because TD(λ) with λ<1\lambda<1 converges to a projected Bellman fixed point rather than the least-squares projection of QπQ^\pi, so the actor follows a perturbed gradient whose error vanishes only as λ→1\lambda\to1
  4. Because the average cost is not differentiable
Show the answer

C. Because TD(λ) with λ<1\lambda<1 converges to a projected Bellman fixed point rather than the least-squares projection of QπQ^\pi, so the actor follows a perturbed gradient whose error vanishes only as λ→1\lambda\to1

The compatible-features argument needs the least-squares projection, which TD(1) computes. For λ<1\lambda<1 the critic's fixed point is biased unless QπQ^\pi lies in the feature span, and that bias perturbs the actor's ODE by an amount that shrinks as λ→1\lambda\to1.

Further reading

  • R. S. Sutton, D. McAllester, S. Singh & Y. Mansour, "Policy gradient methods for reinforcement learning with function approximation," NIPS 12 (2000).
  • V. R. Konda & J. N. Tsitsiklis, "On actor-critic algorithms," SIAM Journal on Control and Optimization 42(4), 1143–1166 (2003).
  • S. M. Kakade, "A natural policy gradient," NIPS 14 (2001).
  • V. S. Borkar, "Stochastic approximation with two time scales," Systems & Control Letters 29(5), 291–294 (1997).
  • S. Bhatnagar, R. S. Sutton, M. Ghavamzadeh & M. Lee, "Natural actor–critic algorithms," Automatica 45(11), 2471–2482 (2009).