Skip to content

Continuous actions: DDPG, TD3 and SAC

When the action is a number - a steering angle, a dose, a price - you can't take a max over actions. DDPG climbs a critic with a deterministic actor; TD3 fixes its overestimation; SAC adds entropy and a stochastic actor.

Advanced ~15 min8 steps

What runs in CodeSplash

You will be able to

  • Explain why DQN's max over actions fails for continuous actions
  • Compute DDPG's critic target and actor objective
  • Name TD3's three changes and the problem each addresses
  • Write SAC's soft target and explain what the temperature α does

Read first

01

No max over a continuum

Read

DQN's target takes max⁡a′Q(s′,a′)\max_{a'} Q(s', a') over a handful of actions. With an action that is a real number, or a vector of them, that max is an optimization problem at every step. Continuous-control methods train an actor that outputs the action directly and a critic Q(s,a)Q(s, a) that judges it, both off-policy from a replay buffer.

These methods are explained here: the Policy learning studio's environments have a few discrete actions, where DQN and PPO fit.

02

DDPG

Read

DDPGDeep deterministic policy gradient (DDPG)Continuous-action actor–critic: the actor outputs one action and climbs the critic's Q; replay and target networks keep it stable. uses a deterministic actor μ(s)\mu(s). The critic regresses on a target built with the target actor and critic:

y=r+γ (1−done) Qtarget(s′,μtarget(s′)).y = r + \gamma\,(1 - \text{done})\, Q_{\text{target}}\big(s', \mu_{\text{target}}(s')\big).

The actor climbs the critic: it maximizes Q(s,μ(s))Q(s, \mu(s)), so its loss is −Q(s,μ(s))‾-\overline{Q(s, \mu(s))}. In the reference's example, targets are 2.98 and −0.2 (the second step is terminal), the critic loss 1.140 and the actor loss −1.1. Exploration comes from noise added to the actor's action.

03

TD3: three fixes

Read

DDPG's actor exploits any spot where the critic overrates an action, and the critic's targets inherit the error. TD3Twin delayed DDPG (TD3)DDPG with two critics (take the smaller target), noise on the target action, and fewer actor updates than critic updates. adds:

  1. Clipped double Q: two critics, and the target uses the smaller of their values.
  2. Target policy smoothing: clipped noise on the target action, so the target averages over a small neighborhood.
  3. Delayed actor updates: the actor and target networks update less often than the critics.

In the reference's example, noisy target actions are clipped back into range at 1 and −1, and the targets use the smaller critic: 3.475 and 1.98.

04

SAC: reward plus entropy

Read

Soft actor–criticSoft actor–critic (SAC)Actor–critic that maximizes reward plus policy entropy, with twin critics and a stochastic actor; α sets the entropy weight. maximizes reward plus the policy's entropy, weighted by a temperature α. Its actor is stochastic, and its target uses twin critics and subtracts α times the next action's log-probability:

y=r+γ (1−done)(min⁡(Q1,Q2)(s′,a′)−αlog⁡π(a′∣s′)),a′∼π(⋅∣s′).y = r + \gamma\,(1 - \text{done})\big(\min(Q_1, Q_2)(s', a') - \alpha \log \pi(a' \mid s')\big), \quad a' \sim \pi(\cdot \mid s').

The entropy term rewards keeping options open. In the reference's example the soft targets are 2.921 and, at a terminal step, 0; the actor loss is −1.58. Many implementations tune α automatically toward a target entropy.

05

Predict: one critic or two

Predict

Predict first

TD3's target takes the smaller of two critics' values. What does that do to the targets?

It removes the critic's upward bias entirelyIt counters upward bias, at the risk of some underestimationIt has no effect on bias
Reveal

It counters upward bias, at the risk of some underestimation. The min of two noisy estimates leans low, which is safer for an actor that hunts for overrated actions than leaning high.

06

What runs here

Read
07

Check: continuous control

Checkpoint

Check yourself

How is DDPG's actor trained?

Show the answer

Answer: a

The actor's loss is −Q(s, μ(s)); its gradient flows from the critic into the actor's weights.

Check yourself

A non-terminal transition has reward 1. The target critic values the target actor's next action at 2, and γ = 0.9. What is DDPG's critic target?

Show the answer

Answer: 2.8

y = 1 + 0.9 × 2 = 2.8. At a terminal step the target would be 1.

Check yourself

Which set lists TD3's changes to DDPG?

Show the answer

Answer: a

The second set belongs to Rainbow, the third to SAC, the fourth to PPO.

Check yourself

TD3: reward 0.5, γ = 0.9, the two target critics give 2.5 and 2.1. What is the target?

Show the answer

Answer: 2.39

y = 0.5 + 0.9 × min(2.5, 2.1) = 0.5 + 0.9 × 2.1 = 0.5 + 1.89 = 2.39.

Check yourself

In SAC, what happens as the temperature α grows?

Show the answer

Answer: a

α weighs entropy against reward. Large α favors spread-out actions; α near 0 recovers a reward-only objective.

Check yourself

What does SAC's target subtract from the smaller critic value?

Show the answer

Answer: a

Subtracting α·log π adds the entropy bonus to the bootstrapped value: rare (low log-probability) actions earn more.

08

Recap

Recap
  • Continuous actions rule out a max over actions; an actor proposes, a critic judges.
  • DDPG: deterministic actor climbing the critic, with target networks and replay.
  • TD3: twin critics (take the min), smoothed target actions, delayed actor updates.
  • SAC: stochastic actor, reward plus α-weighted entropy, twin critics.

Concepts in this lesson