Skip to content

Deep reinforcement learning and decision models · Method reference · DRL003 · Architecture

Dueling DQN architecture

Factor action values into a state-value stream and action-dependent advantage stream, allowing a network to represent how good a state is even when several actions have similar consequences.

Runs in CodeSplash Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Runs in CodeSplash
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through decide.offline_rl, decide.rl_dqn. 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

Factor action values into a state-value stream and action-dependent advantage stream, allowing a network to represent how good a state is even when several actions have similar consequences. This is an architectural modification compatible with several Q-learning algorithms.

Question / hypotheses

Can shared state-value learning improve generalization across actions? The question concerns representation and control performance; the architecture does not itself specify exploration, replay, or an inferential null.

Architecture / computational structure

A common feature encoder branches into a scalar value head and an action-width advantage head. An aggregation layer combines them into identifiable Q-values by subtracting the mean advantage. The two streams are jointly trained by the selected TD-learning objective.

Assumptions

Discrete action values share meaningful state information. The raw decomposition Q=V+A is not identified because constants can move between streams; the aggregation convention resolves this redundancy. A useful feature encoder and adequate transition coverage are still required.

Formula / computational definition

Q(s,a)=V(s)+A(s,a)−∣A∣−1∑bA(s,b)Q(s,a)=V(s)+A(s,a)-|\mathcal A|^{-1}\sum_bA(s,b). The mean-subtracted advantage has zero mean over actions, making the scalar stream equal to the mean action value under this convention. The training target may be DQN or Double DQN.

Parameters and notation

Learned parameters include shared encoder weights and separate value/advantage heads. Hyperparameters include each head’s width, normalization convention, optimizer, and the surrounding Q-learning settings. The number of actions determines advantage output size; it is not a latent component count.

Fitting, fine-tuning, and adaptation

Reuse a compatible encoder when moving from a single-stream checkpoint, but initialize or refit the new heads. If the action set changes, rebuild the advantage head and aggregation. Frozen-encoder transfer and full fine-tuning should be evaluated separately, with replay refreshed for new actions.

How to use and calibrate

Compare with a capacity-matched single-stream Q-network using the same target rule and data budget. Analyze performance in states where action values are similar versus sharply different. Track both streams and the combined output to catch unstable internal scales.

Example application

Represent game states in which many joystick actions have nearly identical immediate effects. The paired forward-pass example confirms that adding a constant to every raw advantage leaves the aggregated Q-values unchanged.

Interpretation / pitfalls

Watch out

The value stream is an aggregation-defined quantity, not automatically the value of the current behavior policy. Dueling is not Double DQN: one changes architecture, the other the bootstrap target. Counting both is justified only while retaining that distinction.

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
value=np.array([2.,1.])[:,None]; advantage=np.array([[1.,2.,3.],[-1.,0.,1.]])
q=value+advantage-advantage.mean(axis=1,keepdims=True)
shifted=advantage+7.
assert np.allclose(q,value+shifted-shifted.mean(axis=1,keepdims=True))
print(q)
R

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

value <- c(2,1); advantage <- matrix(c(1,2,3,-1,0,1),2,byrow=TRUE)
q <- value+advantage-rowMeans(advantage)
shifted <- advantage+7
stopifnot(max(abs(q-(value+shifted-rowMeans(shifted))))<1e-10); print(q)

Sources

From the CodeSplash reference, entry DRL003.