Skip to content

Deep reinforcement learning and decision models · Method reference · DRL008 · Algorithm

Deep deterministic policy gradient (DDPG)

Extend deep value learning to continuous actions using a deterministic actor that proposes actions and a critic that evaluates state–action pairs.

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Extend deep value learning to continuous actions using a deterministic actor that proposes actions and a critic that evaluates state–action pairs. Replay and target networks stabilize the actor–critic updates and allow reuse of older interactions.

Question / hypotheses

Which continuous action maximizes expected return, and how can the actor follow the critic’s gradient with respect to action? The resulting gradient is a policy-improvement signal, not a causal estimate or a calibrated test statistic.

Architecture / computational structure

A deterministic actor maps observations to bounded actions; a critic combines observations and actions to predict Q. Delayed copies of both networks produce targets. Replay transitions train the critic, while differentiating its value at actor-generated actions updates the actor.

Assumptions

Continuous action coordinates and bounds are meaningful, the critic is differentiable in actions, and exploration covers useful regions. The actor can exploit inaccurate critic gradients outside replay support. Environment/action normalization and genuine terminal masks must be consistent.

Formula / computational definition

y=r+γ(1−d)Qϕˉ(s′,μθˉ(s′))y=r+\gamma(1-d)Q_{\bar\phi}(s^\prime,\mu_{\bar\theta}(s^\prime)). Minimize (Qϕ(s,a)−y)2(Q_\phi(s,a)-y)^2 for the critic and −E[Qϕ(s,μθ(s))]-\mathbb E[Q_\phi(s,\mu_\theta(s))] for the actor; freeze critic parameters during the actor step while allowing action gradients through it.

Parameters and notation

Learned quantities are actor and critic weights; target copies follow a delayed/averaged update. Hyperparameters include separate learning rates, target smoothing, replay size, batch size, discount, exploration-noise scale/process, action bounds, and network width. Noise is for exploration rather than stochastic policy likelihood.

Fitting, fine-tuning, and adaptation

Warm-start compatible observation features and actor weights, but refresh data and adapt the critic before aggressively optimizing the actor under a changed task. Synchronize target networks and tune exploration for the new action regime. Compare frozen-encoder versus full-network transfer.

How to use and calibrate

Evaluate deterministic and exploratory behavior separately. Track critic values, TD losses, action saturation, replay coverage, and return across seeds. Compare with TD3 and SAC under the same action normalization and environment-interaction budget.

Example application

Choose continuous torques in a simulated manipulator. The example computes a critic bootstrap target and actor objective from supplied predictions; a complete implementation needs autodiff through the actor and critic, exploration, replay, and target updates.

Interpretation / pitfalls

Watch out

Single-critic overestimation and action-gradient exploitation can destabilize training. Determinism does not eliminate exploration requirements. Adding Gaussian noise after clipping changes the effective exploration distribution, and off-policy does not automatically mean reliable learning from an arbitrary fixed offline dataset.

Python and R code examples

Scope: computational component described in the application subsection; not a complete estimator, neural trainer, or environment loop. Dependencies/validation: Python with NumPy executed successfully; base R not executed. Targets and supplied network outputs are ordinary arrays here, so this does not validate automatic-differentiation boundaries.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — computational component described in the application subsection; not a complete estimator, neural trainer, or environment loop. · needs numpy

import numpy as np
reward=np.array([1.,-.2]); terminal=np.array([0.,1.]); target_critic_at_target_actor=np.array([2.,3.])
target=reward+.99*(1-terminal)*target_critic_at_target_actor
critic_prediction=np.array([1.5,.1]); critic_loss=np.mean((critic_prediction-target)**2)
critic_at_current_actor=np.array([1.8,.4]); actor_loss=-critic_at_current_actor.mean()
print(target,critic_loss,actor_loss)
R

Component demo, not a trained model — computational component described in the application subsection; not a complete estimator, neural trainer, or environment loop.

reward <- c(1,-.2); terminal <- c(0,1); target_critic_at_target_actor <- c(2,3)
target <- reward+.99*(1-terminal)*target_critic_at_target_actor
critic_prediction <- c(1.5,.1); critic_loss <- mean((critic_prediction-target)^2)
critic_at_current_actor <- c(1.8,.4); actor_loss <- -mean(critic_at_current_actor)
print(target); print(c(critic_loss=critic_loss,actor_loss=actor_loss))

Sources

From the CodeSplash reference, entry DRL008.