Modern Deep Reinforcement Learning/Continuous Control: DDPG and TD3

Lesson 5.31,939 words

Continuous Control: DDPG and TD3

When actions are real-valued, the argmaxaQ(s,a)\arg\max_a Q(s,a) in Q-learning becomes an optimization problem on every step. This lesson builds the off-policy actor-critic family that sidesteps it: the deterministic policy gradient and DDPG, which replaces the max with a learned actor, and the three fixes of TD3 that counter the value overestimation DDPG inherits.

╌╌╌╌

Deep Q-networks act by computing — they enumerate the action values in a state and take the largest. That works when the action set is a handful of discrete choices; it fails when actions are continuous. A robot arm commands a torque on each of seven joints; a quadruped commands a real vector; a car commands a steering angle and a throttle. The maximization over is then an inner optimization problem, solved from scratch on every environment step — intractable in any practical loop.

The policy-gradient methods lesson already gave one escape: parameterize a policy directly and it can output a Gaussian over continuous actions, no max required. The actor-critic and PPO lesson made that policy a deep network and toured this continuous-control family in a single closing section. This lesson and its companion treat it properly. The three methods in this family — DDPG, TD3, and SAC — share one structural idea: keep a Q-critic , but replace its intractable inner max with a learned actor that produces the maximizing action directly. Because the critic is a Q-function, all three learn off-policy from a replay buffer, which is what makes them far more sample-efficient than on-policy PPO on the control benchmarks they dominate. Here we build the first two — DDPG and the overestimation-fixing TD3 — and leave SAC and the methods layered on this template to the companion.

The obstacle. With discrete actions (left) is a lookup over a few values; with continuous actions (right) it is an optimization over a continuum, run on every step. The continuous-control family replaces that max with a learned actor.

The deterministic policy gradient

Policy-gradient methods so far learned a stochastic policy and climbed the expectation . The score-function estimator behind it averages over sampled actions, and its variance grows with the dimension of the action space — a nuisance in high-dimensional control. Silver et al. (2014) showed that if the policy is deterministic, written , the policy gradient takes a simpler and lower-variance form.1 A deterministic actor commits to one action per state, , and the performance objective is the expected value of that action under the critic,

where is the state distribution induced by whatever policy fills the replay buffer. Because the action is a deterministic function of , the gradient flows through it by the chain rule — no score-function trick, no integral over actions:

Read the two factors. is the direction in action space that raises the critic's value; translates that change in action into a change in the actor's weights. The composition is one backpropagation: differentiate the critic with respect to its action input, then continue backward through the actor. This composition escapes the — instead of searching the action space, the actor is trained by gradient ascent to output the maximizer, and the critic's action-gradient is the training signal.

The deterministic policy gradient as one backward pass. The actor feeds an action into the critic ; the critic's action-gradient flows back through the actor's Jacobian to update , so the actor learns to output the value-maximizing action.

DDPG: a DQN for continuous actions

Deep deterministic policy gradient (DDPG) is the deterministic policy gradient made deep and off-policy, assembled from the same parts that stabilized DQN.2 It runs four networks: an actor , a critic , and a slow-moving copy of each — the target actor and target critic — used only to form the learning target. Transitions collected by the agent are stored in a replay buffer and sampled in minibatches, exactly as in DQN, which decorrelates the updates and lets each transition train the networks many times.

The critic is trained by regression toward a bootstrapped target, the continuous-action analog of the DQN target. Where DQN uses , DDPG replaces the max with the target actor's action:

The actor is trained by the deterministic policy gradient — ascend the critic through the actor — sampling states from the same buffer:

Target networks by soft update

DQN copies the online weights into the target network in a hard jump every few thousand steps. DDPG instead updates the targets softly on every step, blending a small fraction of the online weights in:

The targets therefore track the online networks slowly and smoothly. This keeps the bootstrapped target stable: the critic regresses toward a value produced by weights that change far more slowly than its own, damping the feedback loop that would otherwise diverge.

Exploration for a deterministic actor

A deterministic policy has no built-in exploration — asked for an action in a state, it returns the same one every time. DDPG explores by adding noise to the action it actually sends to the environment, while keeping the clean for learning:

with a zero-mean noise process (the original paper used temporally correlated Ornstein–Uhlenbeck noise; uncorrelated Gaussian noise works about as well in practice). Exploration is thus bolted on externally, a design choice SAC will later reject.

The DDPG architecture. An actor and critic each have a slow target copy; transitions go into a replay buffer; sampled minibatches train the critic toward and the actor up ; exploration noise is added to the environment action.
Algorithm:DDPG\textsc{DDPG} — off-policy deterministic actor-critic for continuous control
  1. 1
    input: actor μθ\mu_\theta, critic QϕQ_\phi, soft-update rate τ\tau, discount γ\gamma
  2. 2
    initialize targets θθ\theta' \gets \theta, ϕϕ\phi' \gets \phi; empty replay buffer D\mathcal{D}
  3. 3
    for each step do
  4. 4
    observe ss, select aμθ(s)+Na \gets \mu_\theta(s) + \mathcal{N}
    exploration noise
  5. 5
    execute aa, observe rr, ss'; store (s,a,r,s)(s,a,r,s') in D\mathcal{D}
  6. 6
    sample a minibatch of (s,a,r,s)(s,a,r,s') from D\mathcal{D}
  7. 7
    yr+γQϕ(s,μθ(s))y \gets r + \gamma\, Q_{\phi'}(s', \mu_{\theta'}(s'))
    Qϕ0Q_{\phi'} \gets 0 if ss' terminal
  8. 8
    ϕϕηϕ(Qϕ(s,a)y)2\phi \gets \phi - \eta\,\nabla_\phi\, (Q_\phi(s,a) - y)^2
    critic regression
  9. 9
    θθ+ηθQϕ(s,μθ(s))\theta \gets \theta + \eta\,\nabla_\theta\, Q_\phi(s, \mu_\theta(s))
    ascend critic
  10. 10
    ϕτϕ+(1τ)ϕ\phi' \gets \tau\phi + (1-\tau)\phi'
  11. 11
    θτθ+(1τ)θ\theta' \gets \tau\theta + (1-\tau)\theta'

DDPG solved control problems DQN could not touch, but it earned a reputation for being brittle: sensitive to hyperparameters, prone to sudden collapse, and — the central diagnosis of the next method — systematically overestimating its own values.

TD3: three fixes for overestimation

The failure mode DDPG inherits from Q-learning is overestimation bias. The critic is noisy, and the actor is trained to maximize it. Any state where the critic happens to overshoot the true value becomes a target the actor climbs toward, and the bootstrap then propagates that inflated value backward through the Bellman update. Errors that should average out instead compound, because the maximization systematically selects for them. Twin-delayed DDPG (TD3) is DDPG plus three targeted fixes for this.3

Clipped double-Q learning

The main fix is the same idea as double Q-learning: do not let a single noisy critic evaluate its own maximizing action. TD3 learns twin critics and with independent initializations, and forms the target from the minimum of the two:

Both critics are then regressed toward this same . Taking the minimum is deliberately pessimistic: where one critic has spiked high on noise, the other is unlikely to have spiked in the same place, so the min discards the outlier. The bias does not vanish — it is pushed to the under-estimating side — but a slight, consistent underestimate does not compound the way an overestimate does, because the min never supplies an inflated value for the actor to climb.

Single vs twin critic under noise. A lone critic (left) is maximized at its noisy peak, so the target inherits the overshoot; twin critics (right) rarely spike together, and taking the elementwise minimum (lower envelope) clips the peak back toward the true value.

For example, suppose the true value of the greedy target action is , and each critic estimates it with independent zero-mean noise. Say the two critics happen to read (a overshoot) and (a undershoot). A single-critic DDPG target would use whichever critic the actor maximized — and since the actor was trained to maximize the critic, it is biased toward the one reading high, so the effective target inflates toward . TD3's target takes , a slight underestimate of . Now iterate the bootstrap. An overestimate feeds forward: next step the target built on pushes the critic to fit , and the actor climbs the inflated surface, so the error grows. An underestimate does not: the target built on pulls the critic down, and the actor cannot exploit a value the min never inflates, so the error stays bounded and self-corrects as more data arrives. Averaged over many noisy reads, for correlated-but-not-identical estimates — the min is a deliberately conservative estimator, and conservative is safe here in a way optimistic is not.

Delayed policy updates

The second fix addresses a coupling problem. The actor is trained on the critic, and the critic is a moving target; if both change at the same rate, the actor chases a value estimate that has not yet settled, and their errors feed each other. TD3 updates the policy less often than the critics — typically one actor (and target) update for every two critic updates. Letting the value estimates converge before they steer the policy reduces the variance the actor accumulates from a still-thrashing critic.

Delayed policy updates with delay d=2. The critics update every step; the actor and all target networks update once every two steps, after the critics have partly settled. The policy chases a steadier value estimate, so the coupled actor-critic loop accumulates less variance.

Target-policy smoothing

The third fix hardens the target against the actor exploiting sharp, spurious peaks in the critic. A deterministic target action can land exactly on a noise spike, and nothing prevents that spike from entering the target. TD3 smooths the target by adding clipped noise to the target action, so the value is averaged over a small neighborhood of actions rather than read off a single point:

This encodes a regularizing prior: similar actions should have similar values, so a peak one clipped-noise step wide is treated as an artifact, not a real maximum. The clip keeps the perturbation local. Note this noise is on the target action inside the Bellman update — distinct from the exploration noise added to the behavior action.

Algorithm:TD3\textsc{TD3} — twin-delayed DDPG, three fixes over DDPG
  1. 1
    input: actor μθ\mu_\theta, twin critics Qϕ1,Qϕ2Q_{\phi_1}, Q_{\phi_2}, delay dd, noise σ,c\sigma, c
  2. 2
    initialize targets θ,ϕ1,ϕ2\theta', \phi_1', \phi_2'; empty buffer D\mathcal{D}; step counter t0t \gets 0
  3. 3
    for each step do
  4. 4
    select aμθ(s)+Na \gets \mu_\theta(s) + \mathcal{N}, execute, store (s,a,r,s)(s,a,r,s') in D\mathcal{D}
  5. 5
    sample a minibatch from D\mathcal{D}
  6. 6
    a~μθ(s)+clip(N(0,σ),c,c)\tilde a \gets \mu_{\theta'}(s') + \clip(\mathcal{N}(0,\sigma), -c, c)
    target smoothing
  7. 7
    yr+γmini=1,2Qϕi(s,a~)y \gets r + \gamma\,\min_{i=1,2} Q_{\phi_i'}(s', \tilde a)
    clipped double-Q
  8. 8
    for i=1,2i = 1, 2 do
  9. 9
    ϕiϕiηϕi(Qϕi(s,a)y)2\phi_i \gets \phi_i - \eta\,\nabla_{\phi_i}\,(Q_{\phi_i}(s,a) - y)^2
  10. 10
    if tmodd=0t \bmod d = 0 then
    delayed policy update
  11. 11
    θθ+ηθQϕ1(s,μθ(s))\theta \gets \theta + \eta\,\nabla_\theta\, Q_{\phi_1}(s, \mu_\theta(s))
  12. 12
    ϕiτϕi+(1τ)ϕi\phi_i' \gets \tau\phi_i + (1-\tau)\phi_i' for i=1,2i = 1, 2
  13. 13
    θτθ+(1τ)θ\theta' \gets \tau\theta + (1-\tau)\theta'
  14. 14
    tt+1t \gets t + 1

TD3 keeps DDPG's deterministic actor and off-policy replay, adds no new objective, and turns a brittle method into a reliable one. On the MuJoCo continuous-control benchmarks it substantially outperforms DDPG, and the three fixes are cheap enough that TD3 is often the first thing to try when DDPG misbehaves.

Where this leaves us

DDPG and TD3 share one skeleton: an off-policy Q-critic trained from a replay buffer, a deterministic actor trained to output the critic-maximizing action (the escape from ), and slow target networks to keep the bootstrap from diverging. DDPG proves the idea works; TD3 makes it reliable by refusing to trust a single noisy critic — twin critics and a minimum target, delayed policy updates, and target smoothing.

Both actors are deterministic, so exploration has to be bolted on as external action noise. The next method rejects that: SAC learns a genuinely stochastic policy, folds exploration into the objective through an entropy bonus, and turns out to be the more robust choice. That maximum-entropy objective, the reparameterized squashed-Gaussian actor, automatic temperature tuning, and the distributional-critic / ensemble / pixel extensions built on this template continue in Continuous Control: SAC and Beyond.

Footnotes

  1. Silver et al. (2014), Deterministic Policy Gradient Algorithms, ICML — the deterministic policy gradient theorem, showing that for a deterministic policy the gradient of performance reduces to , a lower-variance estimator than the stochastic score-function form; also Morales, Grokking Deep Reinforcement Learning, Ch. 12.
  2. Lillicrap et al. (2016), Continuous Control with Deep Reinforcement Learning, ICLR — DDPG: the deterministic policy gradient made deep and off-policy with a replay buffer, actor and critic target networks updated by soft (Polyak) averaging , and Ornstein–Uhlenbeck exploration noise; Morales, Ch. 12, DDPG: Approximating a deterministic policy.
  3. Fujimoto et al. (2018), Addressing Function Approximation Error in Actor-Critic Methods, ICML — TD3: clipped double-Q learning (twin critics, minimum target), delayed policy and target updates, and target-policy smoothing via clipped noise on the target action, together correcting DDPG's overestimation bias on the MuJoCo benchmarks; Morales, Ch. 12, TD3: State-of-the-art improvements over DDPG.

╌╌ END ╌╌