Compute Double DQN targets
Why it matters Double Q targets are standard in every value-based RL agent since 2015.
Double DQN picks the next action with the online network but evaluates it with the target network, reducing overestimation.
Write double_dqn_target(r, done, q_online_next, q_target_next, gamma). Arrays are batched: r (B,), done (B,), q tables (B, A). Return r + gamma * (1 - done) * q_target_next[b, argmax_a q_online_next[b, a]].
def double_dqn_target(r, done, q_online_next, q_target_next, gamma)Example
r [1], done [0], online [[1, 5]], target [[10, 2]], gamma 0.9 gives [1 + 0.9 * 2] = [2.8].
Understand the idea
DQN's target uses the max over next actions of a noisy Q estimate, and taking a max of noisy numbers tends to overshoot. Double DQN splits the job: the online network picks the best next action, and the target network says how good that action is. Since the two networks have different noise, the overestimate shrinks. Worked example: batch of 2, gamma 0.9. Row 0: r 0.5, not done, online Q next [2, 3] picks action 1, target Q next [4, 1] gives 1, so the target is 0.5 + 0.9 * 1 = 1.4. Plain DQN would take max target 4, giving 4.1. Row 1: r 1, done, so the target is just 1. Result [1.4, 1.0]. Rule: a* = argmax over actions of q_online_next[b]; target_b = r_b + gamma * (1 - done_b) * q_target_next[b, a*]. Select with the online network and evaluate with the target network, never both with the target. Treat done as 0 or 1 so terminal rows get no bootstrap. Used in: Atari DQN agents and most modern value-based RL methods, which use this target by default.