Deep Q-Networks
Tabular Q-learning works great when we can list every state-action pair. The agent stores one value for each pair, then updates that table as it learns.
But real-world problems do not look like tiny tables. Games, robotics, and language can have millions of states, high-dimensional observations, or continuous inputs. We cannot store a Q-table that big.
So DQN replaces the table with a function approximator, usually a neural network. The input is the state. The output is a predicted Q-value for each available action.
Instead of a lookup table, the agent learns parameters so that
DQN architecture
A Q-table becomes a Q-network
Choose an observation type. The output stays the same: one estimated Q-value for each available action.
State observation
84 x 84 pixels
Input shape: 7,056 numbers
Q-network
Q(s,a; theta)
Predicted action values
Greedy action
fire
The network receives a state observation and outputs one predicted value for each discrete action. In an Atari game, the input might be pixels and the output might be values for left, right, fire, and stay. The greedy action is the action with the largest predicted Q-value.
DQN still learns from the Bellman optimality target. For a sampled transition , the target is usually written as
The prediction being trained is . The loss asks the online network to move that prediction toward the target:
Equation walkthrough
DQN trains a prediction toward a Bellman target
Click each term to see how the target and loss connect.
Bellman target
what the network should move toward
The target is immediate reward plus a bootstrapped estimate of the best future value.
Terms
The update step adjusts the network weights in the direction that reduces prediction error. The temporal-difference error, or TD error, is the gap between the target value and the current Q estimate.
If the TD error is zero, there is no update. If it is positive, the update increases . If it is negative, the update decreases that estimate.
Equation walkthrough
The TD error tells the Q-network which way to move
Click each part of the update rule to see how squared-error learning becomes a weight update.
TD error
target minus current estimate
If this is zero, there is no update. If it is positive, increase the current Q estimate. If it is negative, decrease it.
Terms
TD error = 0
no update
TD error > 0
increase Q
TD error < 0
decrease Q
DQN still needs exploration, so it often chooses actions with an epsilon-greedy rule. With probability , the agent takes a random action. With probability , it takes the greedy action:
A typical decay schedule is , which starts exploratory and becomes greedier over time.
Exploration schedule
DQN still uses epsilon-greedy
Move through training time to see how random exploration decays while greedy Q-value action selection takes over.
epsilon
0.286
random action
29%
greedy action
71%
Deep Q-learning algorithm
DQN turns interaction into supervised-style updates
Step through the training loop from acting to replay to target-network updates.
Initialize
Initialize Q-network weights theta, set target weights theta-minus equal to theta, and create an empty replay buffer.
theta = random weights
theta_minus = theta
D = empty replay buffer
What Changes From Tabular Q-Learning
The update target is familiar: immediate reward plus discounted future value. The representation changes. A DQN generalizes across similar observations instead of treating every exact state as a separate table row.
What is the main role of the neural network in DQN?