---
title: 'Averaged-DQN: Variance Reduction in Deep RL'
url: https://www.emergentmind.com/topics/averaged-dqn
type: topic
---

# Averaged-DQN: Variance Reduction in Deep RL

Averaged-DQN is a reinforcement learning algorithm designed as an extension to Deep Q-Networks (DQN), addressing instability and high variance inherent in standard DQN by averaging multiple past Q-value estimates to compute more stable target values. This technique provably reduces the variance of the target approximation error (TAE), controls overestimation bias, and empirically leads to improved learning stability and performance across a suite of deep reinforcement learning benchmarks [1611.01929].

## 1. Background: Instability and Sources of Error in Deep Q-Learning

Standard DQN employs target networks to stabilize value estimation, updating network parameters $\theta$ by minimizing the squared error between the predicted Q-value and a temporally bootstrapped target,
\[
y_i = r_i + \gamma \max_{a}\, Q(s_{i+1}, a; \theta^-),
\]
where $\theta^-$ denotes the target network's parameters, periodically synced with $\theta$.

However, practical implementations of DQN exhibit pronounced instability:
- **Run-to-run variability**: Identical hyperparameters and architectures can yield widely diverging performance due to sensitivity to random seed.
- **Spiking and collapse in evaluation scores** during training.

Two primary mechanisms underlie this instability:
- **Target Approximation Error (TAE)**: Inexact minimization, restricted network capacity, and finite replay buffers inject noise into the value estimate targets.
- **Overestimation Bias**: The $\max_a$ in the Bellman target amplifies positive noise, further inflating Q-values.

An error decomposition (after Thrun & Schwartz, 1993) for the per-update deviation $\Delta_i(s, a)$ of the learned Q-value vs. $Q^*(s, a)$ yields:
\[
\Delta_i = \underbrace{Q(s,a;\theta_i) - y_i}_{\text{Target Approximation Error}}
           + \underbrace{y_i - (r + \gamma \max_a Q^*(s', a))}_{\text{Overestimation}}
           + \underbrace{(r + \gamma \max_a Q^*(s', a) - Q^*(s, a))}_{\text{Optimality Gap}}
\]
This decomposition motivates explicit variance reduction in the target network update mechanism.

## 2. Algorithmic Definition and Implementation

Averaged-DQN maintains a sliding window of the $K$ most recent Q-network parameter snapshots, $\{\theta_{i-1}, ..., \theta_{i-K}\}$. The target for each Bellman update is computed as the mean value output by these $K$ historical Q-networks:
\[
y_i^{\text{avg}} = r_i + \gamma \max_a \frac{1}{K}\sum_{k=1}^K Q(s_{i+1}, a; \theta_{i-k}).
\]
At each learning iteration:
1. An $\epsilon$-greedy policy is used with respect to $Q(\cdot; \theta_{i-1})$, and the experienced transition $(s_i, a_i, r_i, s_{i+1})$ is stored.
2. A mini-batch is sampled from the replay buffer.
3. For each transition, the update target is $y^{\text{avg}}$ as above.
4. Parameters $\theta_i$ are updated by descending the stochastic gradient of the mean squared loss,
   \[
   \nabla_\theta[(y^{\text{avg}} - Q(s, a; \theta))^2].
   \]
The final Q-function for policy extraction is the ensemble mean,
\[
\overline{Q}(s, a) = \frac{1}{K} \sum_{k=1}^K Q(s, a; \theta_{N-k}).
\]
Averaged-DQN thus only replaces the target calculation step and requires circular buffer bookkeeping for historical networks.

## 3. Theoretical Analysis of Variance Reduction

A core analytical contribution is the characterization of how Averaged-DQN reduces the variance of the learned Q-values under TAE. In a stylized M-state chain MDP with zero rewards and deterministic dynamics, the standard DQN update accumulates noise as:
\[
Q^{\text{DQN}}_i(s_0) = Z_i(s_0) + \gamma Z_{i-1}(s_1) + \cdots + \gamma^{M-1} Z_{i-(M-1)}(s_{M-1}),
\]
where $Z_i(\cdot)$ are i.i.d., zero-mean noise terms of variance $\sigma^2$. This yields
\[
\operatorname{Var}[Q^{\text{DQN}}_i(s_0)] = \sum_{m=0}^{M-1}\gamma^{2m} \sigma^2.
\]
For "Ensemble-DQN" (independently trained, non-interacting ensemble averaged at inference):
\[
\operatorname{Var}[Q^{E}_i(s_0)] = \frac{1}{K} \sum_{m=0}^{M-1}\gamma^{2m} \sigma^2.
\]
Averaged-DQN, by averaging across the historical parameter trajectory within a single training run, achieves strictly lower variance:
\[
\operatorname{Var}[Q^{A}_i(s_0)] = \sum_{m=0}^{M-1} D_{K, m}\, \gamma^{2m}\, \sigma^2,
\]
where $D_{K, m} < 1/K$ for $m > 0$, and thus $\operatorname{Var}[Q^A] < \operatorname{Var}[Q^E]$. Therefore, Averaged-DQN attains at least a $1/K$ reduction in TAE-driven variance compared to standard DQN, and often strictly better.

## 4. Empirical Evaluation and Results

The algorithm has been evaluated on the Arcade Learning Environment benchmarks (Breakout, Seaquest, Asterix), using a canonical deep convolutional architecture with three convolutional layers and a fully connected layer, following [Mnih et al., 2015]. Each method is run across multiple seeds for 120 million frames.

Key empirical results:

| Game     | DQN (K=1)         | Avg-DQN (K=5)      | Avg-DQN (K=10)     |
|----------|-------------------|--------------------|--------------------|
| Breakout | 245.1 (124.5)     | 381.5 (20.2)       | 381.8 (24.2)       |
| Seaquest | 3775.2 (1575.6)   | 5740.2 (664.8)     | 9961.7 (1946.9)    |
| Asterix  | 195.6 (80.4)      | 6960.0 (999.2)     | 8008.3 (243.6)     |

Empirically:
- Increasing $K$ nearly eliminates late-training performance collapse and shrinks run-to-run standard deviation by a factor of three or more.
- Final scores are substantially higher as $K$ increases, with effect sizes sufficient to yield human-level performance where DQN fails.

Computational overhead arises only at target-calculation time (proportional to $K$ forward passes per sample), with backpropagation cost unchanged. This is a modest cost on modern hardware.

## 5. Applications, Integration, and Best Practices

Averaged-DQN is particularly effective:
- In domains with sparse rewards or long horizons (where TAE accumulation is severe).
- When standard DQN exhibits noisy learning curves or persistent overestimation.

Typical practical choices:
- An averaging window of $K=5$ to $K=10$ captures most of the stabilizing effect with moderate additional cost.
- Tuning $K$ via held-out validation or early-training stability metrics is advisable for new domains.

The algorithm is compatible with orthogonal DQN improvements (Double-DQN, prioritized replay, dueling networks). In modular DRL libraries (e.g., Stable Baselines, Dopamine), implementation requires adding a history buffer and modifying the target computation as above.

## 6. Comparative Perspective and Limitations

Averaged-DQN shares conceptual motivation with ensemble methods, but differs by exploiting the temporal correlation in the learning trajectory of a single agent rather than requiring independent learners. Compared to Full Gradient DQN and average-reward variants, Averaged-DQN targets reduction of variance in the discounted Bellman update setting and does not alter the policy evaluation or control protocol [2304.03729]. The computational expense, though moderate, is not negligible for very large $K$ values or in resource-constrained settings.

Averaged-DQN does not explicitly address the bias induced by the max operator but controls the amplification of noise that leads to overestimation. In problems where other sources of bias or instability dominate, additional techniques may be needed.

## 7. Summary

Averaged-DQN is a principled, low-overhead extension of DQN, systematically reducing target estimation variance and suppressing learning instabilities arising from target approximation error. It offers provable and demonstrated empirical benefits, with adoption facilitated by its ease of integration into standard deep RL frameworks [1611.01929].

Source: https://www.emergentmind.com/topics/averaged-dqn