Topics / 🎮 Reinforcement Learning / 🧠 Level 111: Reinforcement Learning: Deep RL & Policy Gradients

Python exercise · about 5 minutes · free

DQN Targets: Bootstrapping With a Frozen Network

A neural network chasing a target that it also produces is unstable. Compute the target with a slowly updated copy.

A deep Q-network (DQN) replaces the Q-table with a neural network. Training regresses Q(s, a) onto the target r + gamma x max Q_target(s', a') x (1 - done). Two stabilisers: a target network (a periodically copied frozen version of the Q-network) and a replay buffer. Double DQN reduces the overestimation caused by the max: the online network chooses the next action and the target network evaluates it.

Prices, versions and service names last checked 2026-11-19. They change, so confirm on the official pages before you rely on them.

Diagram. Online Q-network (picks the action); Target network (evaluates it); target y (r + gamma Q_target(s', a*)). Links: Online Q-network → target y; Target network → target yOnline Q-networkpicks the actionTarget networkevaluates ittarget yr + gamma Q_target(s', a*)
Your quest: Write dqn_target(r, next_q, gamma, done) (next_q is the target network's list of Q values for the next state) and double_dqn_target(r, online_next_q, target_next_q, gamma, done). A finished episode (done true) has no future value.
Starter code
def dqn_target(r, next_q, gamma, done):
    pass

def double_dqn_target(r, online_next_q, target_next_q, gamma, done):
    pass

Try it in your browser → Free. Sign in with Google to run it. Your code runs on your device.

In this level you'll learn:
More in Level 111: Reinforcement Learning: Deep RL & Policy Gradients

Share on LinkedIn