Skip to content
BIASED

Deep Q-networks

Semi-gradient Q-learning, the deadly triad, replay and target networks, Double DQN and Rainbow.

From a table to a network

Tabular Q-learning needs one entry per state. An Atari stack of four 84×8484\times 84 grey frames can take 25628 224256^{28\,224} values; cart-pole has continuous angles. Values must come from a function QθQ_\theta with far fewer parameters that also generalizes across similar states.

Semi-gradient Q-learning

Treat Q-learning as regression on its own target y=r+γmax⁡a′Qθ(s′,a′)y=r+\gamma\max_{a'}Q_\theta(s',a') (or y=ry=r if terminal), holding yy fixed in the gradient:

θ←θ+α[y−Qθ(s,a)]∇θQθ(s,a).\theta\leftarrow\theta+\alpha\big[y-Q_\theta(s,a)\big]\nabla_\theta Q_\theta(s,a).

This is a semi-gradient: the full gradient of 12δ2\tfrac12\delta^2 would also move the target. With a table the update collapses to tabular Q-learning; with a network it comes from backpropagation.

The deadly triad

Function approximation + bootstrapping + off-policy data can diverge even without noise (Sutton and Barto §11.3). Toy: features 11 and 22, shared weight ww, transition 1→21\to 2 with reward 00. The update multiplies ww by 1+α(2γ−1)1+\alpha(2\gamma-1); for γ=0.9\gamma=0.9, α=0.1\alpha=0.1 that factor is 1.081.08, and after 6060 updates ww grows from 11 to about 101101. Remove any one leg and the same example converges. DQN stays inside the triad; it makes each step look more like supervised regression.

Replay and the target network

Key idea. Store transitions in a replay buffer and train on random minibatches; compute targets with a frozen copy θ−\theta^- refreshed every CC steps:

L(θ)=E(s,a,r,s′,d)∼U(D)[ℓ(r+γ(1−d)max⁡a′Qθ−(s′,a′)−Qθ(s,a))].L(\theta)=\mathbb E_{(s,a,r,s',d)\sim\mathcal U(\mathcal D)}\Big[\ell\big(r+\gamma(1-d)\max_{a'}Q_{\theta^-}(s',a')-Q_\theta(s,a)\big)\Big].

Replay breaks correlation and reuses data (off-policy). The target network holds labels still between copies — fitted Q-iteration with a network. On CartPole, without a target network ∣Q∣|Q| reached millions while true values cannot exceed 1/(1−γ)=1001/(1-\gamma)=100; with both devices the pole balances for hundreds of steps. On 49 Atari games one architecture and one hyperparameter set beat prior ML methods on 43.

Double DQN and Rainbow

E[max⁡aQ]≥max⁡aE[Q]\mathbb E[\max_a Q]\ge\max_a\mathbb E[Q]: ten equal actions with noise σ\sigma overestimate by about 1.539σ1.539\sigma. Double DQN chooses with the online net and evaluates with the target net. Dueling heads, prioritized replay, multi-step returns, distributional RL and noisy nets each fix one weakness; Rainbow combines them (median human-normalized score 223%223\% vs DQN’s 79%79\% on 57 games). Prioritized replay and multi-step targets mattered most in ablations.

Limits and next

No convergence guarantee remains. The max⁡\max needs a small discrete action set; continuous torques and softmax policies over tens of thousands of tokens need something else. Next: drop the value table and ascend the gradient of expected return — policy gradients and actor–critic, ending at PPO.

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Full notes

Answers are saved on the server and tied to this browser until you sign in.