Lesson 59
Deep Q-Network
Replace the Q-table with a neural network so the agent can score actions from raw, high-dimensional states. One example is on this page.
Intermediate12 min
What You Will Learn
- Idea
- Example
- When to use it
Idea
A deep Q-network learns Q(state, action) with a neural net. The target for one step is the reward plus gamma times the best Q in the next state. A frozen target network supplies that next Q so the target does not chase a moving network on every step.
Example
reward, gamma = 0.0, 0.9
next_q = [1.0, 2.0]
target = reward + gamma * max(next_q)
print(f"dqn target: {target:.2f}")Output:
dqn target: 1.80When to use it
- Use it when the state is an image or another input too large for a table.
- The target uses the max action of the next state. That max can overestimate.
- Replay buffers and a target network are part of making this update stable.
Loading playground…