Code
Code
A deterministic actor and a critic
With a continuous action, the greedy step of Q-learning, , becomes an optimization problem over at every time step. DDPG avoids solving it by training a second network to do it. It keeps two networks:- The actor maps the 28-number state to an action. Its output layer is a , so each output lies in , and it is rescaled to m/s and rad/s.
- The critic maps a state and an action to an estimate of the action value of the actor’s policy.
The deterministic policy gradient
The actor should maximize the expected return from the start states, where is the distribution of start states and is the value of following . The deterministic policy gradient theorem (Silver et al., 2014) gives its gradient as an expectation over , the discounted distribution of states visited under : Read it as the chain rule. The critic says in which direction a small change of would raise the value, and says how to change the actor’s weights to move its output that way. Compare it with the policy gradient theorem of the REINFORCE section, for a stochastic policy: That gradient raises the log-probability of each sampled action in proportion to its value. It needs the value only at the actions the robot took, and it averages over many sampled actions to find the direction. The deterministic gradient needs one action per state, but it needs the slope of the value with respect to the action. Only a differentiable critic can supply that slope. The log-probability term is gone because a deterministic policy has no distribution over actions to differentiate. DDPG replaces with the critic , so the actor’s loss is simply averaged over a batch of states.Learning the critic
The critic learns by temporal differences, like the Q-table. For a stored transition the target is and the critic minimizes over a batch. The difference is the TD error of TD prediction, and the critic’s loss is its square. Compared with the Q-learning target, is replaced by the value of the action the actor would take in . As before, a goal or a collision cuts the bootstrap term and a timeout does not. In the MDP chapter’s terms, the critic does policy evaluation for . Its target is a one-sample estimate of the right side of the Bellman expectation equation for action values, with the stored next state in place of the sum and a network in place of the table. The actor step is policy improvement. Policy iteration in the navigation MDP section set exactly. The actor takes one gradient step toward a larger instead. DDPG alternates the two steps without running either to convergence, which makes it a form of approximate policy iteration. and are target networks: slowly moving copies of the critic and the actor. Three more pieces keep training stable:- A replay buffer stores the last 200,000 transitions, and each update draws a random batch of 256 from it. Consecutive steps of one trajectory are strongly correlated, and random batches break that correlation. Reusing old transitions is allowed because DDPG, like Q-learning, is off-policy. The target uses , the action of the current target actor, not the action stored in the buffer. A transition collected by an older, noisier policy is therefore still a valid sample of the dynamics. REINFORCE cannot reuse transitions this way, because its gradient is an expectation over the current policy’s own actions.
- After each update the target weights move a fraction toward the learned weights, . The targets then change slowly instead of chasing the critic they train.
- The deterministic actor never explores by itself, so during training Gaussian noise with standard deviation 0.2 is added to its two outputs before rescaling. Lillicrap et al. used temporally correlated Ornstein-Uhlenbeck noise. Independent noise is simpler and works here. The first 5000 steps use uniformly random actions to fill the buffer.
Code
Code
Code
Code
Code
Code
References
- Lillicrap, T., Hunt, J., Pritzel, A., Heess, N., Erez, T., et al. (2015). Continuous control with deep reinforcement learning. arXiv [cs.LG]. Link
- Silver, D., Lever, G., Heess, N., Degris, T., Wierstra, D., et al. (2014). Deterministic Policy Gradient Algorithms. Proceedings of the 31st International Conference on Machine Learning. Link
Found an error on this page? Report an issue.

