TL;DR
DDPG learns a policy that outputs one continuous action per state, along with a critic that scores state-action pairs. The actor is improved by following the critic's gradient with respect to the action. It uses the replay buffer and target networks from the deep Q-network, so it can learn from stored experience. It is the standard way to apply deep reinforcement learning to continuous control, such as torques on a robot arm.
Where you'll see it: simulated robot control, where the action is a vector of joint torques, and any continuous-action task where a discrete max over actions is impractical.
Intuition
Think of a driver and a coach. The driver (the actor) decides how hard to turn the wheel. The coach (the critic) watches the result and says how much better or worse the outcome was. The coach does not just score the outcome. The coach also says which direction to move the wheel to do better. The driver takes that advice and adjusts, and the coach keeps learning from the driver's new results.
Why is this needed? In Q-learning the policy is "take the action with the largest ". With a discrete set of actions that is a quick lookup. With continuous actions, such as a torque in the range from minus one to one, finding the largest needs an optimisation at every step. DDPG avoids that search by learning an actor that outputs the best action directly, and it trains the actor using the critic's gradient.
The result is a deterministic policy: for a given state it always outputs the same action. That keeps the update cheap and low-variance. The cost is that exploration has to be added by hand, usually as noise on the action during training.
flowchart LR S["State s"] --> A["Actor mu(s) outputs action a"] A --> Q["Critic Q(s, a) scores it"] Q --> G["Gradient of Q with respect to a"] G --> A R["Replay buffer"] --> Q R --> A
The math
Setup
Write the actor as a deterministic map from states to actions, with parameters . Write the critic as with parameters . A stored transition is , meaning the agent took action in state , received reward and landed in . The discount factor is .
The actor is trained to maximise the expected return
where the expectation is over states drawn from the replay buffer. The critic is trained to satisfy the Bellman equation (see Bellman Equation) with the actor's action as the next-state action.
The actor update
The deterministic policy gradient, from Deterministic Policy Gradient, says that the gradient of with respect to the actor parameters is
averaged over a minibatch of states from the replay buffer. The first factor is the gradient of the critic with respect to the action, a vector the size of the action. The second factor is the Jacobian of the actor's output with respect to its parameters.
This is the Chain Rule applied to the path from the parameters, through the action, into the critic. The actor parameters are then moved uphill with a gradient ascent step, or equivalently downhill on with Gradient Descent.
The critic update
The critic is a regression onto a Bellman target. The target uses the target actor and the target critic :
The critic minimises the mean squared error between its prediction and this target,
where the targets are treated as constants, so no gradient flows through them. Squared error is the usual mean squared error loss.
Target networks and soft updates
Both target networks follow the online networks slowly. After each update the target weights move a small step toward the online weights:
with . This is the same idea as the periodic copy in the deep Q-network, but applied gradually at every step instead of every few thousand steps. A small keeps the targets stable while the online networks learn.
Exploration
Because the actor is deterministic, DDPG adds noise to the action during training. If is noise, the agent acts with , clipped to the allowed action range. The original paper used temporally correlated noise from an Ornstein-Uhlenbeck process (with and ), so that consecutive actions drift smoothly. Plain independent Gaussian noise is also common in implementations. The noise is used only to collect data. The actor and critic are trained on the data, and the test policy is the deterministic without noise.
The full loop
Each environment step stores one transition in the replay buffer. Then the agent samples a minibatch, updates the critic toward , updates the actor with the gradient above, and soft-updates both target networks. Stored transitions can be reused many times, which is what gives DDPG its sample efficiency compared with purely on-policy methods.
Worked examples
Use a linear actor with , a single state , and a fixed critic . The critic prefers actions near 1, whatever the state. Use learning rate .
- The current action is .
- The action gradient of the critic is . At this is .
- The Jacobian of the actor with respect to is .
- The actor gradient is . Gradient ascent gives .
- The new action is , closer to the critic's preferred value of 1.
Interpretation: the actor moved its output toward the action the critic scores highest, using only the critic's slope at the current action. Repeating the step gives and an action of , which is closer still.
A robot arm produces a transition with reward . The target actor's next-state action is scored by the target critic at . Use discount . The online critic currently predicts for the stored action.
- Bellman target: .
- Temporal-difference error: .
- Squared loss for this sample: . The critic's update reduces this by moving up toward .
- Suppose one target weight is and the online weight is now . A soft update with moves the target to .
Interpretation: the target is built from the target networks, so the regression goal does not move with every online update. The soft update changes the target by only a fraction of the online change, which is what keeps the critic's goal stable. The value is an illustrative choice, not a value taken from the paper.
Tradeoffs and failure modes
| Situation | What goes wrong | Better choice |
|---|---|---|
| Discrete actions | The actor's gradient needs a continuous action, and the max over a small set is easy | [[deep-q-network |
| Critic overestimates values | The actor exploits the critic's errors and the policy drifts into bad actions | Twin critics, delayed actor updates and target smoothing (the TD3 changes) |
| Multi-modal best actions | A deterministic actor can commit to one mode and miss others | A stochastic actor trained with an entropy bonus |
| Sparse rewards | Little signal reaches the critic, so the actor learns slowly | Hindsight relabelling or reward shaping |
| Hyperparameter sensitivity | Learning rates, noise scale and all interact, and runs can diverge | Careful tuning and several seeds; compare with a well-tuned baseline |
| Stale replay data | Old transitions came from an older policy and bias the critic | Smaller buffer, or prioritise recent data |
A common failure is divergence: the critic's values grow without bound, and the actor follows them. Lower learning rates, soft targets and gradient clipping are the first remedies. The critic error is also worth logging, because a rising critic loss often comes before a collapse in return.
History
Silver and colleagues introduced the deterministic policy gradient in 2014 and showed that the gradient can be written as an expectation over states, with no integral over actions. Lillicrap and colleagues combined it with the ideas that had made the deep Q-network work: a replay buffer, target networks and minibatch training. Their 2015 arXiv paper, Continuous control with deep reinforcement learning, applied the result to simulated physics tasks with continuous actions and gave the algorithm the name DDPG. The paper's algorithm box and experiments are the usual reference for the details above.
Check yourself
QuestionRecall: how does DDPG's actor differ from the policy in Q-learning, and why does that matter for continuous actions?Show answer
QuestionComputation: the reward is , the discount is , and the target critic scores the next state-action pair at . What is the Bellman target , and what is the squared error if the online critic predicts ?Show answer
QuestionWhy: why are target networks updated slowly, and what would happen if the critic used the online networks directly in its target?Show answer
QuestionApplied: a DDPG agent with a deterministic actor learns quickly, but in a task with two very different good motions it always converges to the same one. Why, and what would you change?Show answer
Sources
- Silver, Lever, Heess, Degris, Wierstra and Riedmiller, Deterministic Policy Gradient Algorithms (ICML 2014): proceedings.mlr.press
- Lillicrap et al., Continuous control with deep reinforcement learning (2015): arXiv:1509.02971
- Deep reinforcement learning (Wikipedia)