Skip to main content

Reinforcement Learning II

Active RL, exploration vs. exploitation, Q-learning and SARSA, value function approximation, and DQN with its extensions.

9.1 Active RL and Exploration

Passive RL evaluates a fixed policy \(\pi\); active RL learns an optimal policy \(\pi^*\) while acting in an environment with unknown \((T, R)\).

  • Exploration vs. exploitation: Acting randomly for a long time wastes payoff before exploiting (and fails with dead-ends); acting purely greedily on current \((\hat{T}, \hat{R})\) stalls in suboptimal local minima. An agent must explore when knowledge is weak and exploit as estimates improve.
  • GLIE (Greedy in the Limit with Infinite Exploration): Every \((s,a)\) is visited infinitely often and \(\pi_t \to\) greedy w.r.t. \(Q(s,a) = \hat{R}(s) + \gamma \sum_{s'} \hat{T}(s,a,s')V(s')\), guaranteeing convergence in model-based ADP and active TD:
    • Decaying \(\varepsilon_t\)-greedy: Random action w.p. \(p(t)\) (\(p(t) = 1/t\) is GLIE; fixed \(\varepsilon \in \{0.01, 0.1\}\) is standard \(\varepsilon\)-greedy) and \(\arg\max_a Q(s,a)\) w.p. \(1 - p(t)\).

    • Boltzmann (softmax) exploration with annealed temperature \(T \downarrow 0\) (\(T \gg 1\) explores nearly uniformly; \(T \to 0^+\) exploits greedily):

      \[ \Pr(a \mid s) = \frac{\exp\bigl(Q(s, a)/T\bigr)}{\sum_{a' \in A} \exp\bigl(Q(s, a')/T\bigr)}. \]

9.1.1 Optimistic Exploration and \(R_{\max}\)

Instead of randomizing actions, inflate under-explored state–action pairs (\(N(s,a) \le N_e\)) to the best conceivable return \(V_{\max} = \dfrac{R_{\max}}{1 - \gamma}\) and act greedily:

  • Optimistic Value Iteration:

    \[ V^+(s) \leftarrow \max_{a \in A} \begin{cases} V_{\max}, & N(s, a) \le N_e, \\[4pt] \hat{R}(s) + \gamma \sum_{s'} \hat{T}(s, a, s') V^+(s'), & N(s, a) > N_e. \end{cases} \]

Definition 9.1 (Rmax Algorithm (Brafman & Tennenholtz, 2002)) Equivalent optimistic-MDP formulation: if \(N(s,a) < N_e\), set \(\tilde{T}(s,a,s) = 1\) and \(\tilde{R}(s) = R_{\max}\) (self-looping nirvana state); once \(N(s,a) \ge N_e\) (\(N_e\) set via Chernoff bounds), switch to empirical \((\hat{T}, \hat{R})\) and solve by standard VI.

  • PAC efficiency: With high probability, \(R_{\max}\) executes at most \(\operatorname{poly}\!\bigl(|S|, |A|, \tfrac{1}{1-\gamma}, \tfrac{1}{\epsilon}\bigr)\) actions whose value is more than \(\epsilon\) below \(V^*\).
  • TD-based active RL: Replaces full VI sweeps with \(O(1)\) updates \(V(s) \leftarrow V(s) + \alpha\bigl(R(s) + \gamma V(s') - V(s)\bigr)\) under a GLIE policy, but still requires storing \(\hat{T}\) (\(O(|A||S|^2)\) memory) to evaluate \(\arg\max_a \sum_{s'}\hat{T}(s,a,s')V(s')\).

9.2 Model-Free Control: Q-Learning and SARSA

9.2.1 Tabular Q-Learning

Learning the optimal action-value function \(Q^*(s,a)\) directly (\(V^*(s) = \max_{a'} Q^*(s,a')\)) eliminates \(\hat{T}\) during action selection via \(\pi^*(s) = \arg\max_a Q^*(s,a)\):

\[ Q^*(s, a) = R(s) + \gamma \sum_{s' \in S} T(s, a, s') \max_{a' \in A} Q^*(s', a'). \]

  • Off-policy TD update on observed transition \((s, a, r, s')\) (independent of the next exploratory action actually taken):

    \[ Q(s, a) \leftarrow Q(s, a) + \alpha \Bigl(r + \gamma \max_{a' \in A} Q(s', a') - Q(s, a)\Bigr). \]

Theorem 9.1 (Convergence of Tabular Q-Learning) \(Q_n \to Q^*\) with probability \(1\) if every \((s, a)\) is visited infinitely often and step sizes \(\alpha_n(s,a)\) satisfy

\[ \sum_{n=1}^\infty \alpha_n = \infty, \qquad \sum_{n=1}^\infty \alpha_n^2 < \infty. \]

  • Sparse goal-reward speedup: Forward updates propagate a terminal reward backward by only one state per episode; trajectory replay (multiple passes over stored episodes) or reverse updates (updating backward from the goal) propagate credit across an entire trajectory immediately.

9.2.2 SARSA: On-Policy vs. Off-Policy

  • SARSA (State–Action–Reward–State–Action, on-policy): Draws both \(a_n\) and \(a_{n+1}\) from the current behavior policy (e.g., \(\varepsilon\)-greedy on \(Q_n\)) and bootstraps on the actual next action \(a_{n+1}\):

    \[ Q_{n+1}(s_n, a_n) = Q_n(s_n, a_n) + \alpha_n \bigl[r(s_n, a_n) + \gamma Q_n(s_{n+1}, a_{n+1}) - Q_n(s_n, a_n)\bigr]. \]

  • Cliff Walking tradeoff (fixed \(\varepsilon > 0\)): Off-policy Q-learning learns the risky cliff-edge optimal path \(\pi^*\) and repeatedly suffers \(-100\) exploration falls; on-policy SARSA penalizes cliff-adjacent states for its own \(\varepsilon\)-slips and learns the safe detour (higher online return for fixed \(\varepsilon\), converging to \(\pi^*\) once \(\varepsilon_t \to 0\)).

Cliff Walking under fixed \(\varepsilon\): on-policy SARSA learns the safe upper detour, whereas off-policy Q-learning hugs the cliff and incurs lower online reward.

Comparison across tabular active RL (\(|S| = n\), \(|A| = m\); all converge to \(\pi^*\) under GLIE):

Method Model \(\hat{T}\)? Policy Type Step Compute Memory Sample Eff.
ADP / \(R_{\max}\) Yes Model-based High (VI / PI) \(O(mn^2)\) High (PAC poly)
Active TD Yes (for \(\arg\max_a\)) Model-assisted Low \(O(mn^2)\) Medium
Q-Learning No Off-policy Low \(O(mn)\) Medium
SARSA No On-policy (safer) Low \(O(mn)\) Medium

9.3 Function Approximation and Deep Q-Networks

9.3.1 Linear Value Approximation

Tabular methods fail on huge state spaces (no generalization across unseen states). State hashing \(S \to S'\) compresses states but can violate the Markov property unless hand-engineered. General large-scale paradigms comprise value function approximation, policy gradients, and actor–critic methods.

  • Linear approximator: Represent \(V_\theta(s) = \theta_0 + \sum_{i=1}^k \theta_i f_i(s)\) over state features \(f_1(s), \dots, f_k(s)\) (\(k \ll |S|\); one-hot state indicators recover exact tables without generalization).

  • Semi-gradient TD update on \((s, a, r, s')\) with bootstrap target \(v(s) = R(s) + \gamma V_\theta(s')\):

    \[ \theta_i \leftarrow \theta_i + \alpha \bigl(v(s) - V_\theta(s)\bigr) f_i(s). \]

    (Learning \(V_\theta(s)\) still needs a compact transition model for greedy lookahead—natural in board games like Backgammon, impractical for raw visual inputs.)

9.3.2 Deep Q-Network (DQN)

DQN (Mnih et al., Nature 2015) parameterizes \(Q(s, a; \theta)\) directly with a deep CNN: \(210 \times 160\) Atari frames are rescaled to \(84 \times 84\) luminance and stacked over the \(4\) most recent frames (\(\phi(s_t) \in \mathbb{R}^{84\times 84\times 4}\)), outputting all \(|A|\) action values in one forward pass.

DQN architecture for Atari: convolutional feature layers followed by fully connected layers outputting \(Q(\phi(s), a; \theta)\) for every joystick action.

Naïve neural Q-learning oscillates or diverges due to correlated sequential transitions, non-stationary bootstrap targets (small \(Q\) shifts abruptly flip \(\pi\) and the data distribution), and unbounded reward scales. DQN stabilizes training via three mechanisms:

  1. Experience replay: Store \((\phi_t, a_t, r_t, \phi_{t+1})\) in replay buffer \(D\) (capacity \(10^6\)) and sample random minibatches (\(\text{size } 32\), RMSProp) to break temporal correlations.

  2. Fixed target network (\(\theta^-\)): Compute bootstrap targets with frozen weights \(\theta^-\), synced \(\theta^- \leftarrow \theta\) only every \(C\) steps:

    \[ L_i(\theta_i) = \mathbb{E}_{(s, a, r, s') \sim U(D)} \!\left[\Bigl(r + \gamma \max_{a'} Q(s', a'; \theta_i^-) - Q(s, a; \theta_i)\Bigr)^2\right]. \]

  3. Reward clipping: Clip immediate rewards to \([-1, +1]\) to bound Q-values and condition backpropagated gradients.

  • Atari 2600 benchmark (\(49\) games, \(50\text{M}\) frames, action selection every \(4\)th frame): Surpasses professional human testers overall—excelling at reactive short-horizon games (Video Pinball: \(2539\%\)), while struggling on sparse-reward, long-horizon exploration (Montezuma’s Revenge).
  • Stabilization ablation (replay buffer is primary; combining replay + target \(\hat{Q}\) compounds gains—e.g., Breakout score: \(3.2\) neither \(\to 10.2\) target only \(\to 240.7\) replay only \(\to 316.8\) both; Seaquest: \(275.8 \to 1003.0 \to 822.6 \to 2894.4\)).

9.4 Extensions of DQN

9.4.1 Maximization Bias and Double DQN

Using the same noisy estimator to both select and evaluate the maximizing action induces positive maximization bias, \(\mathbb{E}[\max_a \hat{Q}(s', a)] \ge \max_a \mathbb{E}[\hat{Q}(s', a)]\):

  • Double Q-Learning (van Hasselt, 2010): Train two independent tables \(Q_1, Q_2\) (act \(\varepsilon\)-greedily on \(Q_1 + Q_2\); randomly pick one per step to update while using the other to evaluate):

    \[ Q_1(S_t, A_t) \leftarrow Q_1(S_t, A_t) + \alpha \Bigl[R_{t+1} + \gamma Q_2\bigl(S_{t+1},\, \arg\max_a Q_1(S_{t+1}, a)\bigr) - Q_1(S_t, A_t)\Bigr]. \]

  • Double DQN (van Hasselt, Guez & Silver, 2015): Reuses the existing online network \(w\) for action selection and target network \(w^-\) for value evaluation:

    \[ y_t^{\text{DDQN}} = R_{t+1} + \gamma Q\bigl(S_{t+1},\, \arg\max_a Q(S_{t+1}, a; w);\, w^-\bigr). \]

Maximization bias example: noisy \(\mathcal{N}(-0.1, 1)\) payoffs from state \(B\) trick standard Q-learning into taking wrong from \(A\), whereas Double Q-learning rapidly converges to optimal.

9.4.2 Prioritized Replay, Dueling Nets, Multi-Step, and R2D2

  • Prioritized Experience Replay (Schaul et al., 2016): Sample high-“surprise” transitions from a priority queue according to TD error \(|\delta_i|\) via stochastic prioritization (\(\alpha = 0\) recovers uniform replay):

    \[ P(i) = \frac{p_i^\alpha}{\sum_k p_k^\alpha}, \qquad p_i \propto |\delta_i| \quad (\text{or rank-based}). \]

  • Dueling Networks (Wang et al., 2016): Split the network into an action-independent state-value stream \(V(s; w)\) (attends to global context, e.g., road ahead) and an action-advantage stream \(A(s, a; w)\) (\(A^\pi(s,a) = Q^\pi(s,a) - V^\pi(s)\), attends only when immediate collision avoidance matters). Subtracting the mean resolves unidentifiability between \(V\) and \(A\):

    \[ Q(s, a; w) = V(s; w) + \left(A(s, a; w) - \frac{1}{|A|} \sum_{a' \in A} A(s, a'; w)\right). \]

  • Multi-step returns: Replace \(1\)-step reward with the truncated \(n\)-step return \(R_t^{(n)} = \sum_{k=0}^{n-1} \gamma^k R_{t+k+1}\) in the squared target \(\bigl(R_t^{(n)} + \gamma^n \max_{a'} Q(S_{t+n}, a'; w^-) - Q(S_t, A_t; w)\bigr)^2\) to speed up credit assignment (Rainbow combines Double DQN, PER, Dueling, multi-step returns, distributional RL, and noisy nets).

  • Distributed DQN (Ape-X) & R2D2: Decouple acting from learning by running hundreds of parallel CPU actors (e.g., \(256\)) that push transitions with initial priorities into shared prioritized replay for a central learner; R2D2 adds an LSTM layer after the CNN stack (with \(n = 5\)-step Double Q-learning) to handle partial observability.