DDPG
Topics: Reinforcement Learning
Introduction
Deep Deterministic Policy Gradient (DDPG) is a model-free, actor-critic, off-policy, RL algorithm that trains a deterministic policy targeted at environments with continuous action spaces.
It learns both a Q-function and a policy (actor-critic): it uses off-policy data and the Bellman Equation to learn the Q-values, and uses the Q-values to learn the policy.
DDPG can be thought of as Deep Q-Learning (DQN) for continuous action spaces.
Q-Learning Part of DDPG
Starting from the Bellman equation:
In the case of discrete action spaces, is very easy to compute. But in the case of continuous action spaces, like DDPG, we cannot do that, and the optimization problem of finding the maximum Q-value and optimal action is too expensive to run every time the agent needs to make a decision.
For continuous action spaces, we approximate it with:
where is the policy.
Then, the Bellman equation becomes:
Note that is the actor neural network with parameters . Its input is the state and its output is the action . is the critic neural network with parameters . Its inputs are the state and action , and its output is the Q-value .
So, to satisfy the Bellman equation, we can update the parameters by minimizing the Mean Square Bellman Error (MSBE):
A problem that arises from this formulation is that the network that we want to update, , is the same network used on the right side of the Bellman equation. It is as if you are tracking a target, but every time the you take a step closer, it moves a step further from you. This makes learning unstable.
Therefore, the idea of target networks was introduced, which is a delayed version of the network being trained. The parameters of the target networks get updated very slowly, which makes the target stable and hence the training stable.

The above image shows how a stored sample is used in training. The training of the thus consists of minimizing the following loss function:
The parameters of the target networks are updated via Polyak averaging, which is also known as a soft update:
where is a constant close to , for example or .
The final point to discuss in this section is that, since DDPG is an off-policy algorithm, it uses a replay buffer to store past experiences for training. Training data is sampled randomly from the buffer to update the parameters.
Why are we able to train off-policy and use past experience which is obtained using outdated policies?? Because the Bellman equation does not care which transition tuples are used since the optimal value should satisfy the Bellman equation for all possible transitions.
Policy Learning Part of DDPG
In DDPG, the Q-value is used to learn the policy. The goal is to learn a deterministic policy which maximizes . Since the action space is continuous, we perform gradient ascent with respect to policy parameters :

The above image shows the training structure for the policy in DDPG.
Exploration Tricks
- To improve exploration throughout training, we can add noise to the policy
- Another trick to improve exploration at the beginning of training is to take actions which are sampled from a Continuous Uniform Distribution over valid actions, until a fixed number of steps is reached (start_steps). After that, we return to normal DDPG exploration with noise.
Pseudocode


References
Backlinks
Notes that reference this page.
Connections
Direct relationships to this note.