Search

Search papers and lessons

Double Q-Learning

Level 4 · 12 min read

Double Q-learning keeps two value tables and uses one to pick the best next action and the other to score it, which removes the upward bias that Q-learning gets from using the same noisy estimates twice.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Reinforcement learning
  • Calculus
  • Linear algebra
  • Optimization
  • ReadReady to readNot yet

TL;DR

Double Q-learning keeps two tables of action values, A and B, that learn from the same experience but with separate noise. On each update it uses one table to choose the best next action and the other table to put a value on that choice. Because the choice and the value no longer share the same noisy numbers, the upward bias of Q-Learning largely disappears. The method was proposed by Hado van Hasselt in 2010 and is the basis of the Double DQN used in deep reinforcement learning.

Builds on: Q-Learning, Overestimation Bias · Leads to: Double DQN, Deep Q-Network

Where it's used

Deep Reinforcement Learning on Atari games. The 2015 Double DQN paper by van Hasselt, Guez and Silver applied the idea to the Deep Q-Network, which replaces the table with a neural network (Function Approximation) and learned to play dozens of Atari 2600 games (classic 1980s video games) from raw screen pixels. The paper reports that the standard target overestimated values in many games and that the double version reduced the overestimation and improved scores on a number of them. See Deep Reinforcement Learning with Double Q-Learning and Deep Q-Network.

Agents that choose among many options from noisy returns. Any learner that must pick the best of many actions, such as a recommendation system that tests many items or an agent that picks among many routes, will overrate its luckiest option if it uses one table for both choosing and scoring. Double estimators are a cheap guard against that.

How it works

We follow one update for a tiny agent. The agent is in state ss, takes action aa, gets reward 0, and moves to state s′s'. In s′s' there are two actions, numbered 1 and 2. Here are the current estimates held by the two tables, with discount γ=0.9\gamma = 0.9 (the discount multiplies the value of the next state before it is added to the reward):

  • Table A, state s′s': action 1 is 0.7, action 2 is 0.3.
  • Table B, state s′s': action 1 is 0.4, action 2 is 0.6.

The true values at s′s' are both about 0.5, so each table is noisy. Suppose the coin says "update table A this time".

  1. Choose with A. Table A has the larger value for action 1 (0.7 against 0.3), so the choice is a∗=1a^* = 1. Check: the choice comes only from table A's numbers.

  2. Score with B. Table B gives action 1 the value 0.4. That is the value used in the target, even though table B did not choose the action. Check: table B's own noise is independent of table A's noise, so this value is not inflated by the same error that made A pick action 1.

  3. Form the target. The target is the number the estimate will move toward. The reward is 0, so the target is 0+0.9×0.4=0.360 + 0.9 \times 0.4 = 0.36. Check: the single-table target from Overestimation Bias would have been 0.9×0.7=0.630.9 \times 0.7 = 0.63. The double target is much closer to the true value 0.45.

  4. Update A. Table A's entry for (s,a)(s, a) starts at 0. With learning rate α=0.5\alpha = 0.5, it becomes 0+0.5×(0.36−0)=0.180 + 0.5 \times (0.36 - 0) = 0.18. Check: the entry moved halfway toward the target, as the rule says.

  5. Next time. Roles swap on a fair coin, so table B is updated with the same logic using A's scores. Over many updates each table gets about half of them.

The picture below shows the split.

flowchart LR
  S[Next state s'] --> C{Coin: update A or B?}
  C -->|A| SA[A picks the best action]
  SA --> VB[B scores that action]
  VB --> UA[Update A toward the target]
  C -->|B| SB[B picks the best action]
  SB --> VA[A scores that action]
  VA --> UB[Update B toward the target]

The math

Setting

As in Q-Learning, the environment is a Markov decision process with states S\mathcal{S}, actions A\mathcal{A}, transition probabilities P(s′∣s,a)P(s' \mid s, a), rewards RR and discount γ\gamma. Keep two action-value estimates (action values), QAQ^A and QBQ^B, both starting from arbitrary values. The agent acts with an exploratory rule such as Epsilon-Greedy Policy, so the experience comes from the same process as in Q-learning.

Steps 1 and 2 in symbols: choose and score

For the example, the two tables at s′s' are QA(s′,⋅)=(0.7,0.3)Q^A(s', \cdot) = (0.7, 0.3) and QB(s′,⋅)=(0.4,0.6)Q^B(s', \cdot) = (0.4, 0.6). The choice uses the table being updated. Here arg⁡max⁡a′f(a′)\arg\max_{a'} f(a') is the action a′a' that gives the largest f(a′)f(a'), not the largest value itself:

a∗=arg⁡max⁡a′QA(St+1,a′).a^* = \arg\max_{a'} Q^A(S_{t+1}, a').

The score comes from the other table:

QB(St+1,a∗).Q^B(S_{t+1}, a^*).

With a∗=1a^* = 1 this is QB(s′,1)=0.4Q^B(s', 1) = 0.4, as in Step 2 of the walkthrough.

Steps 3 and 4 in symbols: the update

Definition: Double Q-learning update

On each step, a fair coin decides which table to update. If it chooses A, the agent sets

QA(St,At)←QA(St,At)+α[Rt+1+γ QB(St+1,arg⁡max⁡aQA(St+1,a))−QA(St,At)].Q^A(S_t, A_t) \leftarrow Q^A(S_t, A_t) + \alpha \Big[ R_{t+1} + \gamma\, Q^B\big(S_{t+1}, \arg\max_{a} Q^A(S_{t+1}, a)\big) - Q^A(S_t, A_t) \Big].

If it chooses B, the roles of A and B are exchanged.

Read the symbols: α\alpha is the Learning Rate, Rt+1R_{t+1} is the reward just received, and the bracket is a temporal-difference error. The only difference from ordinary Q-learning is that the max⁡\max over actions is split into an arg⁡max⁡\arg\max taken with one table and a value taken from the other.

Why step 2 removes the bias

Write each table as the truth plus noise: QA(s′,a)=va+εaAQ^A(s', a) = v_a + \varepsilon^A_a and QB(s′,a)=va+εaBQ^B(s', a) = v_a + \varepsilon^B_a, where each noise term is a Random Variable with mean zero, and the two sets of noise are independent of each other. The chosen action a∗a^* depends only on εA\varepsilon^A. So, taking the expectation over εB\varepsilon^B with a∗a^* fixed,

E ⁣[QB(s′,a∗)]=va∗+E ⁣[εa∗B]=va∗.\mathbb{E}\!\left[Q^B(s', a^*)\right] = v_{a^*} + \mathbb{E}\!\left[\varepsilon^B_{a^*}\right] = v_{a^*}.

The score is unbiased for the value of the chosen action. In the example v=(0.5,0.5)v = (0.5, 0.5), so the expected target is 0.9×0.5=0.450.9 \times 0.5 = 0.45, the true value. Single Q-learning instead targets max⁡aQ(s′,a)\max_a Q(s', a), and the maximum of noisy numbers is biased upward, as derived in Overestimation Bias.

This is the sense in which the double method "decouples" selection from evaluation. It does not make the target exact in every case, but it removes the systematic upward push that comes from reusing the same noise. For an introduction to expected values of this kind see Expected Value.

Step 5 in symbols: the sum over updates

Both tables are updated from the same stream of transitions, so each sees about half of the updates. Under the usual conditions for tabular Q-learning (every state-action pair visited often enough and learning rates that decay suitably) both tables converge to the true values. The convergence argument is the one that holds for Q-learning, applied to each table.

Worked examples

Example
1. One update by hand

Table A has QA(s,a)=0Q^A(s, a) = 0 for the action aa taken in ss. Table A's values at s′s' are (0.7,0.3)(0.7, 0.3) and table B's are (0.4,0.6)(0.4, 0.6). Reward 0, γ=0.9\gamma = 0.9, α=0.5\alpha = 0.5. The coin picks table A.

  1. Table A picks the action with the larger value at s′s': action 1, since 0.7>0.30.7 \gt 0.3.
  2. Table B scores action 1: its value is 0.4.
  3. The target is 0+0.9×0.4=0.360 + 0.9 \times 0.4 = 0.36.
  4. The update is QA(s,a)←0+0.5×(0.36−0)=0.18Q^A(s, a) \leftarrow 0 + 0.5 \times (0.36 - 0) = 0.18.

The new value 0.18 sits between the old 0 and the target 0.36, which is the expected behaviour of a step with α=0.5\alpha = 0.5.

Example
2. The coin picks table B

Now the coin picks table B. Table B has QB(s,a)=0.2Q^B(s, a) = 0.2 for the action in ss. At s′s', table B's values are (0.4,0.6)(0.4, 0.6) and table A's are (0.7,0.3)(0.7, 0.3). Reward 0, γ=0.9\gamma = 0.9, α=0.5\alpha = 0.5.

  1. Table B picks the action with the larger value at s′s': action 2, since 0.6>0.40.6 \gt 0.4.
  2. Table A scores action 2: its value is 0.3.
  3. The target is 0+0.9×0.3=0.270 + 0.9 \times 0.3 = 0.27.
  4. The update is QB(s,a)←0.2+0.5×(0.27−0.2)=0.2+0.035=0.235Q^B(s, a) \leftarrow 0.2 + 0.5 \times (0.27 - 0.2) = 0.2 + 0.035 = 0.235.

The roles are symmetric. Here the scoring table disagrees with the choosing table about which action is best, and that disagreement is what keeps the target honest.

Example
3. A realistic deep-learning target

The online network is the network whose weights are trained on every step. The target network is a copy of it that is refreshed only every so often (see Target Network). A Double DQN agent is in a state where the reward is r=1r = 1 and the discount is γ=0.9\gamma = 0.9. The online network's values for three actions are (1.0,2.5,2.2)(1.0, 2.5, 2.2). The target network's values for the same three actions are (2.0,1.5,2.6)(2.0, 1.5, 2.6). Compare the standard DQN target with the double target.

  1. Standard DQN takes the best target-network value: max⁡=2.6\max = 2.6, at action 3. Target: 1+0.9×2.6=1+2.34=3.341 + 0.9 \times 2.6 = 1 + 2.34 = 3.34.
  2. Double DQN chooses the action with the best online value: arg⁡max⁡=2\arg\max = 2, since 2.52.5 is largest.
  3. Double DQN scores that action with the target network: value 1.51.5.
  4. Double target: 1+0.9×1.5=1+1.35=2.351 + 0.9 \times 1.5 = 1 + 1.35 = 2.35.
  5. The double target is lower than the standard one by 0.99, because the standard target trusted a value (2.6) that the online network did not pick.

Try it: the reward is r=0r = 0 and γ=0.9\gamma = 0.9, the online values are (1.0,2.5,2.2)(1.0, 2.5, 2.2) and the target-network values are (2.0,1.5,2.6)(2.0, 1.5, 2.6). What is the double target, and what is the standard DQN target? Answer: the online network picks action 2 and the target network gives it 1.5, so the double target is 0.9×1.5=1.350.9 \times 1.5 = 1.35. The standard target is 0.9×2.6=2.340.9 \times 2.6 = 2.34.

Common mistakes and tradeoffs

It is tempting to think that using two tables is the same as averaging them. In fact the method's point is that the table which chooses and the table which scores are different, so their noise is independent. Averaging the two tables into one estimate and then taking the max reintroduces the bias.

It is tempting to think that the double estimator always gives the right answer. In fact it can err in the other direction: when the two tables disagree in a way that happens to favour a poor action, the target can be too low. The bias can also point the other way: the double estimator can underestimate in some problems. It reduces the systematic upward error, but it does not guarantee zero error.

It is tempting to think the method costs much more. In fact the computation per step is about the same as Q-Learning. The real cost is data: each table is updated only on about half the steps, so learning can be slower in a small problem.

When to use it: when there are many actions, when returns are noisy, and when overestimated values would send the agent to the wrong choices, which is the situation described in Overestimation Bias.

When not to use it: in deterministic problems with few actions, where the bias is negligible and a single table learns faster. Also avoid it when data is very scarce, because splitting updates between two tables can slow learning.

Alternatives: a Target Network delays the change of the target and reduces, but does not remove, the bias in deep learning. Averaging several independent estimates of the value is another option, at the cost of more samples. Deep agents also store past transitions and reuse them, a method called Experience Replay that is a separate fix and can be combined with this one.

History

The problem was visible in early Q-Learning experiments: an agent that learned from noisy rewards seemed to think its options were better than they were. Hado van Hasselt identified the cause as the maximum over noisy estimates and proposed the two-estimator fix in 2010 in the tabular setting.

Deep reinforcement learning made the issue much larger. In 2015 van Hasselt, Guez and Silver combined the idea with the Deep Q-Network, producing the Double DQN method, and reported that it reduced overestimation on Atari games. That paper is now the usual reference for the method in practice, and it is why the technique is often named after the Double DQN algorithm rather than the tabular version.

Recap

  • Q-Learning's target takes a maximum over noisy estimates, which is biased upward.
  • Double Q-learning keeps two tables. One chooses the best next action and the other scores it.
  • The choice and the score have independent noise, so the expected target is not inflated.
  • The update rule is the Q-learning rule with one substitution inside the target.
  • The same idea, with the online and target networks playing the two roles, underlies Double DQN in Deep Reinforcement Learning with Double Q-Learning.

What to read next: Deep Reinforcement Learning with Double Q-Learning applies the method to deep networks, and Deep Q-Network explains the network it is applied to.

Check yourself

QuestionIn double Q-learning, table A picks the best next action and table B gives it a value. Why does this reduce overestimation compared with plain [[q-learning]]?Show answer

Plain Q-learning uses one table both to pick the maximum and to value it. Noise that makes an action look best also inflates its value, so the target is pushed up. In double Q-learning the choice comes from table A's noise and the value from table B's noise. Those errors are independent, so the value of the chosen action is not inflated by the same error that selected it.

QuestionTable A gives next-state values (0.2,0.9,0.5)(0.2, 0.9, 0.5) and table B gives (0.6,0.4,0.7)(0.6, 0.4, 0.7). Reward 00, γ=0.5\gamma = 0.5. What is the double Q-learning target, if table A is being updated?Show answer

Table A picks the largest value: action 2, since 0.90.9 is the largest. Table B scores action 2 at 0.40.4. The target is 0+0.5×0.4=0.20 + 0.5 \times 0.4 = \mathbf{0.2}.

QuestionWhy does double Q-learning not fix the bias completely, even though it reduces it?Show answer

The method removes the systematic upward push when the two tables' errors are independent, but it does not make every estimate exact. Noise in the scoring table still affects the target, and when the tables disagree in a way that favours a poor action the target can be too low. The bias can change direction in some settings, so the method reduces error rather than eliminating it.

QuestionA researcher has a problem with two actions and almost noise-free rewards. Should they use double Q-learning? Explain briefly.Show answer

Probably not. Overestimation comes from taking a maximum over noisy values. With almost no noise there is little bias to remove, and a single table learns faster because every update trains the one table rather than being split between two.

Sources