5.2.1 · D1Deep & Advanced RL

Foundations — Deep Q-Networks (DQN)

2,131 words10 min readBack to topic

Before you can read the parent note, you must be able to read its symbols out loud in plain English. This page is a dictionary — but a dictionary where every word comes with a picture and a reason it exists. We build strictly bottom-up: nothing appears until the thing it leans on is already defined.


1. The stage: state, action, reward

Everything in reinforcement learning happens as a loop between two characters: an agent (the learner) and an environment (the world it lives in).

Figure — Deep Q-Networks (DQN)

Look at the loop above: the agent sees , picks , the world replies with a reward and a new state (read "s-prime" — the state that comes next). That primed symbol is used constantly in the parent, so lock it in:

One full hop — "I was here, did this, got this, ended up there" — is called a transition. Remember that 4-tuple; the whole replay buffer is a pile of them.


2. Following a rule: the policy


3. Caring about the future: discount

A reward now and a reward in a thousand steps are not worth the same. We shrink far-off rewards with a discount factor.

Figure — Deep Q-Networks (DQN)

Why and not, say, subtracting a constant each step? Because multiplying repeatedly is what "compounding decay" looks like — the same shape as radioactive half-life or interest. Each extra step of delay multiplies the weight by another , so a reward steps out is worth of its face value. Two cases to feel:

  • : only the immediate reward matters — a total short-term thinker.
  • : the distant future matters almost as much as now — a patient planner.

DQN typically uses or .


4. The star of the show: the value

Now we can build the single most important symbol.

The full formula in the parent is a sum with an in front and a inside. Let's decode those two symbols so they stop being scary.

So the parent's line reads, in English: " is the average, over all the randomness, of the sum of all future rewards, each discounted by how far away it is."

The vertical bar reads "given that" — given we start in state and take action at time .


5. The best possible plan: and

This is exactly why the parent's Bellman Equation uses : it assumes optimal play from the next state onward. And here is the hidden restriction that trips people up: to take a you must be able to list all the actions. That's why DQN handles only discrete action sets — you can't loop over infinitely many continuous choices.


6. The neural network: and

A table can't hold a value for every possible screen (there are astronomically many). So DQN replaces the table with a function that computes the value.

Figure — Deep Q-Networks (DQN)

7. Learning signals: TD error and the loss


8. Where the data lives: replay buffer and


How the pieces feed the topic

state s

action-value Q of s a

action a

reward r

discounted return

discount gamma

policy pi

max over next actions

Bellman optimality

bootstrap target y

network params theta

Q with theta

frozen params theta minus

squared TD loss

replay buffer D

epsilon greedy

Deep Q-Networks


Equipment checklist

Read each cue, answer in your head, then reveal.

What does mean and what picture goes with it?
The next state — the very next screen/frame after acting.
In one line, what is ?
Expected total discounted future reward from taking in then following the policy.
Why is there a inside the return?
To shrink far-off rewards so an infinite sum stays finite and comparable.
What does compute, and what does it silently assume?
The best next-state value; it assumes we can enumerate all actions (so actions must be discrete).
Read the symbol group in plain English.
The network's guess of the value of using knob settings .
How does differ from , and why keep it?
It's a frozen older copy used for the target, giving a steady reference so training doesn't chase a moving goal.
Define the TD error .
: improved target minus current guess.
Why sample randomly from the buffer instead of using frames in order?
Consecutive frames are correlated; shuffling restores i.i.d.-like variety and reuses data.
What does control and why do we need it?
Probability of a random action; it forces exploration of untried actions.
What does stand for?
The average outcome over all the environment's randomness.

When every reveal feels obvious, you're ready for Deep Q-Networks (DQN) itself.