Log inStart free
LESSON 17.02 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

DQN: replay buffers and target networks

Watch a Q-network learn a grid game, with and without its two stabilizers.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 17.02 · DQN BAYSTEP 1000 · Q ERROR 0.16
01
Stage 1 of 5 · The Q-network
A Q-network reads the row and the column of a cell. It gives 4 Q-values, one per move.
Explain it simply

The agent starts at S, the goal G pays plus 1, and the pit P pays minus 1. Each cell shows 4 triangles, one per move. A stronger cobalt shade means a higher Q-value, and brick means a move that loses value. The network sees only the row and the column, so cells in one row or column share weights.

A 4 by 4 grid. Start S at the bottom left, goal G at the top right, pit P below the goal's left neighbour. At step 1,000 the Q error is 0.16.

transitions, buffertarget network, TD targetTD error, pit, negative QQ-values, greedy path
GP+1−1S012457891011131415the game · step 1,000the Q-networkrow 0row 1row 2row 3col 0col 1col 2col 3↑0.60→0.66↓0.69←0.64cell S16 ReLU unitsGP+1−1S012457891011131415the game · step 1,000the Q-networkrow 0row 1row 2row 3col 0col 1col 2col 3↑0.60→0.66↓0.69←0.64cell S16 ReLU units
Toy: the 17.C1 grid game, 16 cells, a 8–16–4 Q-network, 6,000 steps
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Q(s,⋅ ;θ)=W2 relu(W1x(s)+b1)+b2\sy{q}{out}{Q(s,\cdot\,;\theta)} = \sy{w}{param}{W_2}\,\mathrm{relu}(\sy{w}{param}{W_1}\sy{x}{data}{x(s)} + b_1) + b_2
Q(12,⋅)=(0.60, 0.66, 0.69, 0.64)Q(12,\cdot) = (0.60,\ 0.66,\ 0.69,\ 0.64)

The network maps a cell's row and column to 4 Q-values.

Common mix-ups

MYTHA replay buffer gives the agent more experience.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If replay is off, do the 16 picks spread over the buffer or bunch at the newest end?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.