Actor–critic methods
Actor–critic methods combine a parameterised policy (actor) with a learned value function (critic) to get low-variance, bootstrapped policy-gradient learning for control in Markov decision processes.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Actor–critic methods are used by engineers when they need a policy that learns continuously and efficiently in environments with large or continuous state/action spaces. They are the standard choice when you want the stability of value-based bootstrapping (the critic) together with the direct optimisation of the policy (the actor), for example in robot control, resource allocation, or continuous-action control.
Key ideas
Start from first principles: a reinforcement learning problem is usually modelled as a finite Markov decision process (MDP). We will assume an MDP with finite or continuous state space S and action space A, discount factor 0 ≤ γ ≤ 1, and an episodic or continuing setting with stationary dynamics.
Policy: a policy is a distribution π_θ(a|s) parameterised by θ. It maps each state s to a probability distribution over actions a. (Here π_θ is differentiable wrt θ.)
State-value function (value function): the state-value function V^π(s) = E_π[sum_{t=0}^∞ γ^t r_t | s_0 = s]. It gives expected return starting from s under policy π.
Action-value function: the action-value function Q^π(s,a) = E_π[sum_{t=0}^∞ γ^t r_t | s_0 = s, a_0 = a].
Critic: the critic is a function approximator (tabular, linear, or neural network) estimating V^π(s) or Q^π(s,a). The critic provides a learning signal (a bootstrap estimate) to update the actor.
Actor: the actor is the policy π_θ whose parameters θ are adjusted in the direction suggested by the critic (policy gradient updates).
Temporal-difference (TD) error: the TD error is δ_t = r_t + γ V(s_{t+1}) - V(s_t). For action-value critic it becomes δ_t = r_t + γ Q(s_{t+1}, a_{t+1}) - Q(s_t, a_t) (depending on algorithm). For a state-value critic, E[δ_t | s_t, a_t] = A^π(s_t,a_t), so δ_t serves as an unbiased, low-variance estimator of advantage. For an action-value critic, δ_t is the TD error for Q and has zero expectation under Q^π; actor updates then typically use Q(s_t,a_t) (optionally minus a baseline) rather than interpreting δ_t itself as advantage, unless using compatible function approximation with eligibility traces.
Advantage function: A(s,a) = Q(s,a) − V(s). Advantage measures how much better an action is compared to average action in that state. Using an advantage often reduces variance in policy gradient updates.
Policy gradient theorem: Gives an exact expression for the gradient of the expected return J(θ) = E_τ[R(τ)] with respect to θ in terms of the state–action visit distribution under π_θ and the action-value Q^π. This is the fundamental law actor–critic uses (see derivation in Worked examples).
Assumptions commonly stated in university answers:
- The policy π_θ(a|s) is differentiable wrt θ.
- The MDP is stationary and Markovian.
- For the basic policy gradient theorem we assume episodic or γ-discounted infinite horizon so returns are finite. For continuing tasks without discounting (average-reward setting), actor–critic uses the differential return with TD error δ_t = r_t − ρ̂ + V(s_{t+1}) − V(s_t), where ρ̂ estimates the average reward; analogous policy gradient results hold under appropriate ergodicity assumptions.
Diagram to draw when asked (label exactly):
- Draw a box labelled Actor (π_θ) and a box labelled Critic (V_w or Q_w) side by side.
- Draw arrow from Environment (state s) to both Actor and Critic.
- Draw arrow from Actor to Environment labelled action a ~ π_θ(a|s).
- Draw arrow from Environment to Critic labelled reward r and next state s'.
- Draw arrow from Critic to Actor labelled TD error δ (or advantage A) — this is the learning signal.
Derivation universities ask: derive the policy gradient theorem using the likelihood-ratio trick. (See Worked examples.)
Formulas
J(θ) = E_{τ∼π_θ}[R(τ)] — J(θ) is expected return under policy parameter θ. Symbols: τ = trajectory (s_0,a_0,s_1,...), R(τ) = ∑_{t=0}^∞ γ^t r_t. Units: dimensionless (returns are sums of rewards; rewards may have units — here assume dimensionless). Applies to episodic/discounted problems.
∇_θ J(θ) = E_{s∼d^{π}, a∼π_θ}[∇_θ log π_θ(a|s) Q^π(s,a)] — Policy gradient theorem. Symbols: d^{π}(s) = discounted state visitation distribution (e.g., d^{π}(s) = ∑_{t=0}^{∞} γ^t P(s_t = s | π_θ); some texts normalize by (1−γ), which only scales the gradient by a constant), Q^π(s,a) action-value; units: dimensionless. Applies when π_θ differentiable and returns finite.
∇_θ J(θ) = E_{s∼d^{μ}}[∇_θ μ_θ(s) ∇_a Q^{μ}(s,a) |_{a=μ_θ(s)}] — Deterministic policy gradient theorem (for continuous actions), where μ_θ(s) is a differentiable deterministic policy and d^{μ} is the discounted state visitation distribution under μ_θ.
∇_θ J(θ) = E[∇_θ log π_θ(a|s) (Q^π(s,a) − b(s))] — baseline b(s) may be subtracted; does not bias gradient. Symbols: b(s) any function of state. Units: dimensionless.
δ_t = r_t + γ V_w(s_{t+1}) − V_w(s_t) — TD error for state-value critic. Symbols: V_w is critic with parameters w. Units: reward units (often dimensionless). Applies for TD(0) bootstrapping update.
w ← w + α_c δ_t ∇_w V_w(s_t) — critic update (semi-gradient TD). α_c is critic step-size. Units: w dimensionless.
θ ← θ + α_a δ_t ∇_θ log π_θ(a_t | s_t) — actor update using TD error as an estimator of advantage. α_a actor step-size. Units: θ dimensionless.
A^π(s,a) = Q^π(s,a) − V^π(s) — advantage definition. Units: same as reward (dimensionless here).
Note: All RL quantities are typically dimensionless unless rewards carry physical units. If rewards do have units, interpret units consistently.
Worked examples
- Derivation / model answer: Policy gradient theorem (short exam derivation) Question: Show that ∇θ J(θ) = E{s,a∼π}[∇_θ log π_θ(a|s) Q^π(s,a)]. Model answer (step-by-step):
- Write the expected return J(θ) = ∑_{τ} P(τ;θ) R(τ), where P(τ;θ) = p(s_0) ∏t π_θ(a_t|s_t) p(s{t+1}|s_t,a_t).
- Take gradient: ∇_θ J(θ) = ∑_τ ∇_θ P(τ;θ) R(τ).
- Use likelihood ratio: ∇_θ P(τ;θ) = P(τ;θ) ∇_θ log P(τ;θ) = P(τ;θ) ∑_t ∇_θ log π_θ(a_t|s_t) because environment dynamics do not depend on θ.
- So ∇_θ J(θ) = ∑_τ P(τ;θ) (∑_t ∇_θ log π_θ(a_t|s_t)) R(τ)
- Swap sums and write expectation: = E_π[∑_t ∇_θ log π_θ(a_t|s_t) R(τ)].
- Replace R(τ) with return from time t: R(τ) = G_t + terms independent of a_t; only G_t matters. Then ∇_θ J(θ) = E_π[∑_t ∇_θ log π_θ(a_t|s_t) G_t].
- Recognise that E[G_t | s_t, a_t] = Q^π(s_t,a_t), giving ∇_θ J(θ) = E_π[∑_t ∇_θ log π_θ(a_t|s_t) Q^π(s_t,a_t)], which is equivalent to the stated expectation over state-action distribution.
- Conclude dividing by episode length or using stationary discounted visitation gives the compact form. This derivation requires the policy to be differentiable and uses the likelihood-ratio trick; baseline subtraction is allowed because E_π[∇ log π · b(s)] = 0.
- Numerical worked example: Tabular actor–critic (one-step update) Setup: two actions {a1,a2} in state s. Softmax policy parameterised by θ = [θ1, θ2] for state s (separate parameters per state; single-state example). Initial values: θ = [0.2, -0.1], critic V(s)=0.5, discount γ=0.9. Learning rates α_a = 0.1 (actor), α_c = 0.2 (critic). Observed: agent takes action a1, reward r = 1.0, next state s' (same state in this simple example). We perform one actor and critic update using TD(0). Step 1: compute action probabilities by softmax:
- π(a1|s) = exp(0.2) / (exp(0.2)+exp(-0.1)) ≈ 1.22140 / (1.22140+0.90484) ≈ 0.574
- π(a2|s) ≈ 0.426 Step 2: compute TD error δ = r + γ V(s') − V(s) = 1.0 + 0.9·0.5 − 0.5 = 1.0 + 0.45 − 0.5 = 0.95 Step 3: compute ∇_θ log π(a1|s). For softmax with two params, components are:
- ∂/∂θ1 log π(a1|s) = 1 − π(a1|s) = 1 − 0.574 = 0.426
- ∂/∂θ2 log π(a1|s) = −π(a2|s) = −0.426 Step 4: actor update θ ← θ + α_a δ ∇_θ log π:
- Δθ1 = 0.1 × 0.95 × 0.426 = 0.04047 → new θ1 = 0.24047
- Δθ2 = 0.1 × 0.95 × (−0.426) = −0.04047 → new θ2 = −0.14047 Step 5: critic update V(s) ← V(s) + α_c δ = 0.5 + 0.2 × 0.95 = 0.5 + 0.19 = 0.69 Final answers (rounded): new θ ≈ [0.2405, −0.1405], new V(s) = 0.69. The policy became slightly more likely to select a1 because δ>0.
This numerical example shows how the TD error δ serves as an estimator of advantage and updates actor proportionally to ∇ log π.
Common mistakes
- Forgetting that baseline subtraction does not change expectation (it only reduces variance), and incorrectly adding a state-dependent baseline that depends on action.
- Mixing on-policy actor–critic (uses trajectories from π) with off-policy updates without importance sampling — the simple actor–critic formulas assume on-policy sampling.
- Not distinguishing between V-based critic (uses δ = r + γ V(s') − V(s)) and Q-based critic (which leads to different update forms like Q(λ) or SARSA-style).
- Forgetting to make π differentiable; using argmax policies breaks policy gradient derivations.
For your exam
Question types you will see: definitions (state the policy gradient theorem), short notes (advantages of actor–critic vs REINFORCE), derivations (derive policy gradient theorem by likelihood ratio), numericals (single-step actor–critic update like the worked example), and a labelled diagram of actor and critic flow. What a full-marks answer includes:
- Exact definitions of actor and critic and TD error.
- Clear statement of the policy gradient theorem and its assumptions.
- Correct step-by-step derivation (likelihood-ratio trick, moving expectation inside, replacing return with Q^π).
- If numerical: show all intermediate steps and units; final numbers rounded sensibly with units (usually dimensionless).
Quick check
- What is the TD error for a state-value critic?
- Why can you subtract a baseline from the policy gradient estimator without bias?
- In actor–critic, which component reduces variance and which gives direction to policy updates? Answers: δ_t = r_t + γ V(s_{t+1}) − V(s_t); because E_π[∇ log π(a|s) b(s)] = 0 so baseline does not change expected gradient; critic reduces variance (provides estimates), actor provides the policy update direction.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?