Skip to content
Ahmed Haroon
← Reinforcement Learning

Actor-Critic Methods

From Baselines to Critics

The policy-gradient estimator weights each action's score by its expected future return:

∇θJ(θ)=Eπθ[∑t=0T−1∇θlog⁡πθ(at∣st)Qπθ(st,at)].\nabla_\theta J(\theta) =\mathbb E_{\pi_\theta} \left[ \sum_{t=0}^{T-1} \nabla_\theta\log\pi_\theta(a_t\mid s_t) Q^{\pi_\theta}(s_t,a_t) \right].

The true QπθQ^{\pi_\theta} is unknown. REINFORCE replaces it with the sampled return

Gt=∑k=0T−t−1γkrt+k.G_t=\sum_{k=0}^{T-t-1}\gamma^k r_{t+k}.

This is unbiased, but each GtG_t represents only one possible future. Actor-critic methods learn a value estimator that can average across many futures.

An actor represents the policy

at∼πθ(⋅∣st),a_t\sim\pi_\theta(\cdot\mid s_t),

while a critic estimates values such as

Vϕ(s)≈Vπ(s)V_\phi(s)\approx V^\pi(s)

or

Qϕ(s,a)≈Qπ(s,a).Q_\phi(s,a)\approx Q^\pi(s,a).

The critic supplies the return or advantage estimate used to update the actor.

The value-function baseline

We can subtract any state-dependent, action-independent baseline without changing the expected policy gradient. The natural choice is

Vπ(s)=Ea∼π(⋅∣s)[Qπ(s,a)].V^\pi(s) =\mathbb E_{a\sim\pi(\cdot\mid s)}[Q^\pi(s,a)].

This centers action values around their policy-weighted average:

Aπ(s,a)=Qπ(s,a)−Vπ(s).A^\pi(s,a)=Q^\pi(s,a)-V^\pi(s).

Therefore,

∇θJ(θ)=E[∑t∇θlog⁡πθ(at∣st)Aπ(st,at)].\boxed{ \nabla_\theta J(\theta) =\mathbb E \left[ \sum_t \nabla_\theta\log\pi_\theta(a_t\mid s_t) A^\pi(s_t,a_t) \right] }.

Positive advantage means the action is better than the policy's average action at that state. Negative advantage means it is worse.

See derivation

Condition on a state ss:

Ea∼πθ(⋅∣s)[∇θlog⁡πθ(a∣s)b(s)]=b(s)∑aπθ(a∣s)∇θlog⁡πθ(a∣s)=b(s)∑a∇θπθ(a∣s)=b(s)∇θ∑aπθ(a∣s)=b(s)∇θ1=0.\begin{aligned} &\mathbb E_{a\sim\pi_\theta(\cdot\mid s)} \left[ \nabla_\theta\log\pi_\theta(a\mid s)b(s) \right]\\ &=b(s)\sum_a \pi_\theta(a\mid s) \nabla_\theta\log\pi_\theta(a\mid s)\\ &=b(s)\sum_a\nabla_\theta\pi_\theta(a\mid s)\\ &=b(s)\nabla_\theta\sum_a\pi_\theta(a\mid s)\\ &=b(s)\nabla_\theta1\\ &=0. \end{aligned}

The baseline changes variance, not the expected gradient.

A baseline is not always a critic

With

A^tMC=Gt−Vϕ(st),\widehat A_t^{\mathrm{MC}} =G_t-V_\phi(s_t),

the value function is only a baseline. Even if VϕV_\phi is inaccurate, the actor gradient remains unbiased because the return estimate is still Monte Carlo.

With

A^t(1)=rt+γVϕ(st+1)−Vϕ(st),\widehat A_t^{(1)} =r_t+\gamma V_\phi(s_{t+1})-V_\phi(s_t),

the learned value appears inside the return estimate. It is now a bootstrapped critic, and its approximation error can bias the actor update.

Suppose

Vϕ(s)=Vπ(s)+e(s).V_\phi(s)=V^\pi(s)+e(s).

Then

E[A^t(1)∣st=s,at=a]=Aπ(s,a)+γEs′[e(s′)]−e(s).\begin{aligned} \mathbb E[\widehat A_t^{(1)}\mid s_t=s,a_t=a] &=A^\pi(s,a) +\gamma\mathbb E_{s'}[e(s')] -e(s). \end{aligned}

The −e(s)-e(s) term is state-only and behaves like a baseline. The next-state error can depend on the chosen action through the transition distribution, so it is the main source of critic-induced bias.

Learning the Critic

A critic can learn from Monte Carlo returns or from bootstrapped temporal-difference targets.

Monte Carlo regression

The target is the complete sampled return:

ytMC=Gt.y_t^{\mathrm{MC}}=G_t.

We minimize

LMC(ϕ)=12E[(Vϕ(st)−Gt)2].\mathcal L_{\mathrm{MC}}(\phi) =\frac12\mathbb E \left[ \left(V_\phi(s_t)-G_t\right)^2 \right].

Function approximation averages different returns observed from similar states. This target does not bootstrap, but it has high variance and may not be available until the trajectory ends.

One-step TD regression

The Bellman equation suggests

yt(1)=rt+γ(1−dt)Vϕ(st+1),y_t^{(1)} =r_t+\gamma(1-d_t)V_\phi(s_{t+1}),

where dt=1d_t=1 for a true terminal transition. Define the TD residual

δt=rt+γ(1−dt)Vϕ(st+1)−Vϕ(st).\boxed{ \delta_t =r_t+\gamma(1-d_t)V_\phi(s_{t+1})-V_\phi(s_t) }.

The critic loss is

LV(ϕ)=12E[(Vϕ(st)−stopgrad⁡[yt(1)])2].\boxed{ \mathcal L_V(\phi) =\frac12\mathbb E \left[ \left( V_\phi(s_t) -\operatorname{stopgrad}[y_t^{(1)}] \right)^2 \right] }.

The semi-gradient update is

ϕ←ϕ+αVδt∇ϕVϕ(st).\phi\leftarrow\phi+ \alpha_V\delta_t\nabla_\phi V_\phi(s_t).

We detach the target so that the critic moves its current-state prediction toward the target without simultaneously changing the next-state prediction to make that target easier to fit.

Target critics

A slowly moving target network further stabilizes bootstrapping:

yt=rt+γ(1−dt)Vϕˉ(st+1).y_t =r_t+\gamma(1-d_t)V_{\bar\phi}(s_{t+1}).

We can periodically copy the critic

ϕˉ←ϕ\bar\phi\leftarrow\phi

or use Polyak averaging:

ϕˉ←τϕ+(1−τ)ϕˉ,τ≪1.\boxed{ \bar\phi \leftarrow \tau\phi+(1-\tau)\bar\phi, \qquad \tau\ll1 }.

For a finite-horizon task, the exact value can also depend on time:

Vtπ(s)=Eπ[∑k=0T−t−1γkrt+k∣st=s].V_t^\pi(s) =\mathbb E_\pi \left[ \sum_{k=0}^{T-t-1}\gamma^k r_{t+k} \mid s_t=s \right].

A stationary critic Vϕ(s)V_\phi(s) is appropriate when the task is time-homogeneous or time is included in the state.

Basic Actor-Critic

For one-step actor-critic, the critic target and advantage are

yt=rt+γ(1−dt)Vϕ(st+1),y_t=r_t+\gamma(1-d_t)V_\phi(s_{t+1}), A^t=yt−Vϕ(st)=δt.\widehat A_t =y_t-V_\phi(s_t) =\delta_t.

The actor minimizes

Lπ(θ)=−E[log⁡πθ(at∣st)stopgrad⁡[A^t]].\boxed{ \mathcal L_\pi(\theta) =-\mathbb E \left[ \log\pi_\theta(a_t\mid s_t) \operatorname{stopgrad}[\widehat A_t] \right] }.

The critic and actor have separate parameters, losses, and optimizers. The advantage is detached during the actor update.

Batch Actor-Critic\textbf{Batch Actor-Critic}Initialize actor parameters θ and critic parameters ϕ.Repeat:collect trajectories using πθ,yt←rt+γ(1−dt)Vϕ(st+1),ϕ←arg⁡min⁡ϕ12∑t(Vϕ(st)−stopgrad⁡[yt])2,A^t←stopgrad⁡[yt−Vϕ(st)],θ←arg⁡min⁡θ−∑tlog⁡πθ(at∣st)A^t.\begin{aligned} &\text{Initialize actor parameters }\theta \text{ and critic parameters }\phi.\\[0.25em] &\text{Repeat:}\\[0.25em] &\qquad \text{collect trajectories using }\pi_\theta,\\[0.25em] &\qquad y_t\leftarrow r_t+\gamma(1-d_t)V_\phi(s_{t+1}),\\[0.25em] &\qquad \phi\leftarrow\arg\min_\phi \frac12\sum_t \left(V_\phi(s_t)-\operatorname{stopgrad}[y_t]\right)^2,\\[0.25em] &\qquad \widehat A_t\leftarrow \operatorname{stopgrad}[y_t-V_\phi(s_t)],\\[0.25em] &\qquad \theta\leftarrow\arg\min_\theta -\sum_t\log\pi_\theta(a_t\mid s_t)\widehat A_t. \end{aligned}

With a single transition, the updates reduce to

ϕ←ϕ+αVδt∇ϕVϕ(st),\phi\leftarrow\phi+ \alpha_V\delta_t\nabla_\phi V_\phi(s_t), θ←θ+απδt∇θlog⁡πθ(at∣st).\theta\leftarrow\theta+ \alpha_\pi\delta_t \nabla_\theta\log\pi_\theta(a_t\mid s_t).

Online updates use fresh data but are noisy and temporally correlated. Batch rollouts average gradients efficiently. Parallel environment workers can decorrelate experience without replay: asynchronous A3C applies worker gradients to shared parameters, while synchronous A2C aggregates all workers before updating.

Multi-Step Returns

One-step TD delegates the entire future after rtr_t to the critic:

G^t(1)=rt+γ(1−dt)V(st+1).\widehat G_t^{(1)} =r_t+\gamma(1-d_t)V(s_{t+1}).

An nn-step return uses nn real rewards before bootstrapping:

G^t(n)=∑k=0n−1γkrt+k+γnV(st+n).\boxed{ \widehat G_t^{(n)} =\sum_{k=0}^{n-1}\gamma^k r_{t+k} +\gamma^n V(s_{t+n}) }.

The bootstrap term is removed if a terminal state occurs inside the window. Its advantage estimate is

A^t(n)=G^t(n)−V(st).\widehat A_t^{(n)} =\widehat G_t^{(n)}-V(s_t).

At the end of a finite episode, V(sT)=0V(s_T)=0. Choosing n=T−tn=T-t recovers the Monte Carlo return:

G^t(T−t)=Gt.\widehat G_t^{(T-t)}=G_t.

Thus one-step TD and Monte Carlo are endpoints of the same family:

G^t(1)⟷G^t(2)⟷⋯⟷Gt.\widehat G_t^{(1)} \longleftrightarrow \widehat G_t^{(2)} \longleftrightarrow \cdots \longleftrightarrow G_t.

Larger nn reduces dependence on critic accuracy but includes more sampled randomness. Smaller nn produces earlier, lower-variance updates but more bootstrap bias.

An nn-step advantage is a discounted sum of one-step TD residuals:

A^t(n)=∑k=0n−1γkδt+k.\boxed{ \widehat A_t^{(n)} =\sum_{k=0}^{n-1}\gamma^k\delta_{t+k} }.
See derivation

Substitute

δt+k=rt+k+γV(st+k+1)−V(st+k).\delta_{t+k} =r_{t+k}+\gamma V(s_{t+k+1})-V(s_{t+k}).

Then

∑k=0n−1γkδt+k=∑k=0n−1γkrt+k+∑k=0n−1γk+1V(st+k+1)−∑k=0n−1γkV(st+k).\begin{aligned} \sum_{k=0}^{n-1}\gamma^k\delta_{t+k} &=\sum_{k=0}^{n-1}\gamma^k r_{t+k}\\ &\quad+\sum_{k=0}^{n-1}\gamma^{k+1}V(s_{t+k+1}) -\sum_{k=0}^{n-1}\gamma^kV(s_{t+k}). \end{aligned}

The value terms telescope:

∑k=0n−1γk+1V(st+k+1)−∑k=0n−1γkV(st+k)=γnV(st+n)−V(st).\sum_{k=0}^{n-1}\gamma^{k+1}V(s_{t+k+1}) -\sum_{k=0}^{n-1}\gamma^kV(s_{t+k}) =\gamma^nV(s_{t+n})-V(s_t).

Therefore,

∑k=0n−1γkδt+k=G^t(n)−V(st)=A^t(n).\sum_{k=0}^{n-1}\gamma^k\delta_{t+k} =\widehat G_t^{(n)}-V(s_t) =\widehat A_t^{(n)}.

This identity connects multi-step returns, generalized advantage estimation, and eligibility traces.

Generalized Advantage Estimation

Choosing one fixed nn commits every update to one point on the bias-variance spectrum. Generalized Advantage Estimation mixes many horizons:

A^tGAE(γ,λ)=(1−λ)∑n=1∞λn−1A^t(n),λ∈[0,1].\widehat A_t^{\mathrm{GAE}(\gamma,\lambda)} =(1-\lambda) \sum_{n=1}^{\infty} \lambda^{n-1}\widehat A_t^{(n)}, \qquad \lambda\in[0,1].

Using the TD-residual identity, this simplifies to

A^tGAE(γ,λ)=∑l=0∞(γλ)lδt+l.\boxed{ \widehat A_t^{\mathrm{GAE}(\gamma,\lambda)} =\sum_{l=0}^{\infty} (\gamma\lambda)^l\delta_{t+l} }.
See derivation

Substitute

A^t(n)=∑l=0n−1γlδt+l:\widehat A_t^{(n)} =\sum_{l=0}^{n-1}\gamma^l\delta_{t+l}:A^tGAE=(1−λ)∑n=1∞λn−1∑l=0n−1γlδt+l.\widehat A_t^{\mathrm{GAE}} =(1-\lambda) \sum_{n=1}^{\infty}\lambda^{n-1} \sum_{l=0}^{n-1}\gamma^l\delta_{t+l}.

A fixed δt+l\delta_{t+l} occurs in every estimator with n≥l+1n\geq l+1. Swapping the summations gives

A^tGAE=(1−λ)∑l=0∞γlδt+l∑n=l+1∞λn−1.\widehat A_t^{\mathrm{GAE}} =(1-\lambda) \sum_{l=0}^{\infty}\gamma^l\delta_{t+l} \sum_{n=l+1}^{\infty}\lambda^{n-1}.
∑n=l+1∞λn−1=λl1−λ.\sum_{n=l+1}^{\infty}\lambda^{n-1} =\frac{\lambda^l}{1-\lambda}.

Therefore,

A^tGAE=∑l=0∞(γλ)lδt+l.\widehat A_t^{\mathrm{GAE}} =\sum_{l=0}^{\infty}(\gamma\lambda)^l\delta_{t+l}.

We compute GAE in one backward pass:

A^t=δt+γλ(1−dt)A^t+1.\boxed{ \widehat A_t =\delta_t +\gamma\lambda(1-d_t)\widehat A_{t+1} }.
Backward GAE Recursion\textbf{Backward GAE Recursion}A^T←0.For t=T−1,T−2,…,0:δt←rt+γ(1−dt)V(st+1)−V(st),A^t←δt+γλ(1−dt)A^t+1.\begin{aligned} &\widehat A_{T}\leftarrow0.\\[0.25em] &\text{For }t=T-1,T-2,\ldots,0:\\[0.25em] &\qquad \delta_t\leftarrow r_t+\gamma(1-d_t)V(s_{t+1})-V(s_t),\\[0.25em] &\qquad \widehat A_t\leftarrow \delta_t+\gamma\lambda(1-d_t)\widehat A_{t+1}. \end{aligned}

At λ=0\lambda=0,

A^tGAE(γ,0)=δt,\widehat A_t^{\mathrm{GAE}(\gamma,0)}=\delta_t,

so we recover the one-step estimate. At λ=1\lambda=1 in a completed episode,

A^tGAE(γ,1)=Gt−V(st),\widehat A_t^{\mathrm{GAE}(\gamma,1)} =G_t-V(s_t),

so we recover Monte Carlo reward-to-go with a value baseline.

The residual at lag ll is weighted by (γλ)l(\gamma\lambda)^l. A rough effective trace horizon is

Heff≈11−γλ.H_{\mathrm{eff}}\approx\frac1{1-\gamma\lambda}.

Larger λ\lambda uses longer sampled horizons and usually increases variance. Smaller λ\lambda relies more strongly on critic accuracy.

A matching value target is

R^tλ=A^t+V(st).\widehat R_t^\lambda =\widehat A_t+V(s_t).

We fit the critic with

LV(ϕ)=12E[(Vϕ(st)−stopgrad⁡[R^tλ])2].\mathcal L_V(\phi) =\frac12\mathbb E \left[ \left(V_\phi(s_t)-\operatorname{stopgrad}[\widehat R_t^\lambda]\right)^2 \right].

Advantage normalization,

A~t=A^t−μAσA+ε,\widetilde A_t =\frac{\widehat A_t-\mu_A}{\sigma_A+\varepsilon},

reduces sensitivity to reward scale, but it cannot repair a systematically incorrect critic.

Off-Policy Actor-Critic

Replay buffers make training more sample-efficient, but they break the on-policy assumptions of a state-value critic. A replay action was sampled from a behavior policy β\beta:

a∼β(⋅∣s),β≠πθ.a\sim\beta(\cdot\mid s), \qquad \beta\neq\pi_\theta.

The Bellman equation for the current policy is

Vπ(s)=Ea∼π(⋅∣s),,s′∼P[r(s,a)+γVπ(s′)].V^\pi(s) =\mathbb E_{ a\sim\pi(\cdot\mid s),,s'\sim P } \left[r(s,a)+\gamma V^\pi(s')\right].

Regressing V(s)V(s) toward a target built from arbitrary replay actions instead averages under β\beta. Without importance weighting or another correction, it does not cleanly learn VπV^\pi.

A Q-function conditions on the replay action:

Qπ(s,a)=Es′∼P(⋅∣s,a)[r(s,a)+γEa′∼π(⋅∣s′)Qπ(s′,a′)].Q^\pi(s,a) =\mathbb E_{s'\sim P(\cdot\mid s,a)} \left[ r(s,a)+\gamma \mathbb E_{a'\sim\pi(\cdot\mid s')} Q^\pi(s',a') \right].

Even when aa came from an old policy, the replay tuple contains a valid environment outcome for that particular (s,a)(s,a). We sample the next action from the current actor:

a′∼πθ(⋅∣s′),a'\sim\pi_\theta(\cdot\mid s'), y=r+γ(1−d)Qϕˉ(s′,a′).\boxed{ y =r+\gamma(1-d)Q_{\bar\phi}(s',a') }.

The critic minimizes

LQ(ϕ)=12ED[(Qϕ(s,a)−stopgrad⁡[y])2].\mathcal L_Q(\phi) =\frac12\mathbb E_{\mathcal D} \left[ \left(Q_\phi(s,a)-\operatorname{stopgrad}[y]\right)^2 \right].

The actor can reuse replay states while sampling fresh current-policy actions:

s∼D,a~∼πθ(⋅∣s).s\sim\mathcal D, \qquad \widetilde a\sim\pi_\theta(\cdot\mid s).

An approximate score-function update is

∇θJD≈E[∇θlog⁡πθ(a~∣s)Qϕ(s,a~)].\nabla_\theta J_\mathcal D \approx\mathbb E \left[ \nabla_\theta\log\pi_\theta(\widetilde a\mid s) Q_\phi(s,\widetilde a) \right].

The fresh action removes the immediate action-distribution mismatch. Replay states still follow a mixture of historical policies, and practical off-policy algorithms accept or control this remaining mismatch.

If the actor always chooses the critic's exact maximizer,

π(a∣s)=1[a=arg⁡max⁡a~Q(s,a~)],\pi(a\mid s)=\mathbb 1 \left[a=\arg\max_{\widetilde a}Q(s,\widetilde a)\right],

then the target becomes

y=r+γmax⁡a′Qϕˉ(s′,a′),y=r+\gamma\max_{a'}Q_{\bar\phi}(s',a'),

which is Q-learning. Actor-critic replaces an explicit maximization operator with a learned policy.

Deterministic and Reparameterized Actors

For continuous actions, we can learn a deterministic actor

μθ(s)≈arg⁡max⁡aQϕ(s,a).\mu_\theta(s)\approx\arg\max_aQ_\phi(s,a).

It maximizes

JD(θ)=Es∼D[Qϕ(s,μθ(s))].J_\mathcal D(\theta) =\mathbb E_{s\sim\mathcal D} \left[Q_\phi(s,\mu_\theta(s))\right].

By the chain rule,

∇θJD(θ)=Es∼D[∇aQϕ(s,a)∣a=μθ(s)∇θμθ(s)].\boxed{ \nabla_\theta J_\mathcal D(\theta) =\mathbb E_{s\sim\mathcal D} \left[ \left.\nabla_aQ_\phi(s,a)\right|_{a=\mu_\theta(s)} \nabla_\theta\mu_\theta(s) \right] }.

The actor loss is simply

Lμ(θ)=−Es∼D[Qϕ(s,μθ(s))].\mathcal L_\mu(\theta) =-\mathbb E_{s\sim\mathcal D} [Q_\phi(s,\mu_\theta(s))].

During this update, gradients must flow through the critic with respect to its action input, but the actor optimizer must not update the critic's parameters.

For a Gaussian policy, sample fixed noise

ϵ∼N(0,I)\epsilon\sim\mathcal N(0,I)

and write the action as

a=fθ(s,ϵ)=μθ(s)+σθ(s)⊙ϵ.a=f_\theta(s,\epsilon) =\mu_\theta(s)+\sigma_\theta(s)\odot\epsilon.

Then

Ea∼πθ[Qϕ(s,a)]=Eϵ[Qϕ(s,fθ(s,ϵ))],\mathbb E_{a\sim\pi_\theta}[Q_\phi(s,a)] =\mathbb E_\epsilon [Q_\phi(s,f_\theta(s,\epsilon))],

and the pathwise gradient is

∇θEϵ[Qϕ(s,fθ(s,ϵ))]=Eϵ[∇aQϕ(s,a)∣a=fθ(s,ϵ)∇θfθ(s,ϵ)].\boxed{ \nabla_\theta \mathbb E_\epsilon[Q_\phi(s,f_\theta(s,\epsilon))] =\mathbb E_\epsilon \left[ \left.\nabla_aQ_\phi(s,a)\right|_{a=f_\theta(s,\epsilon)} \nabla_\theta f_\theta(s,\epsilon) \right] }.

This usually has lower variance than a score-function estimator because it differentiates through the sampled action. As σθ(s)→0\sigma_\theta(s)\to0, it reduces to the deterministic policy gradient.

For bounded actions, we often use

u=μθ(s)+σθ(s)⊙ϵ,a=tanh⁡(u).u=\mu_\theta(s)+\sigma_\theta(s)\odot\epsilon, \qquad a=\tanh(u).

The transformation keeps aa in [−1,1][-1,1] while preserving a differentiable path to the actor.

DDPG

Deep Deterministic Policy Gradient combines:

  • a deterministic actor μθ\mu_\theta;
  • a Q-critic QϕQ_\phi;
  • target actor μθˉ\mu_{\bar\theta} and target critic QϕˉQ_{\bar\phi};
  • an experience-replay buffer.

The target action and critic target are

a′=μθˉ(s′),a'=\mu_{\bar\theta}(s'), y=r+γ(1−d)Qϕˉ(s′,a′).\boxed{ y=r+\gamma(1-d)Q_{\bar\phi}(s',a') }.

The critic minimizes

LQ(ϕ)=ED[(Qϕ(s,a)−stopgrad⁡[y])2],\mathcal L_Q(\phi) =\mathbb E_\mathcal D \left[ \left(Q_\phi(s,a)-\operatorname{stopgrad}[y]\right)^2 \right],

while the actor minimizes

Lμ(θ)=−Es∼D[Qϕ(s,μθ(s))].\mathcal L_\mu(\theta) =-\mathbb E_{s\sim\mathcal D} [Q_\phi(s,\mu_\theta(s))].

Both target networks move slowly:

θˉ←τθ+(1−τ)θˉ,\bar\theta\leftarrow \tau\theta+(1-\tau)\bar\theta, ϕˉ←τϕ+(1−τ)ϕˉ.\bar\phi\leftarrow \tau\phi+(1-\tau)\bar\phi.

Because the actor is deterministic, behavior needs external exploration noise:

at=μθ(st)+ηt.a_t=\mu_\theta(s_t)+\eta_t.

We remove ηt\eta_t during evaluation.

DDPG\textbf{DDPG}Initialize μθ,Qϕ,μθˉ←μθ,Qϕˉ←Qϕ, and replay D.For each environment step:at←μθ(st)+ηt,execute at and store (st,at,rt,st+1,dt),sample a minibatch from D,yi←ri+γ(1−di)Qϕˉ(si′,μθˉ(si′)),ϕ←arg⁡min⁡ϕ1B∑i(Qϕ(si,ai)−yi)2,θ←arg⁡min⁡θ−1B∑iQϕ(si,μθ(si)),Polyak-update θˉ and ϕˉ.\begin{aligned} &\text{Initialize }\mu_\theta,Q_\phi, \mu_{\bar\theta}\leftarrow\mu_\theta, Q_{\bar\phi}\leftarrow Q_\phi, \text{ and replay }\mathcal D.\\[0.25em] &\text{For each environment step:}\\[0.25em] &\qquad a_t\leftarrow\mu_\theta(s_t)+\eta_t,\\[0.25em] &\qquad \text{execute }a_t\text{ and store }(s_t,a_t,r_t,s_{t+1},d_t),\\[0.25em] &\qquad \text{sample a minibatch from }\mathcal D,\\[0.25em] &\qquad y_i\leftarrow r_i+\gamma(1-d_i) Q_{\bar\phi}(s_i',\mu_{\bar\theta}(s_i')),\\[0.25em] &\qquad \phi\leftarrow\arg\min_\phi \frac1B\sum_i(Q_\phi(s_i,a_i)-y_i)^2,\\[0.25em] &\qquad \theta\leftarrow\arg\min_\theta -\frac1B\sum_iQ_\phi(s_i,\mu_\theta(s_i)),\\[0.25em] &\qquad \text{Polyak-update }\bar\theta\text{ and }\bar\phi. \end{aligned}

DDPG is approximate continuous-action Q-learning: the actor amortizes the critic's argmax.

TD3

A learned actor can exploit positive critic errors just as a discrete max does. If the critic overestimates one narrow action region, the actor is trained to move toward it.

TD3 uses two critics

Qϕ1(s,a),Qϕ2(s,a),Q_{\phi_1}(s,a), \qquad Q_{\phi_2}(s,a),

and the clipped target

y=r+γ(1−d)min⁡j∈{1,2}Qϕˉj(s′,a′).\boxed{ y=r+\gamma(1-d) \min_{j\in\{1,2\}} Q_{\bar\phi_j}(s',a') }.

Each critic minimizes its own Bellman loss:

LQj(ϕj)=ED[(Qϕj(s,a)−stopgrad⁡[y])2].\mathcal L_{Q_j}(\phi_j) =\mathbb E_\mathcal D \left[ \left(Q_{\phi_j}(s,a)-\operatorname{stopgrad}[y]\right)^2 \right].

The minimum introduces a conservative bias that prevents optimistic errors from reinforcing themselves. TD3 also delays actor and target updates, allowing the critics to improve before the actor follows their gradients.

many critic updates⟶one actor and target update.\text{many critic updates} \longrightarrow \text{one actor and target update}.

If the actor changes faster than the critic can track, it is likely to chase transient value errors.

Soft Actor-Critic

Soft Actor-Critic optimizes reward and policy entropy:

J(π)=E[∑tγt(r(st,at)+αH(π(⋅∣st)))].\boxed{ J(\pi) =\mathbb E \left[ \sum_t\gamma^t \left(r(s_t,a_t)+\alpha\mathcal H(\pi(\cdot\mid s_t))\right) \right] }.

Since

H(π(⋅∣s))=−Ea∼π[log⁡π(a∣s)],\mathcal H(\pi(\cdot\mid s)) =-\mathbb E_{a\sim\pi} [\log\pi(a\mid s)],

the soft state value is

Vsoft(s)=Ea∼π[Q(s,a)−αlog⁡π(a∣s)].V_{\mathrm{soft}}(s) =\mathbb E_{a\sim\pi} \left[Q(s,a)-\alpha\log\pi(a\mid s)\right].

The temperature α>0\alpha>0 controls the reward-entropy trade-off. Large α\alpha favors stochastic policies; small α\alpha approaches reward-greedy behavior.

Critic target

Sample a reparameterized next action

a′∼πθ(⋅∣s′).a'\sim\pi_\theta(\cdot\mid s').

With twin target critics,

y=r+γ(1−d)[min⁡j∈{1,2}Qϕˉj(s′,a′)−αlog⁡πθ(a′∣s′)].\boxed{ y=r+\gamma(1-d) \left[ \min_{j\in\{1,2\}}Q_{\bar\phi_j}(s',a') -\alpha\log\pi_\theta(a'\mid s') \right] }.

Each critic minimizes

LQj(ϕj)=ED[(Qϕj(s,a)−stopgrad⁡[y])2].\mathcal L_{Q_j}(\phi_j) =\mathbb E_\mathcal D \left[ \left(Q_{\phi_j}(s,a)-\operatorname{stopgrad}[y]\right)^2 \right].

The replay action aa is used in the current critic prediction. The next action a′a' comes from the latest actor.

Actor loss

The actor maximizes soft value, or equivalently minimizes

Lπ(θ)=Es∼D,,a∼πθ[αlog⁡πθ(a∣s)−min⁡j∈{1,2}Qϕj(s,a)].\boxed{ \mathcal L_\pi(\theta) =\mathbb E_{ s\sim\mathcal D,,a\sim\pi_\theta } \left[ \alpha\log\pi_\theta(a\mid s) -\min_{j\in\{1,2\}}Q_{\phi_j}(s,a) \right] }.

Reparameterization lets gradients flow through the sampled action into the critic and through the log-probability term.

Automatic temperature tuning

We can learn α\alpha to track a target entropy Htgt\mathcal H_{\mathrm{tgt}}:

Lα=E[−α(log⁡πθ(a∣s)+Htgt)].\boxed{ \mathcal L_\alpha =\mathbb E \left[ -\alpha \left( \log\pi_\theta(a\mid s) +\mathcal H_{\mathrm{tgt}} \right) \right] }.

Parameterize

α=exp⁡(log⁡α)\alpha=\exp(\log\alpha)

to ensure positivity. The policy terms are detached during the temperature-only update.

Soft Actor-Critic\textbf{Soft Actor-Critic}Initialize actor πθ, critics Qϕ1,Qϕ2, targets, and replay D.For each environment step:at∼πθ(⋅∣st),execute at and store the transition,sample a minibatch from D,ai′∼πθ(⋅∣si′),yi←ri+γ(1−di)[min⁡jQϕˉj(si′,ai′)−αlog⁡πθ(ai′∣si′)],fit both critics to yi,update the actor with αlog⁡πθ(a∣s)−min⁡jQϕj(s,a),optionally update α,Polyak-update both target critics.\begin{aligned} &\text{Initialize actor }\pi_\theta,\text{ critics }Q_{\phi_1},Q_{\phi_2}, \text{ targets, and replay }\mathcal D.\\[0.25em] &\text{For each environment step:}\\[0.25em] &\qquad a_t\sim\pi_\theta(\cdot\mid s_t),\\[0.25em] &\qquad \text{execute }a_t\text{ and store the transition},\\[0.25em] &\qquad \text{sample a minibatch from }\mathcal D,\\[0.25em] &\qquad a_i'\sim\pi_\theta(\cdot\mid s_i'),\\[0.25em] &\qquad y_i\leftarrow r_i+\gamma(1-d_i) \left[ \min_jQ_{\bar\phi_j}(s_i',a_i') -\alpha\log\pi_\theta(a_i'\mid s_i') \right],\\[0.25em] &\qquad \text{fit both critics to }y_i,\\[0.25em] &\qquad \text{update the actor with } \alpha\log\pi_\theta(a\mid s)-\min_jQ_{\phi_j}(s,a),\\[0.25em] &\qquad \text{optionally update }\alpha,\\[0.25em] &\qquad \text{Polyak-update both target critics.} \end{aligned}

Comparing the Main Estimators

MethodDataActorCritic signalMain trade-off
One-step actor-criticFresh on-policy rolloutsStochastic score functionr+γV(s′)−V(s)r+\gamma V(s')-V(s)Low variance, critic bias
GAE actor-criticFresh on-policy rolloutsStochastic score functionWeighted TD residualsTunable bias and variance
DDPGReplayDeterministic pathwiseTarget Q at target-actor actionEfficient continuous control, fragile critic
TD3ReplayDeterministic pathwiseMinimum of twin target criticsLess overestimation, conservative bias
SACReplayStochastic reparameterizedEntropy-regularized twin-Q targetStable exploration, more interacting components

The on-policy methods use value critics because their rollout actions follow the current policy. Replay-based methods use Q-critics because the stored action may come from an older policy.

Practical Diagnosis

SymptomLikely causeUseful response
Advantages are extremely largeBad reward scale, terminal mask, or critic fitInspect TD residuals and reset GAE at episode boundaries
Critic loss falls but return does not improveDistribution mismatch or actor exploiting errorsTrack realized returns and use twin critics
Q-values grow far beyond possible returnsBootstrapping or terminal-handling bugVerify detachment, masks, discount, and target updates
Actor saturates at action boundsCritic overestimation or excessive actor updatesLower actor rate and delay actor updates
Gaussian entropy collapses earlyTemperature too small or actor step too largeMonitor log standard deviation and entropy
DDPG evaluates worse than trainingExploration noise was left enabledRemove action noise during evaluation
GAE behaves like noisy Monte Carloγλ\gamma\lambda is too largeLower λ\lambda or improve the critic
GAE is biased and short-sightedλ\lambda is too small or critic is weakIncrease λ\lambda and critic capacity carefully

Use separate actor and critic optimizers. Detach Bellman targets, GAE advantages, value targets, and policy terms used only for temperature tuning. During a pathwise actor update, preserve gradients through the critic's action input while preventing the actor optimizer from changing critic parameters.

For true terminal transitions,

y=r.y=r.

Administrative time-limit truncations may still have future value and should not automatically be masked as terminal when the environment distinguishes them.

Finally, actor-critic results can vary substantially across seeds. Report multiple runs, separate training returns from evaluation returns, and log both critic predictions and realized discounted returns.

The central progression is

Gt⏟Monte Carlo⟶Gt−V(st)⏟baseline⟶rt+γV(st+1)−V(st)⏟one-step critic⟶∑l(γλ)lδt+l⏟GAE.\underbrace{G_t}_{\text{Monte Carlo}} \longrightarrow \underbrace{G_t-V(s_t)}_{\text{baseline}} \longrightarrow \underbrace{r_t+\gamma V(s_{t+1})-V(s_t)}_{\text{one-step critic}} \longrightarrow \underbrace{\sum_l(\gamma\lambda)^l\delta_{t+l}}_{\text{GAE}}.

For replay-based continuous control, the corresponding progression is

Q(s,μ(s))⏟DDPG⟶min⁡jQj(s,μ(s))⏟TD3⟶min⁡jQj(s,a)−αlog⁡π(a∣s)⏟SAC.\underbrace{Q(s,\mu(s))}_{\text{DDPG}} \longrightarrow \underbrace{\min_jQ_j(s,\mu(s))}_{\text{TD3}} \longrightarrow \underbrace{\min_jQ_j(s,a)-\alpha\log\pi(a\mid s)}_{\text{SAC}}.

Actor-critic methods work by making two approximators improve one another: the critic turns experience into a useful local learning signal, and the actor changes the data distribution toward actions the critic values. Their strength and instability both come from this feedback loop.