Skip to content
Lambdian

Actor-critic methods (A2C)

Combine a policy (actor) with a learned value function (critic) for lower-variance policy gradients.

Animated explanation

The idea

REINFORCE waits until the end of an episode and judges each action by the noisy total return. Actor-critic methods add a second learner, the critic, that predicts how good states are. After every single step the critic computes the TD error: "that went better (or worse) than I expected". The actor uses that surprise to adjust its policy immediately.

So the actor does what policy gradients do (learns a stochastic policy directly) while the critic does what TD learning does (learns values by bootstrapping). The result learns online, with far lower variance than REINFORCE, and is the template for almost every modern deep RL algorithm: A2C, A3C, PPO, SAC, DDPG and TD3.

Advantage estimates

The actor's weight for an action should be its advantage: how much better it is than the policy's average in that state. The one-step TD error is a cheap, biased estimate of it; n-step returns or generalised advantage estimation (GAE) trade bias for variance with a parameter λ, just like TD(λ).

Making it work

Use separate or carefully balanced learning rates (the critic usually learns faster), an entropy bonus βH(π(⋅∣s))\beta H(\pi(\cdot|s)) to keep exploring, normalised advantages, gradient clipping, and several parallel environments to decorrelate data (A2C). For continuous actions the actor outputs a Gaussian's mean and log-standard-deviation.

The algorithm, step by step

  1. 1
    Initialise actor θ and critic w.
  2. 2
    At state s: sample a ~ π_θ(·|s); observe r, s′, done.
  3. 3
    δ = r + γ(1 − done)V_w(s′) − V_w(s).
  4. 4
    Critic: w += α_w δ ∇V_w(s). Actor: θ += α_θ δ ∇log π_θ(a|s) (+ entropy bonus). Continue from s′.

The maths

TD error as advantage

δ=r+γV(s′)−V(s)\delta = r + \gamma V(s') - V(s)

Actor update

θ←θ+αθ δ ∇log⁡πθ(a∣s)\theta \leftarrow \theta + \alpha_\theta\,\delta\,\nabla\log\pi_\theta(a\mid s)

Critic update

w←w+αw δ ∇Vw(s)w \leftarrow w + \alpha_w\,\delta\,\nabla V_w(s)

Entropy-regularised objective

J(θ)+β Es[H(πθ(⋅∣s))]J(\theta) + \beta\,\mathbb{E}_s\big[H(\pi_\theta(\cdot\mid s))\big]

Strengths and weaknesses

Strengths

  • Online, step-by-step learning
  • Much lower variance than REINFORCE
  • Handles continuous actions; basis of modern deep RL

Weaknesses

  • Two learners to tune and balance
  • Critic bias can mislead the actor
  • On-policy versions remain sample-hungry

Reach for it when…

Continuous control, large action spaces, or whenever policy gradients are too noisy; the default family for robotics and simulation.

Check your understanding

Question 1

Q1What does the critic provide to the actor?

Question 2

Q2Compared with REINFORCE, actor-critic methods…

Question 3

Q3Why add an entropy bonus to the actor's objective?

Lambdian Lab

One-step actor-critic on the corridor

Tabular actor (softmax scores theta, N × 2) and critic (V, length N).

  • td_error(V, s, r, s2, done, gamma).
  • actor_critic(episodes, alpha_actor, alpha_critic, seed): one-step updates after every step (episodes capped at 200 steps); return (theta, V).
  • The checks compare V with the true values of always going right.
Open the labPython + NumPy runs in your browser. Sign-in keeps your code and attempts.