Skip to content
StackDecode
AI & ML Atlas
Reinforcement LearningalgorithmAnimated walkthrough

Deep Q-Network (DQN)

Q-learning with a neural network, stabilised by replay and a target network.

The idea

A network maps a state (such as game pixels) to a Q value for every action. Training on consecutive, highly correlated frames is unstable, so DQN stores transitions in a replay buffer and trains on random batches, and computes targets with a slowly updated copy of the network. It reached human level on many Atari games.

loss = (r + γ·max Q_target(s′,a′) − Q(s,a))²

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Act with ε-greedy exploration and store (s, a, r, s′) in a replay buffer.
  2. 2Sample a random mini-batch from the buffer.
  3. 3Compute targets r + γ·max Q_target(s′, ·).
  4. 4Train the network to match the targets.
  5. 5Copy the weights to the target network every so often.

loss = (r + γ·max Q_target(s′,a′) − Q(s,a))²

1/5

Step by step

  1. 1Act with ε-greedy exploration and store (s, a, r, s′) in a replay buffer.
  2. 2Sample a random mini-batch from the buffer.
  3. 3Compute targets r + γ·max Q_target(s′, ·).
  4. 4Train the network to match the targets.
  5. 5Copy the weights to the target network every so often.

Where it is used

Discrete-action control such as Atari.

Watch out for

Overestimation bias, sensitivity to hyper-parameters, and it only handles discrete actions.

Related