Skip to main content
Deep Reinforcement Learning

Deep Q-Networks and Policy Gradient Methods

Published: 2026-08-01
Level: postgraduate
Audience: Postgraduate students in Deep Reinforcement Learning

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Q-learning (off-policy TD control) — covered in Lecture 10
  • Maximization bias and Double Q-learning — covered in Lecture 11
  • Function approximation for value functions — covered in Lecture 11
  • Deep Q-Network architecture, experience replay and target networks — covered in Lecture 12
  • Classical feature construction — covered in Lecture 12
  • Value-based vs policy-based algorithms — covered in Lecture 5
  • Returns and Monte Carlo estimation — covered in Lecture 7
  • Epsilon-greedy action selection — covered in Lecture 2

This lecture has two halves. The first half reviews the family of deep Q-network (DQN) algorithms — the 2013 original, the 2015 improved version, and Double DQN — as a progression where each version fixes a specific problem in the previous one. The second half introduces a fundamentally different paradigm: policy gradient methods, where the agent learns the policy directly instead of learning action values, and walks through the derivation of the REINFORCE algorithm step by step.

13.1 Deep Q-Network (DQN) — The Original Algorithm (2013)

Why should we care about a 2013 algorithm? Because the deep Q-network was the first method to combine deep learning with reinforcement learning and play Atari games from raw pixels alone — beating human experts on several of them. The 2013 paper was the spark; everything in modern deep RL builds on the ideas it introduced.

The lecture begins with a recap of the DQN family — the story of three papers that mark the entry of deep learning into reinforcement learning: the original DQN (2013), the improved DQN (2015, same authors), and Double DQN, which addresses maximization bias. The central message of the review: understand these as a progression, where each new paper fixes a specific problem in the previous version. The 2013 version introduces deep Q-learning; the 2015 version fixes the instability caused by chasing a moving target; Double DQN fixes the overestimation caused by the \(\max\) operator. The professor's exam guidance: focus on the 2015 DQN and DDQN for exams, not the 2013 version — which is why the recap treats the 2013 paper mostly as the problem setup that motivates the later fixes.

13.1.1 What a DQN does

A Deep Q-Network takes a state (typically a stack of preprocessed game frames) as input, passes it through a convolutional neural network, and outputs the estimated Q-value for every possible action. For example, in an Atari game, the network might output five values: the value of pressing "up", the value of pressing "down", the value of pressing "left", the value of pressing "right", and the value of pressing the fire button. These Q-values estimate the expected long-term return (total discounted reward) of taking each action in the current state and following the current policy thereafter.

Q-value (action-value): written \(Q(s, a)\), the Q-value is the expected total discounted reward the agent will collect if it takes action \(a\) in state \(s\) and then acts optimally (or according to its policy) afterwards. A "value" here is a number expressing how good a situation is — the higher the Q-value, the better the action. The name Q comes from the word "quality."

The input to the network is a stack of four preprocessed frames, each resized to \(84 \times 84\) pixels and converted to grayscale. The input tensor therefore has shape \(84 \times 84 \times 4\) (height \(\times\) width \(\times\) frames). Why stack four frames instead of feeding one? A single image gives no information about motion — a ball frozen at one position could be moving in any direction. Four consecutive frames reveal direction and speed of moving objects, which is exactly the information a game-playing agent needs. The choice of four frames is a documented design decision from the original paper: more frames give a longer history but cost more computation and memory.

13.1.2 The network architecture

The DQN architecture uses a deep convolutional neural network. The convolutional layers detect spatial patterns — edges, then shapes, then objects — exactly as in image classification networks:

  • First convolutional layer: 32 filters of size \(8 \times 8\) with stride 4
  • Second convolutional layer: 64 filters of size \(4 \times 4\) with stride 2
  • Third convolutional layer: 64 filters of size \(3 \times 3\) with stride 1
  • Fully connected layer: 512 units
  • Output layer: one unit per action (no activation — raw Q-values)

The network takes the preprocessed frames as input and outputs the Q-value for each action directly. Note the contrast with older designs that fed both state and action as inputs: here only the state is an input, and each action gets its own output neuron. One forward pass then computes the Q-values of all actions at once — a single pass replaces \(K\) separate forward passes, where \(K\) is the number of actions.

Note on the exact numbers: the architecture above (32/64/64 filters, 512 units) is the one used in the 2015 paper and quoted by the professor. The original 2013 paper used a slightly smaller network (16 filters in layer 1, 32 in layer 2, 256 fully connected units). Do not memorize either set of numbers — the professor's exam guidance is that the specific hyperparameters are not essential; what matters is the structure: three convolutional layers feeding a fully connected layer that outputs one value per action.

13.1.3 From tables to networks — the core idea

Function approximation: in tabular Q-learning, Q-values live in a table with one entry per (state, action) pair. That is impossible here: the state space of pixel images has \(2^{84 \times 84 \times 4}\) possible inputs — vastly more entries than there are atoms in the universe. The network instead approximates the Q-function: it takes a state and produces Q-values without storing every state explicitly. States that look similar produce similar Q-values, so what the network learns generalizes to states it has never seen.

The network is trained with the standard Q-learning update, applied to network parameters rather than table entries:

\[ \theta \leftarrow \theta + \alpha \left( Y - Q(s, a; \theta) \right) \nabla_\theta Q(s, a; \theta) \]

where:

  • \(\theta\) (theta) is the vector of network parameters (all the weights and biases)
  • \(\alpha\) (alpha) is the learning rate, the step size of the update
  • \(Q(s, a; \theta)\) is the network's current estimate of the Q-value of action \(a\) in state \(s\) — the "current guess"
  • \(Y\) is the target — the value we want the current guess to move towards
  • \(\nabla_\theta Q(s, a; \theta)\) is the gradient of the network output with respect to the parameters, computed by backpropagation

The update is a step of gradient descent on the squared error \((Y - Q(s, a; \theta))^2\): if the current estimate \(Q(s, a; \theta)\) is below the target \(Y\), the update pushes \(\theta\) in the direction that raises the estimate; if above, it lowers it. The size of the push is scaled by \(\alpha\).

The target in the original 2013 DQN is:

\[ Y = r + \gamma \max_{a'} Q(s', a'; \theta) \]

Here:

  • \(r\) is the reward received after taking action \(a\) in state \(s\)
  • \(\gamma\) (gamma) is the discount factor in \([0, 1]\) — it decides how much future rewards count compared to immediate ones (close to 1: patient agent; close to 0: myopic agent)
  • \(s'\) is the next state
  • \(\max_{a'}\) selects the highest Q-value over all possible next actions \(a'\) — the "best guess" of the value of the next state

This is the Bellman equation applied as an update rule: the value of an action should equal the immediate reward plus the discounted best value of where you end up next. Note that the same network parameters \(\theta\) are used for both computing the current Q-value \(Q(s, a; \theta)\) and computing the target \(Q(s', a'; \theta)\) — and this, as we will see in section 13.2, is exactly the seed of a stability problem.

13.1.4 Experience Replay Buffer

Experience replay buffer: a fixed-capacity memory \(N\) that stores recent transitions \((s, a, r, s')\). Instead of updating the network after every single step, the agent stores each transition, and training updates are made on mini-batches of transitions sampled uniformly at random from the buffer. When the buffer is full, the oldest transition is discarded to make room for the new one (first-in, first-out).

The replay buffer serves two purposes:

  1. Breaking temporal correlation. Consecutive frames in a game are highly correlated — frame 10 is nearly identical to frame 11. If the network learned from consecutive samples, its gradient updates would all point in nearly the same direction, like studying the same exam question ten times in a row. Random sampling from the buffer mixes old and new transitions, producing approximately independent training samples, which stabilizes gradient descent.
  1. Data efficiency. Each transition is reused in many updates rather than being used once and thrown away. In the 2013 paper, each transition is used in multiple weight updates; this matters enormously because collecting experience through environment interaction is slow.

Buffer initialization (a practical detail the papers often skip): before training begins, the buffer must be populated with initial transitions. The professor's recommended starting strategy: initialize the Q-network parameters randomly, then play the game with random actions to collect a batch of initial transitions. Only after the buffer has some data should learning begin. This step is rarely spelled out in the papers but is critical — an empty buffer cannot provide mini-batches, and a randomly initialized network cannot provide sensible targets.

In the original 2013 paper the buffer held the last \(N = 1{,}000{,}000\) frames, and mini-batches of size 32 were sampled. As with all hyperparameter numbers, these are reference values, not exam material.

13.1.5 DQN Training Loop — Detailed Walkthrough

The full DQN algorithm is a procedure, so it is best read as one. The loop runs over episodes; within each episode, these steps repeat:

Purpose: continuously refine the Q-network so that its outputs converge towards the true optimal Q-values, using experience collected by an exploring agent. Inputs & outputs: input — a random initial network \(\theta\), an empty replay buffer of capacity \(N\), a discount factor \(\gamma\), an exploration schedule \(\epsilon\). Output — a trained Q-network whose outputs estimate optimal action values.

Step 1: Obtain the current state. Start with the initial state of the environment. Extract the current frame from the emulator after executing the most recent action. Combine it with the previous three frames, preprocess (resize to \(84 \times 84\), convert to grayscale), and stack them to form the state representation \(\phi\) (phi). This \(\phi\) is the input to the Q-network.

Step 2: Select an action using epsilon-greedy. With probability \(\epsilon\) choose a random action (exploration); with probability \(1 - \epsilon\) choose the action with the highest Q-value (exploitation). The professor marks this as the epsilon-greedy step. Early in training \(\epsilon\) is high (often 1.0, fully random) and anneals down to a small floor (often 0.1) — the agent explores wildly at first, then settles into exploiting what it has learned.

Step 3: Execute the action in the emulator. The emulator processes the action and returns the reward \(r\) and the next raw frame.

Step 4: Construct the next state. Append the new frame to the stack of previous frames, preprocess, and form the next state representation \(\phi'\).

Step 5: Store the transition. Add \((\phi, a, r, \phi')\) to the replay buffer. If the buffer is full, the oldest entry is removed (FIFO).

Step 6: Sample a mini-batch and update. Sample a mini-batch of transitions from the replay buffer. For each transition in the mini-batch, compute the target \(Y\):

  • If the transition ends in a terminal state (game over): \(Y = r\) — there is no future, so the target is just the reward
  • Otherwise: \(Y = r + \gamma \max_{a'} Q(s', a'; \theta)\)

The parameters are then updated using gradient descent to minimize the loss between \(Y\) and \(Q(s, a; \theta)\):

\[ \theta \leftarrow \theta + \alpha \left( Y - Q(s, a; \theta) \right) \nabla_\theta Q(s, a; \theta) \]

Mini-batch trace (all numbers illustrative). Suppose the buffer contains transitions and we sample a mini-batch of two:

  • Transition 1: \(s = \text{paddle at left}\), \(a = \text{right}\), \(r = +1\), \(s' = \text{paddle center}\) (non-terminal)
  • Transition 2: \(s = \text{ball about to hit left wall}\), \(a = \text{left}\), \(r = -1\), \(s' = \text{terminal}\)

With \(\gamma = 0.9\), suppose the network currently outputs \(\max_{a'} Q(s', a'; \theta) = 0.8\) for transition 1 (both non-terminal). Then:

  • Target 1: \(Y_1 = 1 + 0.9 \times 0.8 = 1.72\)
  • Target 2: \(Y_2 = -1\) (terminal — no bootstrap term)

The loss is the average squared difference between the network's current output \(Q(s, a; \theta)\) and these targets, and one gradient step moves \(\theta\) so that \(Q(\text{paddle at left}, \text{right})\) moves up towards 1.72 and \(Q(\text{ball about to hit}, \text{left})\) moves down towards \(-1\). Sense-check: a positive reward followed by a good state pulls the Q-value up; a terminal loss of a point pins the Q-value at exactly the reward.

Implementation variation the professor flagged: the way the mini-batch targets are combined — averaged into a single loss, or treated as a sequence of independent stochastic updates — is not pinned down precisely by the original paper. This is exactly why different GitHub implementations of DQN can produce different results: the paper specifies the ingredients, not the exact recipe for mixing them. The 2015 paper frames it more cleanly as minimizing the mean squared error over the mini-batch.

13.1.6 The Problem with the 2013 DQN — Chasing the Target

The chasing-the-target problem: the 2013 DQN uses the same network both to compute predictions and to compute targets. Because \(Y = r + \gamma \max_{a'} Q(s', a'; \theta)\) contains \(\theta\), every parameter update moves not only the prediction but also the target itself. The result is a feedback loop: parameters change → target changes → update changes → target changes again. The network is constantly running towards a target that moves every time it takes a step.

The professor's analogy: imagine trying to follow someone who is walking ahead of you, but every time you take a step forward, they also take a step forward. You never catch up, and your path becomes erratic. Applied to Q-learning: an update that increases \(Q(s, a)\) often also increases \(Q(s', a')\) for all \(a'\) — because the same weights serve both states — and therefore increases the target the network is chasing. In the worst case this feedback loop causes oscillations or outright divergence of the parameters, which is why combining Q-learning with neural networks had a reputation for being unstable before DQN.

Scope of the problem: this instability is specific to using a nonlinear function approximator (a neural network) for Q-values together with off-policy learning. Earlier theory (Tsitsiklis & Van Roy, 1997) had shown that Q-learning with linear function approximation can also diverge, and combining it with neural networks was widely considered a dead end. DQN's contribution was to show that with the right engineering — replay buffer plus, in the 2015 version, a target network — the combination not only works but works spectacularly.

This instability was a recognized problem in the original 2013 paper, and the 2015 version introduced the fix: a second network whose only job is to compute targets, kept deliberately out of date. That is the subject of the next section.

13.2 Improved DQN (2015) — The Target Network

The one-line fix: if the problem is that the target moves every time the network updates, then the fix is to stop the target from moving. The 2015 DQN does exactly this by adding a second network — the target network — whose parameters are frozen, so the target stays fixed while the main network learns.

13.2.1 The fix — a second, frozen network

The 2015 DQN addresses the chasing-the-target problem by introducing a target network — a second Q-network with parameters \(\theta^-\) (theta-minus). The key change is in how the target \(Y\) is computed:

2013 DQN target:

\[ Y = r + \gamma \max_{a'} Q(s', a'; \theta) \]

2015 DQN target:

\[ Y = r + \gamma \max_{a'} \hat{Q}(s', a'; \theta^-) \]

The only difference: the target computation uses \(\hat{Q}\) (the target network) with parameters \(\theta^-\) instead of \(Q\) (the online network) with parameters \(\theta\). Everything else — the replay buffer, the epsilon-greedy action selection, the gradient descent update of the main network — is unchanged.

The target network \(\hat{Q}\) is a copy of the main Q-network, but its parameters are frozen: they are not updated by gradient descent. Every \(C\) steps, the parameters of the target network are updated by copying the current parameters from the main network:

\[ \theta^- \leftarrow \theta \]

This means the target remains stable for \(C\) steps, breaking the feedback loop. The main network can now converge towards a fixed target; only after \(C\) steps does the target shift to a new position. The professor describes the mechanism as "a teeny bit of work" — a single parameter copy every few thousand steps — that improves performance to a great extent. In the 2015 paper, \(C = 10{,}000\) frames.

Why a lagging target stabilizes learning: the feedback loop in the 2013 DQN existed because an update that raised \(Q(s, a)\) also raised \(Q(s', a')\) and hence raised the target \(Y\) — the agent was pulling its own goalposts up as it ran. With the target network, an update to \(\theta\) has zero effect on the target for \(C\) steps, because the target depends on \(\theta^-\), not \(\theta\). The online network now optimizes a well-defined, fixed regression problem, like a runner chasing a target that holds still long enough to be caught. The residual risk is reduced to a slow drift: every \(C\) steps the goalposts move a little, but the network has \(C\) steps to catch up before they move again.

13.2.2 The two networks at a glance

In the 2013 version, the same Q-network is used everywhere — for action selection and target computation. In the 2015 version:

  • The online network \(Q(\cdot; \theta)\) is the "player": it selects actions (via epsilon-greedy) and is updated by gradient descent at every training step.
  • The target network \(\hat{Q}(\cdot; \theta^-)\) is the "referee": it is used only for computing targets \(Y\), and it receives a fresh copy of the learned parameters every \(C\) steps.

The target network is therefore always "lagging behind" the main network — deliberately outdated — and precisely this staleness is what stabilizes learning. The professor summarizes: in 2013, one network everywhere; in 2015, a second network for targets that trails the learner.

13.2.3 Student Question — Understanding the Two Networks

Q: So there are two Q-networks — an online network and a target network. One is the player that is playing, and the other is the target network that provides a reference for what the Q-value should be. The second weight \(\theta^-\) is used for this target comparison. So it is a play between these two parallel networks?

A: That is a correct understanding. The online network (with parameters \(\theta\)) is the one being continuously updated through gradient descent — it plays the game and learns from experience. The target network (with parameters \(\theta^-\)) provides the reference Q-values for computing the target \(Y\) — it never learns, it only receives fresh copies of \(\theta\) every \(C\) steps. The target network lags behind precisely because of those spaced-out copies, and this separation is what prevents the chasing-the-target problem. So yes — think of it as a play between two parallel networks, where one of them (the target) stands still while the other (the online network) learns to match its reference values.

Common misconception: the target network is not a "second learner" or an ensemble member. It is a stale snapshot. It does not participate in action selection during training (the online network does), and it is never trained by gradient descent. Confusing the two roles — or believing the target network learns independently — will make later algorithms like Double DQN (section 13.3) hard to follow.

Recap: 2013 DQN — one network, target moves with every update, unstable. 2015 DQN — add a frozen copy \(\hat{Q}(\theta^-)\), refresh it every \(C\) steps, and the online network now trains against a fixed target, breaking the feedback loop. This "teeny bit of work" is one of the highest-leverage changes in deep RL history.

13.3 Double DQN (DDQN) — Addressing Maximization Bias

The surprising fact: a \(\max\) over noisy numbers is not just noisy — it is biased upward. Take ten measurements that are each correct on average: the single largest measurement is almost certainly one that got lucky. The culprit is the \(\max\) operator, which both selects and evaluates in one step; its built-in optimism is exactly the maximization bias that this section is about. The third paper in the DQN family undoes this bias, and a later extension called Bayesian DQN (not required for the exam — "nice to know" only) is not part of the core story.

13.3.1 Maximization bias — the professor's analogy

The professor explains maximization bias with a classroom story. A principal asks a professor: "Identify the best student in the class and give me that student's score." The professor looks at all the scores, finds that student Rajamani has the highest score (9.5 out of 10), and reports: "Rajamani is the best, and his score is 9.5." But the principal then conducts an independent evaluation and finds that Rajamani's true score is only 8.

The professor's 9.5 was an overestimate — not because the professor was careless, but because the \(\max\) operator selected Rajamani based on the professor's (noisy) scores. The highest observed score is typically a combination of high true ability plus favorable noise: of all the students, the one with the biggest lucky error is the one who looks like the best. The \(\max\) therefore inherits an upward bias — it is systematically too optimistic about whoever it picks.

13.3.2 The same bias in Q-learning

In Q-learning, the same thing happens. The step \(\max_{a'} Q(s', a')\) does two things simultaneously:

  1. Select the action \(a'\) that has the highest estimated Q-value
  2. Return that Q-value as the target

If the Q-value estimates are noisy — and they always are, especially early in training — the action selected by \(\max\) is likely the one whose noise happened to be positive, and its inflated Q-value is then used as the target. This is the maximization bias: the max operator overestimates the value of the best action, and the overestimate is fed back into the targets, where it propagates through bootstrapping.

Where the noise comes from: during learning, \(Q(s', a'; \theta)\) is an estimate — the network has seen only limited data, the function approximator is imperfect, the environment may be stochastic. Think of each Q-value as "true value + random error." The error is roughly centered at zero for any single action, but \(\max\) does not average: it picks the single action whose error is largest, and that error is positive by construction. Even in completely deterministic games (like the Atari 2600), this bias appears simply because the network's estimates are imperfect during training.

13.3.3 The Double DQN Update

Double DQN decouples the two roles of the \(\max\) operator. Instead of using one network to both select and evaluate the best action, it uses two networks:

Standard DQN target:

\[ Y = r + \gamma \max_{a'} Q(s', a'; \theta) \]

Double DQN target:

\[ Y = r + \gamma Q\left(s', \arg\max_{a'} Q(s', a'; \theta); \theta^-\right) \]

Read the Double DQN expression carefully — it contains the same pieces as standard DQN, just with the selection and evaluation split across two networks:

  • The online network \(Q\) with parameters \(\theta\) selects the best action: \(\arg\max_{a'} Q(s', a'; \theta)\) — it finds which action looks best in the next state
  • The target network with parameters \(\theta^-\) evaluates that action: \(Q(s', a_{\text{selected}}; \theta^-)\) — it scores the chosen action using the stale, independent snapshot

The professor emphasizes: "Look at this expression. This is the only expression that is different." Compared to the 2015 DQN target \(Y = r + \gamma \max_{a'} \hat{Q}(s', a'; \theta^-)\), Double DQN moves the \(\max\) out and replaces it with an \(\arg\max\) evaluated by the target network. Nothing else changes — same replay buffer, same target refresh schedule, same loss.

Why the decoupling kills the bias: the intuition follows the principal-professor analogy. In standard Q-learning, the same noisy estimates both pick the best student and report his score — the pick is biased, so the score is biased. In Double DQN, the professor (online network) still identifies who the best student is — its selection is still biased in its own noise — but the principal (target network) independently evaluates that student's quality. The target network's estimate of the chosen action has its own independent noise, which averages out rather than being selected. When the two sets of estimates are independent, the selection bias of the \(\max\) does not contaminate the value estimate.

More precisely: the estimate used by standard Q-learning is \(\max_a\) of noisy values (upward-biased by construction), while Double DQN uses one specific noisy value — \(Q(s', a^*; \theta^-)\) where \(a^*\) was chosen by the other network — whose noise is independent of the selection, so it is unbiased. Reducing this bias makes the learned values more accurate, which in turn improves the policies derived from them.

Worked trace (all numbers illustrative). Suppose in the next state \(s'\) there are two actions with true values \(Q^*(s', a_1) = 10\) and \(Q^*(s', a_2) = 11\). The networks' noisy estimates are:

Action Online network \(Q(\cdot; \theta)\) Target network \(Q(\cdot; \theta^-)\)
\(a_1\) 11.8 (noise +1.8) 9.6 (noise -0.4)
\(a_2\) 12.5 (noise +1.5) 10.9 (noise -0.1)

Standard DQN (2015): the max over the target network's values is \(\max(9.6, 10.9) = 10.9\), taken directly. Double DQN: the online network selects \(a_2\) (12.5 > 11.8), and the target network evaluates it as 10.9 — same number here, but notice what happens with bigger noise:

Action Online network Target network
\(a_1\) 13.0 (noise +3.0) 8.5 (noise -1.5)
\(a_2\) 10.5 (noise -0.5) 12.0 (noise +1.0)

Standard DQN target: \(\max(8.5, 12.0) = 12.0\). Double DQN: online selects \(a_1\) (13.0 is the max), but the target network evaluates \(a_1\) as only 8.5 → target = 8.5, much closer to the true value of the selected action's region. The standard \(\max\) would have taken 12.0 — the lucky value — while Double DQN refuses to inherit the online network's luck. Final answer: Double DQN's target is 8.5 instead of 12.0 — the inflated pick was rejected by independent evaluation. Sense-check: the number fed into the target is the value of the action actually selected, scored by a network that never saw the selection's noise.

13.3.4 Implementation Note — Alternating Networks

In the original Double Q-learning formulation (van Hasselt, 2010, before the deep learning version), two Q-networks are learned separately, each trained on half of the experience. Their roles can alternate: for some number of steps, \(Q\) selects actions and \(Q'\) evaluates them, and then they switch — \(Q'\) selects and \(Q\) evaluates. This is one valid way to implement Double DQN.

However, in practice the more common implementation uses the DQN 2015 framework: the main network learns continuously from the replay buffer, and the target network is a frozen copy refreshed every \(C\) steps. Double DQN simply changes the target computation — the main network does the selecting, the target network does the evaluating — while keeping everything else identical. This is the "minimal possible change" design: it gives most of the benefit of Double Q-learning without adding a third network or changing the training pipeline.

Pitfalls for the DQN family:

  1. Confusing Double DQN with the 2015 target network. The 2015 paper introduced the target network for stability (a moving-target problem); Double DQN reuses that same target network for bias reduction (a max-over-noise problem). They are different problems solved by different mechanisms, and Double DQN subsumes the 2015 target network — it keeps the frozen copy and changes only the target formula.
  1. Thinking \(\arg\max\) still overestimates. The \(\arg\max\) is taken over the online network, whose selection can still be "lucky" — but the value that enters the target comes from the other network. Selection bias is a property of the value, not the action; as long as evaluation is independent of selection, the target is unbiased.
  1. Expecting Double DQN to fix the 2013 instability. It does not — it still uses the (frozen) target network for targets, and if you remove the target network, Double DQN also destabilizes. The two fixes are complementary, not substitutes.

Recap: maximization bias = the \(\max\) of noisy estimates is systematically too high, because the selected action's noise is positive by construction. Double DQN's one-line fix — select with the online network, evaluate with the target network — breaks the link between selection and evaluation, reducing overestimation and improving both value accuracy and policy quality.

13.4 DQN Summary — Framework, Not Just an Algorithm

A useful way to think about DQN: it is not a fixed recipe with frozen numbers — it is a framework. The core learning structure (learn Q-values with a deep network, replay experience, use a target) survives any modernization of the individual components. When you read a paper in 2025 that says "we build on DQN," it usually means this framework, not the exact 2015 configuration.

The professor makes an important conceptual point: DQN should be understood as more than a step-by-step algorithm. It is a framework established in 2013–2015 that remains relevant today (2025). The specific design choices — the network architecture, the preprocessing pipeline, the replay buffer, the target network — can all be customized with modern techniques while preserving the core DQN learning structure.

For example, the original DQN processed \(84 \times 84 \times 4\) input frames. Modern implementations can use higher-resolution inputs, longer frame histories, or different network architectures (such as attention-based architectures or transformer backbones). The algorithm within the DQN framework still learns Q-values for each action, but the representation of the input and the specific learning steps can be upgraded with state-of-the-art methods.

DQN is fundamentally a value-based algorithm: it learns Q-values (preferences for each action) and then uses those values to select actions, typically via epsilon-greedy. This is the defining characteristic that distinguishes it from the policy-based approaches introduced later in this lecture — value-based methods learn how good each action is and act greedily on that; policy-based methods (section 13.6 onwards) learn how likely each action should be directly.

13.4.1 A practical engineering insight — supervised pre-training

Hybrid supervised + RL training: in many real-world scenarios you already have prior knowledge of action values. For example, for a million states, the optimal action values might already be known from historical data or domain expertise. In such cases you can first train the DQN network in a supervised manner — regression against the known values — until its outputs match them. Only then do you let the network go online and interact with the environment, refining its estimates to handle the stochastic, non-stationary nature of the real world.

This hybrid approach — supervised pre-training followed by reinforcement learning fine-tuning — is an engineering application of DQN that goes beyond the algorithm steps in the paper. It is a reminder that the paper describes a minimum viable learning recipe, not the only way to use a Q-network.

13.4.2 Comparison Table — Three DQN Variants

Aspect DQN (2013) DQN (2015) Double DQN
Target network Same network Separate frozen network \(\hat{Q}(\theta^-)\) Separate frozen network \(\hat{Q}(\theta^-)\)
Target update Every step Every \(C\) steps (copy \(\theta \to \theta^-\)) Every \(C\) steps (copy \(\theta \to \theta^-\))
Target formula \(r + \gamma \max_{a'} Q(s', a'; \theta)\) \(r + \gamma \max_{a'} \hat{Q}(s', a'; \theta^-)\) \(r + \gamma \hat{Q}(s', \arg\max_{a'} Q(s', a'; \theta); \theta^-)\)
Experience replay Yes Yes Yes
Key innovation Deep RL + replay Target network stability Decoupled selection and evaluation
Overestimation bias Yes Yes Reduced

The professor provided this comparison so students do not need to read all three papers in full — it is the reference sheet for the DQN family. Read it column by column: the 2013 column has one network doing everything; the 2015 column freezes a copy for targets; the Double DQN column keeps that frozen copy but changes only the target formula.

13.4.3 Student Questions and Answers

Q: Is the DQN algorithm relevant for the exam?

A: Yes. The professor confirms that the 2015 DQN and DDQN are the versions to focus on for exams; the original 2013 version is less critical. Bayesian DQN is not required for the exam — it is "nice to know" but not examinable. The class PPT shared with students should be used as the primary reference for exam preparation. Students should not spend excessive time on numerical problems; instead, focus on understanding the explanations and the reasoning behind each algorithm.

Q: Should we focus on the specific numbers from the paper (filter sizes, hyperparameters)?

A: No. The specific numbers — filter sizes, replay buffer capacity, discount factor, mini-batch size — are documented for reference but are not essential to memorize. What matters is understanding the algorithm's structure, the problems it addresses, and the reasoning behind each design choice. The comparison table above is provided as a convenience precisely so that structural understanding, not number recall, is what the exam tests.

Q: Does the professor have a companion document with worked numerical examples for practice?

A: The professor has not prepared a separate companion document for numerical problems, but he will provide one worked numerical example for each algorithm (REINFORCE, REINFORCE with baseline, and Actor-Critic) in the next class. He notes that getting into a problem-solving mode for this course would be counterproductive — the focus should be on understanding the algorithms and their reasoning, not extensive numerical drills. Students are encouraged to attempt the provided examples and share solutions for group discussion.

Exam note: Know the three DQN variants as a progression — (1) 2013: deep Q-learning + replay, unstable because targets move; (2) 2015: frozen target network refreshed every \(C\) steps, stable; (3) DDQN: same machinery, target uses the online network to select and the target network to evaluate, reducing overestimation. The table above is the fastest revision tool — but the reasoning behind each change is what the professor wants tested.

13.5 Feature Construction in Classical RL

Why study a dead technology? Before deep learning, an RL engineer's hardest job was not the learning algorithm — it was inventing features by hand. Understanding what that job looked like is what makes the DQN achievement (no hand features at all) land properly.

Before introducing policy gradient methods, the professor briefly discusses feature construction methods used in classical reinforcement learning — the era before deep learning made them largely obsolete.

13.5.1 Manual Feature Extraction Methods

In the classical approach, features were not extracted automatically by a neural network. Instead, engineers wrote algorithms to manually analyze the input — such as an image — and extract features: the positions of objects, their shapes, how they are connected, and so on. These features were then represented using various methods:

Polynomial features. Given input features \(x\) and \(y\), a polynomial transformation creates multiple derived features: a bias term (constant 1), \(x\), \(y\), \(xy\), \(x^2\), \(y^2\), and so on for higher degrees. The product terms \(xy\) are what make this powerful: they make interactions between features explicit before the learning algorithm sees the data. In modern deep learning, the network learns these interactions automatically in its hidden layers; in the classical approach, an engineer had to decide in advance which interactions to build.

Fourier basis. Features constructed using sines and cosines of the input variables, \(\sin(kx)\) and \(\cos(kx)\) for various frequencies \(k\). This is the same idea as decomposing a signal into frequencies: smooth functions can be represented well with a few low-frequency basis functions. The agent's value function is then a weighted sum of these basis functions.

The fundamental weakness of manual features: every choice — which polynomials, which frequencies, which object detectors — is a human guess about what matters in the task. The features are fixed before learning starts, and if the guess is wrong, the agent can never recover: it is limited to what the engineer's features can express. This is exactly the problem DQN's end-to-end learning removes.

13.5.2 Tile Coding (Radial Basis Features)

Tile coding (radial basis): the state space is filled with overlapping circles (tiles). Each circle represents a feature. A point in the state space is described by which circles it falls inside. For example, if a point falls inside circles \(C_7\), \(C_9\), \(C_{21}\), and \(C_{38}\), then the features corresponding to those four circles are active (value 1), and the point's representation is a function of these four features and their corresponding weights.

Concretely, the value of a point is approximated as:

\[ v(s) \approx \sum_{i \in \text{active tiles}(s)} w_i \]

where the sum runs over the tiles containing the point, and each tile \(i\) has a weight \(w_i\) that the learning algorithm adjusts. Because the tiles overlap, nearby points share tiles, so nearby points get similar values — this "sharing" is what makes generalization possible in classical RL. The representation is sparse: with a hundred tiles, each point activates only a handful, so only a few weights need to be examined (and updated) per state.

The professor describes three types of tiles — narrow, medium, and broad — and how they affect the approximation:

  • Narrow tiles capture fine details but produce noisy, jagged approximations — like zooming in so far that you see the texture but miss the shape
  • Broad tiles produce smooth approximations but are less precise — like squinting so much that details blur
  • Medium tiles offer a balance between the two

This is the classical bias–variance trade-off in a spatial disguise: small tiles = low bias, high variance; large tiles = high bias, low variance. The right tile width depends on how smooth the true value function is.

13.5.3 Why Classical Feature Construction Is Obsolete

The professor's key message: these classical feature construction methods are no longer used in modern applications. In DQN, the convolutional neural network extracts features automatically from the raw input frames — this is the "end-to-end" learning that makes DQN powerful. The engineer simply provides preprocessed frames, and the network handles feature extraction and Q-value computation in a single forward pass. Even in modern control applications, the professor has not seen papers using these classical tiling approaches.

The features learned by a deep network have two advantages over hand-built ones: they are task-tuned (the network only spends capacity on features that improve Q-value prediction, whereas a hand design must hedge across many possibilities), and they are hierarchical (edges → shapes → objects → abstract game concepts), which matches the structure of visual input.

The reason the lecture briefly covers this material: the textbook (written before the deep learning era) devotes space to these methods, and understanding them helps appreciate why deep learning was such a significant breakthrough for reinforcement learning. The tile-coding discussion is a window into the old world: an entire research field spent on the question "how should we represent a state?" — and the deep learning answer is simply "let the network figure it out."

13.6 Transition to Policy-Based Methods — A New Paradigm

A genuine paradigm shift: every algorithm so far — from tabular Q-learning to DQN — computes how good each action is and then acts greedily on those numbers. This lecture now switches to a fundamentally different question: instead of learning values and deriving a policy from them, why not learn the policy itself — a direct map from states to action probabilities?

Up to this point, all algorithms discussed follow the same paradigm: compute Q-values for each action, then use those values to select an action (via epsilon-greedy or similar). This is the value-based approach.

The professor now introduces the alternative: instead of computing values and then deriving a policy from those values, the agent directly learns the policy. This is the policy-based approach, and the specific methods for learning the policy are called policy gradient methods. The rest of the lecture is about this paradigm.

13.6.1 The Policy Network

Policy network: in a policy-based approach, the neural network is a policy network. It takes a state (or its representation) as input and directly outputs the probability of taking each action:

\[ \pi(a \mid s; \theta) = \text{probability of taking action } a \text{ in state } s \]

where \(\pi\) (pi) is the policy, \(a\) the action, \(s\) the state, and \(\theta\) the network parameters. Read the notation \(\pi(a \mid s; \theta)\) as "the probability the policy assigns to action \(a\), given state \(s\), with network weights \(\theta\)."

For example, in a game with five actions (up, down, left, right, do nothing), the network might output:

  • \(\pi(\text{up} \mid s) = 0.3\)
  • \(\pi(\text{down} \mid s) = 0.4\)
  • \(\pi(\text{left} \mid s) = 0.1\)
  • \(\pi(\text{right} \mid s) = 0.1\)
  • \(\pi(\text{do nothing} \mid s) = 0.1\)

These probabilities sum to 1: the output layer uses a softmax activation, which turns any real-valued network outputs into a valid probability distribution. The agent then samples an action from this distribution — it does not pick the argmax; it draws from the distribution, so even the 0.1 actions get tried sometimes, exactly in proportion to their probability.

This is fundamentally different from epsilon-greedy. In epsilon-greedy, one action gets a dominant probability and all others share the remainder equally — the shape of the distribution is rigid. In a policy network, the distribution can have any shape: 0.4/0.3/0.1/0.1/0.1 is a graded preference, not a binary split.

13.6.2 Stochastic Policy vs. Epsilon-Greedy — The Key Distinction

The professor draws a sharp contrast between epsilon-greedy policies and stochastic policies learned by policy networks.

Epsilon-greedy. Suppose the action values are \(Q(\text{up}) = 79\), \(Q(\text{down}) = 76\), \(Q(\text{right}) = 80\), \(Q(\text{left}) = 84\). With \(\epsilon = 0.5\), the greedy action (left) gets probability 0.6, and each non-greedy action gets probability 0.1. At the next step, if \(Q(\text{right})\) becomes 85, there is an abrupt shift — right suddenly becomes the greedy action and gets probability 0.6, while left drops to 0.1. This sudden change in behavior is problematic: a single value crossing a threshold rewrites the entire behavior profile in one step.

Stochastic policy. The policy network might output probabilities like 0.3, 0.4, 0.1, 0.1, 0.1 — a nuanced, graded preference rather than a binary greedy/non-greedy split. As learning progresses, these probabilities change smoothly and gradually — a network weight change shifts all probabilities a little — rather than jumping abruptly when a single value crosses a threshold.

The professor's vivid analogy: in a value-based approach with epsilon-greedy, behavior changes like a manager who one day says "focus entirely on this project" and the next day says "stop, shift all your attention elsewhere." Sudden re-allocations are disruptive and hard to recover from. In a policy-based approach, preferences shift like a manager who incrementally adjusts priorities based on new information — each update is small, so behavior drifts rather than lurches.

13.6.3 Worked Example — Why Stochastic Policies Can Be Optimal

The professor presents a small grid-world environment, taken from the textbook's classic example, demonstrating that stochastic policies can outperform any deterministic policy.

Environment setup:

  • Three states in a line: state 1 (start) → state 2 → state 3 (goal)
  • Two actions: left, right
  • Each step incurs a reward of \(-1\)
  • From state 1, trying to go left keeps the agent in state 1 (wall)
  • From states 2 and 3, left and right work normally
  • State 2 is adversarial: taking "right" moves the agent left (back to state 1), and taking "left" moves the agent right (toward the goal)
  • The agent cannot distinguish which state it is in — all states have identical features (aliasing), so one shared policy must serve all three states

Analysis of deterministic policies:

A "left-greedy" policy (epsilon-greedy with left dominant, e.g., left with probability 0.9, right with 0.1): since the goal is to the right, this policy takes a very long time to reach it — the agent must rely on the small 0.1 probability of pressing right to make any forward progress at all.

A "right-greedy" policy (epsilon-greedy with right dominant): from state 1 it moves right to state 2 quickly. But at state 2, taking right — which happens 90% of the time — sends the agent back to state 1 because of the adversarial flip. This creates a cycle: state 1 → state 2 → state 1 → state 2… The expected value for this policy is approximately \(-55\) steps' worth of reward.

The optimal stochastic policy:

\[ \pi(\text{right} \mid s) = 0.59, \quad \pi(\text{left} \mid s) = 0.41 \]

This balanced policy, learned directly by a policy-based algorithm, reaches the goal in approximately 12–13 steps. It works because:

  • From state 1: pressing right (59% of the time) moves to state 2 quickly
  • At state 2: pressing right (59% of the time) sends the agent back to state 1 (adversarial flip), but pressing left (41% of the time) sends the agent to state 3 — the goal
  • The near-even split means the agent does not get locked into the adversarial state-2 loop: whichever way it is pushed, it has a substantial chance of escaping in the useful direction

The two deterministic policies each fail in a distinct way: left-greedy starves the agent of forward progress (right is the only way out of state 1), while right-greedy feeds the state-2 trap (right is exactly the wrong action there). Only a balance between the two actions — which neither greedy policy can express — threads between the two failure modes.

Sense-check with the Bellman equations. Let \(p = \pi(\text{right})\) be the shared probability of pressing right (and \(1 - p\) of left), and let \(E_1, E_2\) be the expected number of steps remaining from states 1 and 2. From state 1: right (prob \(p\)) reaches state 2; left (prob \(1-p\)) hits the wall and stays. From state 2: right (prob \(p\)) returns to state 1; left (prob \(1-p\)) reaches the goal, ending the episode. The two equations are:

\[ E_1 = 1 + p\,E_2 + (1-p)\,E_1, \qquad E_2 = 1 + p\,E_1 \]

The first simplifies to \(p E_1 = 1 + p E_2\), i.e. \(E_1 = \tfrac{1}{p} + E_2\). Substituting into the second:

\[ E_2 = 1 + p\left(\tfrac{1}{p} + E_2\right) = 2 + p E_2 \quad \Longrightarrow \quad E_2 = \frac{2}{1-p} \]

and therefore:

\[ E_1(p) = \frac{1}{p} + \frac{2}{1-p} \]

Now plug in candidate policies:

  • Right-greedy (\(p = 0.9\)): \(E_1 = 1.11 + 20 = 21.1\) steps — the state-2 cycle dominates (the professor's ~55-step figure reflects his precise environment parameterization; the mechanism is the same)
  • Left-greedy (\(p = 0.1\)): \(E_1 = 10 + 2.22 = 12.2\) steps — slow progress, worse than balanced
  • Balanced (\(p = 0.41\)): \(E_1 = 2.44 + 3.39 \approx 5.8\) steps — the minimum is achieved near the balanced split

Final answer: the balanced stochastic policy minimizes expected steps. Minimizing \(E_1(p)\) gives \(p^* = \sqrt{2} - 1 \approx 0.41\) — the professor's 0.59/0.41 split in either labeling — confirming that the optimal policy is genuinely stochastic and far better than either greedy extreme. Sense-check: the optimum balances "getting out of state 1 quickly" (needs high \(p\)) against "escaping the adversarial state 2" (needs low \(p\)); the peak of the combined cost sits at the compromise.

Why no epsilon-greedy policy can match this (the subtle part): an epsilon-greedy policy is greedy with respect to its own Q-values — the dominant action is the argmax. But in the start state, pressing left is a wall: no progress, so \(Q(s_1, \text{left})\) is always lower than \(Q(s_1, \text{right})\) for any policy. Since the states are aliased (one policy everywhere), the greedy action would have to be "right" in every state — and right-dominance is precisely what the adversarial state 2 exploits. A deterministic or epsilon-greedy policy is therefore structurally incapable of expressing the balanced split that this environment demands. This is exactly the textbook example's point: the optimal policy here is not greedy with respect to any action-value function, so value-based methods with greedy action selection cannot find it.

13.6.4 Benefits of Policy-Based Approaches

The professor summarizes four advantages of policy-based over value-based methods:

  1. Better convergence properties. The stochastic policy changes smoothly, avoiding the abrupt preference shifts of epsilon-greedy. This leads to more stable learning — no single threshold crossing can rewrite the whole behavior profile.
  1. Natural handling of continuous action spaces. Q-learning requires computing \(\max_{a'} Q(s', a')\), which is only feasible when the action space is discrete and small. Policy-based methods can output the parameters of a continuous distribution — such as the mean and variance of a Gaussian, \(\mathcal{N}(\mu(s), \sigma^2(s))\) — from which the action (a torque, a steering angle) is sampled. This makes them applicable to continuous control tasks like robotic manipulation and autonomous driving, where Q-learning has no practical answer to "max over an infinite set of actions."
  1. Domain knowledge incorporation. The policy network directly maps states to action probabilities, a form of knowledge that is intuitive and easy to encode as prior knowledge. For example, a doctor's decision-making can be captured directly as "in this state, the probability of choosing treatment A is 0.7" — and the network can be initialized to reflect exactly that. In contrast, a value-based network outputs Q-values, which are less intuitive and harder to seed with expert knowledge.
  1. Can represent stochastic policies. Some problems — like the adversarial state-2 example above — have optimal solutions that are inherently stochastic. Policy-based methods can represent these directly; value-based methods with epsilon-greedy cannot.

Recap: value-based learning computes Q-values and acts greedily; policy-based learning outputs action probabilities directly and samples from them. Stochastic policies change smoothly, handle continuous actions, accept domain priors, and — as the 3-state grid world proves — can be strictly better than any greedy policy when the environment punishes deterministic behavior. This is why the rest of the lecture focuses on how to learn \(\theta\) so that \(\pi(a \mid s; \theta)\) improves.

13.7 Performance Measure and Policy Gradient Objective

The starting problem: to learn the parameters \(\theta\) of the policy network, we need a number that says how good the current policy is. In supervised learning that number is the loss; in reinforcement learning, what plays the same role is the performance measure \(J(\theta)\) — and because we want it as large as possible, we will end up climbing hills instead of descending into valleys.

13.7.1 Performance Measure for Episodic Tasks

For episodic tasks (tasks with a clear beginning and end, like playing a game), the performance measure is the expected return from the starting state under the current policy:

\[ J(\theta) = v_{\pi_\theta}(s_0) \]

where:

  • \(J(\theta)\) is the performance measure — a scalar that ranks policies: larger \(J\) means better policy
  • \(s_0\) is the starting state of the episode
  • \(\pi_\theta\) is the policy parameterized by \(\theta\)
  • \(v_{\pi_\theta}(s_0)\) (v) is the state-value function — the expected total discounted reward the agent collects from state \(s_0\) onward, following policy \(\pi_\theta\)

In plain words: "If I use policy \(\pi_\theta\) to play the game starting from the initial state, what is my expected total reward?" Note that the value depends on \(\theta\) through the policy: \(J(\theta) = v_{\pi_\theta}(s_0)\) changes only because changing \(\theta\) changes \(\pi_\theta\), which changes the states visited and rewards collected.

To get a reliable estimate of \(J(\theta)\), multiple episodes are played with the current policy and the returns are averaged. This average is the performance measure \(J(\theta)\) — the Monte Carlo estimate. One episode gives a noisy sample; averaging over many episodes shrinks the noise.

Scope: this definition works for episodic tasks — games, races, navigation runs — where an episode always ends. Continuing tasks (no natural endpoint, e.g., a lifelong trading agent) need a more complicated performance measure — the average reward rate per time step — which the professor defers to a later discussion. Do not use \(J(\theta) = v_{\pi_\theta}(s_0)\) for continuing tasks without thinking about what the return even means when \(T \to \infty\).

13.7.2 Gradient Ascent — Not Descent

In supervised learning, the goal is to minimize a loss function, so we use gradient descent:

\[ \theta \leftarrow \theta - \alpha \nabla_\theta L \]

In policy gradient methods, the goal is to maximize performance \(J(\theta)\), so we use gradient ascent:

\[ \theta \leftarrow \theta + \alpha \nabla_\theta J(\theta) \]

The only difference is the sign — ascent instead of descent. (In practice, most software frameworks minimize, so the objective is typically implemented as the negative of the performance, but conceptually: up is good here.)

The direction of \(\nabla_\theta J(\theta)\) (the gradient — an arrow pointing in the direction of steepest increase of \(J\) in parameter space) tells us which way to change \(\theta\) to improve performance, and its magnitude tells us how much performance responds to changes in \(\theta\). The learning rate \(\alpha\) (alpha) controls the step size: too large and the updates overshoot and oscillate; too small and learning crawls.

The professor's analogy: "I will alpha a learning rate, I will have control over your aspirations." If the gradient says "take 2,000 steps upward," the learning rate might allow only 0.2 of that ambition — the update implements 0.2 × 2,000 = 400 steps of the suggested climb. The learning rate is the brake that keeps an over-eager gradient from wrecking the parameter vector in one update, preventing wild oscillations. As a rough intuition: the gradient proposes a direction and an intensity; the learning rate decides how much of that intensity is actually applied.

Pitfalls for the objective:

  1. Descent vs. ascent sign errors. The only difference is the sign, but flipping it silently turns training into anti-training. When implementing in a library that minimizes, you must negate the objective (or the policy loss) — the code in practice computes \(-\nabla_\theta \log \pi(a|s)\cdot G_t\) and minimizes it.
  1. Treating \(J(\theta)\) as directly differentiable. It is not: \(J\) depends on \(\theta\) through a long chain — policy → action probabilities → sampled actions → trajectory → rewards — and the environment's dynamics sit inside that chain without being differentiable. That is exactly the problem the policy gradient theorem (section 13.8) solves.
  1. Expecting the gradient to be computable by backprop alone. Backprop gives you \(\nabla_\theta \pi(a|s;\theta)\) — the network's own gradient — for free. But the rewards enter the gradient as multipliers, and they arrive from outside the network. The whole art of policy gradient methods is connecting these two pieces.

Recap: we need a scalar "how good is this policy?" — for episodic tasks, \(J(\theta) = v_{\pi_\theta}(s_0)\), estimated by averaging episode returns. Since we maximize it, we will use gradient ascent: \(\theta \leftarrow \theta + \alpha \nabla_\theta J(\theta)\). The catch, addressed next: computing \(\nabla_\theta J(\theta)\) is non-trivial because the environment sits inside the dependency chain.

13.8 The Policy Gradient Theorem

13.8.1 The Core Challenge

The one-sentence problem: we want \(\nabla_\theta J(\theta)\) to climb the performance hill, but \(\theta\) does not directly determine \(J\) — a long chain of environment interactions sits between them, and the environment cannot be differentiated through.

The fundamental difficulty in policy gradient methods is that the parameter \(\theta\) does not directly determine the performance \(J(\theta)\). In supervised learning, changing a weight directly changes the loss — the relationship is immediate and deterministic: loss \(\to\) backprop \(\to\) weight update, all inside one differentiable function. In reinforcement learning, the chain is long:

\[ \theta \;\to\; \text{policy } \pi_\theta \;\to\; \text{action probabilities} \;\to\; \text{sampled actions} \;\to\; \text{trajectory through the environment} \;\to\; \text{(environment's stochastic dynamics)} \;\to\; \text{rewards} \;\to\; J \]

The environment's transition probabilities \(p(s' \mid s, a)\) and reward function \(r(s, a)\) are part of this chain, but they are not differentiable functions we control — they are external black boxes (an emulator, a robot, a simulator). We cannot backpropagate through them.

This means we cannot simply compute \(\nabla_\theta J(\theta)\) by standard backpropagation. We need a way to compute (or approximate) this gradient using only quantities available within the network — probabilities the network itself outputs, and rewards that arrive as observed numbers.

13.8.2 The Theorem Statement

The policy gradient theorem provides an analytic expression for the gradient of the performance measure. It states:

\[ \nabla_\theta J(\theta) \propto \sum_{s} \mu(s) \sum_{a} q_\pi(s, a) \nabla_\theta \pi(a \mid s; \theta) \]

where:

  • \(\mu(s)\) (mu) is the state visitation frequency — the fraction of time the agent spends in state \(s\) under policy \(\pi\), which plays the role of a weighting: states visited more often contribute more to the gradient, states visited rarely contribute almost nothing. (Formally, for episodic tasks this is the discounted weighting \(\mu(s)\) of the on-policy state distribution; the subscript is dropped for readability.)
  • \(q_\pi(s, a)\) is the action-value function — the expected return when taking action \(a\) in state \(s\) and following policy \(\pi\) thereafter. It is the "quality signal": how good was the choice of action \(a\)?
  • \(\nabla_\theta \pi(a \mid s; \theta)\) is the gradient of the policy network's output — the probability of action \(a\) in state \(s\) — with respect to the network parameters \(\theta\). This is computed entirely within the network via backpropagation.

The proportionality sign (\(\propto\)) indicates that the expression is proportional to the true gradient, not equal to it. The constant of proportionality (which involves \(\gamma\), the discount, and normalization factors) is a positive scalar, so it points in the same direction as the true gradient. Since gradient ascent only needs a direction, any quantity pointing the right way is sufficient — the constant is silently absorbed into the learning rate \(\alpha\).

Scope of the theorem: the theorem holds for the on-policy setting (the data is generated by the policy being updated) and for either episodic or continuing tasks with the appropriate \(\mu(s)\) and proportionality constant. It is the bedrock of REINFORCE and of almost every modern policy gradient method (baselines, actor-critic, PPO all descend from it), but it does not directly give an off-policy gradient — methods that learn from another policy's data need importance-weighting extensions beyond this lecture.

13.8.3 Why This Theorem Matters

The beauty of this expression is that the differentiation \(\nabla_\theta\) applies only to the policy network's parameters. Look at where the gradient symbol sits:

\[ \nabla_\theta J(\theta) \propto \sum_{s} \mu(s) \sum_{a} q_\pi(s, a)\; \nabla_\theta \pi(a \mid s; \theta) \]

The environment dynamics, the state transition probabilities, and the reward function — none of these appear inside a gradient operator. They appear only as multipliers: \(\mu(s)\) and \(q_\pi(s, a)\) are plain numbers (or estimated numbers) sitting outside \(\nabla_\theta\). Everything that needs to be differentiated — \(\pi(a \mid s; \theta)\) — is available within the network.

The professor emphasizes: "There is no aspect outside the network that has to be differentiated. The delta (gradient) applies to parameters of only the network." This is the whole point: the theorem converts "differentiate through the environment" into "multiply the network's own gradient by two numbers we can estimate from experience."

Q: Wait — earlier the professor said policy-based methods do not compute Q-values. But here is \(q_\pi(s, a)\) sitting in the policy gradient theorem. Isn't that a contradiction?

A: It seems contradictory, but it is not. The apparent contradiction is resolved by separating what is learned from what is measured. Policy-based methods do not learn Q-values as their primary output, the way DQN does; the policy network's output is \(\pi(a \mid s; \theta)\), never a Q-value. But the theorem shows the gradient needs a quality signal — an estimate of how good the chosen action was — and \(q_\pi(s, a)\) plays exactly that role. It is a measurement taken to judge an action, not the thing being learned. Different algorithms differ precisely in how they obtain this quality signal — REINFORCE uses the observed return \(G_t\), actor-critic uses a learned value function — and that single design choice separates one algorithm from the next. The preferred mental model: values are used as a critique, not as the actor's output.

Recap: the policy gradient theorem turns an impossible differentiation problem into a weighted average of network gradients. The weighting is the state visitation \(\mu(s)\) times the action quality \(q_\pi(s,a)\); the differentiation is only ever applied to the policy network itself. What remains — section 13.9 — is converting the theorem's sums over all states and actions into something computable from a handful of samples.

13.9 From Theorem to Algorithm — Deriving the REINFORCE Update

The gap between theorem and code: the policy gradient theorem gives a direction, but it sums over all states and all actions — impossible when the state space is huge. The professor now walks through four algebraic steps that convert the theorem into a practical, sample-based update rule. The professor's summary: "Someone gave a very complex policy gradient theorem, and I kind of simplified it in multiple ways, and brought it to a simple form, and made an algorithm out of it."

13.9.1 Step 1 — Convert to Expectation

Recognizing that \(\mu(s)\) is the probability of being in state \(s\) under policy \(\pi\) — a probability distribution over states — we can rewrite the sum over states as an expectation:

\[ \nabla_\theta J(\theta) \propto \mathbb{E}_\pi \left[ \sum_{a} q_\pi(s, a) \nabla_\theta \pi(a \mid s; \theta) \right] \]

The professor motivates this with an everyday example: to find the expected height of students in a class, you do not measure every student — you sample students, measure their heights, and average. The sample average approaches the true average as you sample more. Similarly, to compute this expectation we can sample states from the policy (just by playing episodes) and compute the inner sum for each sampled state. We do not need to enumerate all states — we just need enough samples. The states that appear in the sum are naturally weighted by how often the policy visits them, which is exactly what \(\mu(s)\) does.

13.9.2 Step 2 — Remove the Sum Over Actions

The expression still contains a sum over all actions \(\sum_a\), which is undesirable for large action spaces. The professor shows a clever algebraic manipulation: multiply and divide by \(\pi(a \mid s; \theta)\) — a mathematically legal move, since \(\frac{\pi}{\pi} = 1\), but one that re-arranges the expression into the shape of an expectation:

\[ \sum_{a} q_\pi(s, a) \nabla_\theta \pi(a \mid s; \theta) = \sum_{a} \pi(a \mid s; \theta) \cdot q_\pi(s, a) \cdot \frac{\nabla_\theta \pi(a \mid s; \theta)}{\pi(a \mid s; \theta)} \]

Now look at the structure: a sum over actions of "probability \(\pi(a \mid s; \theta)\) times something" — that is precisely the definition of an expectation over \(a \sim \pi\):

\[ = \mathbb{E}_{a \sim \pi} \left[ q_\pi(s, a) \cdot \frac{\nabla_\theta \pi(a \mid s; \theta)}{\pi(a \mid s; \theta)} \right] \]

Since this is an expectation, we do not need to sum over all actions — we can sample one action from the policy and use that single sample as an unbiased estimate of the whole sum. This is the same logic as the class-height example, applied to the action axis: one sampled action, scaled appropriately, replaces the full enumeration.

13.9.3 Step 3 — Apply the Log-Derivative Trick

The term \(\frac{\nabla_\theta \pi(a \mid s; \theta)}{\pi(a \mid s; \theta)}\) is recognized as the gradient of the natural logarithm — the standard identity \(\frac{d}{dx} \ln f(x) = \frac{f'(x)}{f(x)}\):

\[ \frac{\nabla_\theta \pi(a \mid s; \theta)}{\pi(a \mid s; \theta)} = \nabla_\theta \ln \pi(a \mid s; \theta) \]

The professor notes this transformation is done for "mathematical convenience": the ratio of a gradient to a function is awkward to compute and numerically unstable, while the gradient of a log-probability is a clean quantity that deep learning frameworks compute natively and stably. This log-derivative trick has been a standard tool since the early days of machine learning — it appears in many derivations, not just this one.

13.9.4 Step 4 — Replace the Quality Signal

The gradient now reads \(\mathbb{E}[q_\pi(s, a) \nabla_\theta \ln \pi(a \mid s; \theta)]\) — but \(q_\pi(s, a)\), the true action-value, is still unknown. We need a practical estimate of it. In the REINFORCE algorithm (a Monte Carlo policy gradient method), the quality signal is simply the return \(G_t\) — the total discounted reward actually observed from time step \(t\) until the end of the episode:

\[ G_t = \sum_{k=0}^{T-t} \gamma^k r_{t+k} \]

where \(T\) is the final time step of the episode. Because REINFORCE is a Monte Carlo method, it waits until the episode is complete, computes the actual return \(G_t\) for each step, and uses it as the quality signal in place of \(q_\pi(s_t, a_t)\). This replacement is justified: \(G_t\) is an unbiased estimate of \(q_\pi(s_t, a_t)\) — on average it equals the true action-value, because the return is exactly what the action-value is defined to predict. No model of the environment is needed — just the observed rewards.

13.9.5 The Final REINFORCE Update Rule

Combining all the simplifications, the REINFORCE update rule is:

\[ \theta \leftarrow \theta + \alpha \, G_t \, \nabla_\theta \ln \pi(a_t \mid s_t; \theta) \]

where:

  • \(\alpha\) is the learning rate (which also absorbs the constant of proportionality from the theorem)
  • \(G_t\) is the discounted return from time step \(t\) — the quality signal
  • \(\nabla_\theta \ln \pi(a_t \mid s_t; \theta)\) is the gradient of the log-probability of the action that was actually taken, computed via backpropagation

The complete chain of simplifications, in one place:

\[ \begin{aligned} \nabla_\theta J(\theta) &\propto \sum_{s} \mu(s) \sum_{a} q_\pi(s, a) \nabla_\theta \pi(a \mid s; \theta) &&\text{(policy gradient theorem)}\\ &= \mathbb{E}_\pi\left[\sum_{a} q_\pi(s, a) \nabla_\theta \pi(a \mid s; \theta)\right] &&\text{(mu(s) is a distribution over states)}\\ &= \mathbb{E}_{a \sim \pi}\left[q_\pi(s, a) \frac{\nabla_\theta \pi(a \mid s; \theta)}{\pi(a \mid s; \theta)}\right] &&\text{(multiply and divide by } \pi \text{, recognize expectation)}\\ &= \mathbb{E}_{a \sim \pi}\left[q_\pi(s, a) \nabla_\theta \ln \pi(a \mid s; \theta)\right] &&\text{(log-derivative trick)}\\ &\approx G_t \, \nabla_\theta \ln \pi(a_t \mid s_t; \theta) &&\text{(one sample: } a_t \sim \pi,\; G_t \approx q_\pi \text{)} \end{aligned} \]

Each step is reversible and standard; the result is a single-sample estimate of the gradient direction, which gradient ascent turns into the update \(\theta \leftarrow \theta + \alpha G_t \nabla_\theta \ln \pi(a_t \mid s_t; \theta)\).

Worked trace of one REINFORCE update. Consider a two-action task (right, left) with a policy network whose output layer holds logits \(z = [z_{\text{right}}, z_{\text{left}}] = [0, 0]\) — equal logits give equal probabilities: \(\pi(\text{right}) = \pi(\text{left}) = 0.5\) via softmax.

Episode 1. The agent samples an action: right (prob 0.5). It takes the action, receives reward \(r_0 = +2\), and the episode ends (\(T = 0\)). The return is \(G_0 = r_0 = 2\). The gradient of the log-probability of "right" w.r.t. the logits is the standard softmax identity \(\frac{\partial \ln \pi(a|s)}{\partial z_j} = \mathbf{1}_{j=a} - \pi(j|s)\):

\[ \nabla_z \ln \pi(\text{right} \mid s_0) = \left[1 - 0.5,\; 0 - 0.5\right] = [0.5, -0.5] \]

With \(\alpha = 0.1\), the update is \(\Delta z = \alpha G_0 \nabla_z \ln \pi = 0.1 \times 2 \times [0.5, -0.5] = [0.1, -0.1]\):

\[ z_{\text{new}} = [0 + 0.1,\; 0 - 0.1] = [0.1, -0.1] \]

New softmax probabilities: \(e^{0.1}/(e^{0.1} + e^{-0.1}) = 1.1052/2.0100 \approx 0.55\) for right, \(0.45\) for left. Final answer: after one good episode, the probability of the rewarded action (right) rose from 0.50 to 0.55. Sense-check: the update moves probability toward actions followed by positive returns — a small bump because \(\alpha\) and \(G_t\) are small; repeated good episodes compound it.

Episode 2 (contrast). The agent samples left and the episode returns \(G_0 = -1\). The gradient of \(\ln \pi(\text{left})\) w.r.t. the logits is \([0 - 0.55,\; 1 - 0.45] = [-0.55, +0.45]\). Then \(\Delta z = 0.1 \times (-1) \times [-0.55, 0.45] = [+0.055, -0.045]\), giving new probabilities \(\approx 0.57\) for right and \(0.43\) for left — the probability of the poorly rewarded action (left) is pushed down, and right rises since probabilities must renormalize. The same mechanism, opposite sign: bad outcomes decrease the probability of the action that caused them. This is trial-and-error learning in its purest form.

13.9.6 Interpreting the REINFORCE Update

The update has an intuitive interpretation:

  • \(G_t\) measures how good the trajectory turned out to be from step \(t\) onward — the outcome of the experiment
  • \(\nabla_\theta \ln \pi(a_t \mid s_t; \theta)\) points in the direction that increases the probability of the action that was taken
  • If \(G_t\) is high (good outcome), the update increases the probability of taking action \(a_t\) in state \(s_t\)
  • If \(G_t\) is low (poor outcome), the update decreases that probability
  • The learning rate \(\alpha\) scales the magnitude of the update

This is a form of trial and error learning reinforced by outcomes — exactly the spirit of reinforcement learning: actions that worked become more likely, actions that failed become less likely, and the direction of adjustment is provided by the network's own gradient.

Pitfalls and the known weakness of REINFORCE:

  1. High variance. \(G_t\) is a single, noisy sample — one roll of the dice per update. Different episodes can return wildly different totals for the same action, so the gradient estimate is unbiased but noisy. The professor's next lecture introduces the baseline (subtracting a state-dependent value) precisely to reduce this variance, and that leads to the actor-critic family.
  1. Credit assignment is coarse. \(G_t\) credits every action in the episode with the full return — an action taken early gets blamed or praised for everything that followed, including the effects of unrelated later actions. REINFORCE has no mechanism to disentangle "was it my action or the next one?"; it just uses the total.
  1. Positive-reward environments stall. If all returns are positive, every action's probability increases — the relative ordering still shifts, but learning is slower because probabilities can only move in one direction per update. This is another motivation for the baseline.

Recap: the REINFORCE update \(\theta \leftarrow \theta + \alpha G_t \nabla_\theta \ln \pi(a_t \mid s_t; \theta)\) is the policy gradient theorem made computable: expectation over states (sample episodes), expectation over actions (multiply-divide by \(\pi\) + sample one action), log-derivative trick (computable, stable gradients), and the return \(G_t\) as the quality signal. The whole journey: a complex theorem, simplified step by step into one line of code — and next class's worked numerical examples (REINFORCE, REINFORCE with baseline, Actor-Critic) will put numbers to this line.

13.10 Exam Guidance Summary

This section consolidates the professor's explicit exam guidance given during the lecture. It is a summary of what was said — the details behind each bullet live in the corresponding sections above.

13.10.1 DQN Exam Focus

  • Focus on the 2015 DQN and DDQN for exams, not the 2013 version (the 2013 version matters as history — its instability motivates everything that follows)
  • Bayesian DQN is not required for the exam — it is "nice to know" only
  • The specific numerical hyperparameters (filter sizes, buffer capacities, discount factors) are not required to memorize — understand the structure and reasoning instead
  • Use the class PPT as the primary reference for exam preparation
  • The comparison table of the three DQN variants (section 13.4.1) is valuable for quick revision

13.10.2 Policy Gradient Exam Focus

  • The professor will provide one worked numerical example for each algorithm (REINFORCE, REINFORCE with baseline, Actor-Critic) in the next class — students should attempt them and share solutions for group discussion
  • The policy gradient theorem — understand its form and its significance, but detailed mathematical proofs are not required
  • The stochastic policy example (0.59 vs 0.41 in the adversarial grid world) is important for understanding why policy-based methods can outperform value-based methods

13.11 Key Industry Applications

13.11.1 DQN Framework in Practice

  • DQN framework — The DQN architecture (convolutional network + replay buffer + target network) is a foundational framework used in many modern deep RL systems. The specific network architecture and learning steps can be upgraded with state-of-the-art techniques — higher-resolution inputs, attention-based backbones, prioritized replay — while preserving the core DQN structure: learn Q-values from experience, replay them, stabilize with a target.
  • Hybrid supervised + RL training — When prior knowledge of action values is available (e.g., from historical data or domain expertise), the DQN can be pre-trained in a supervised manner against those known values and then fine-tuned online through environment interaction. This engineering pattern — warm-start from data, then refine in the field — applies to many real-world problems where pure RL from scratch would be too slow or too unsafe.

13.11.2 Policy Gradient Applications

  • Policy gradient methods for continuous control — Robotics, autonomous driving, and other continuous control tasks benefit from policy gradient methods because they naturally handle continuous action spaces (torques, steering angles, throttle values sampled from a parameterized distribution), unlike Q-learning which requires discrete actions to compute \(\max_{a'} Q(s', a')\).
  • Domain knowledge integration — Policy networks make it easy to incorporate expert knowledge as prior probability distributions over actions — "in this state, choose treatment A with probability 0.7" — which is useful in medical decision-making, financial trading, and other domains where expert intuition is valuable and data is scarce.

13.12 Named References

13.12.1 Research Papers

  • DQN (2013) — original deep Q-learning paper: "Playing Atari with Deep Reinforcement Learning" (Mnih et al.). One of the first and most successful deep reinforcement learning algorithms: it learns to play Atari games from raw pixels with a convolutional network, experience replay, and epsilon-greedy exploration.
  • DQN (2015) — improved version with target network: "Human-level control through deep reinforcement learning" (Mnih et al., Nature 518), by the same authors. Introduces the target network and scales to 49 Atari games, reaching a level comparable to a professional human games tester.
  • Double DQN — extension addressing maximization bias: "Deep Reinforcement Learning with Double Q-learning" (van Hasselt, Guez & Silver, 2016). Builds on Double Q-learning (van Hasselt, 2010) and adapts it to the deep setting using the existing target network.

13.12.2 Textbooks and Courses

  • Sutton and Barto — chapter on policy gradient methods: Reinforcement Learning: An Introduction (Chapter 13) is the source of the policy gradient theorem derivation and the classic stochastic-policy example (the adversarial three-state grid world, Example 13.1); it is the course's core reference.
  • Andrew Ng machine learning courses — J(theta) notation convention: referenced for the use of \(J(\theta)\) as the cost/objective function notation, a convention this lecture reuses for the performance measure.

DRL Lecture 13 notes

Deep Reinforcement Learning· postgraduate· 2026-08-01

Sections Breakdown

1Deep Q-Network (DQN) - The Original Algorithm (2013)

The 2013 DQN: convolutional network, frame preprocessing, function approximation, experience replay, the training loop, and the chasing-the-target instability.

2Improved DQN (2015) - The Target Network

The frozen target network fix, the C-step refresh schedule, and why a lagging target stabilizes learning.

3Double DQN (DDQN) - Addressing Maximization Bias

Maximization bias via the professor-principal analogy, the Double DQN target, and a worked numeric trace.

4DQN Summary - Framework, Not Just an Algorithm

DQN as a customizable framework, hybrid supervised pre-training, the three-variant comparison table, and exam Q&A.

5Feature Construction in Classical RL

Polynomial features, Fourier bases, and tile coding, and why deep end-to-end feature learning replaced them.

6Transition to Policy-Based Methods - A New Paradigm

The policy network, stochastic vs epsilon-greedy policies, the adversarial grid world, and benefits of policy-based methods.

7Performance Measure and Policy Gradient Objective

J(theta) as expected return from the start state and gradient ascent as the sign-reversed twin of descent.

8The Policy Gradient Theorem

The core differentiation challenge, the theorem statement, and why only the policy network needs differentiating.

9From Theorem to Algorithm - Deriving the REINFORCE Update

Four simplification steps: expectation, multiply-divide by pi, the log-derivative trick, and G_t as quality signal.

10Exam Guidance Summary

Professor's exam focus: 2015 DQN and DDQN, the policy gradient theorem, and the stochastic policy example.

11Key Industry Applications

DQN framework in practice, hybrid supervised + RL training, and policy gradients for continuous control.

12Named References

Research papers (DQN 2013, DQN 2015, Double DQN) and textbooks (Sutton & Barto).

Postgraduate students in Deep Reinforcement Learning

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

Deep Q-Network (DQN) — The Original Algorithm (2013)

Must-know: DQN replaces the Q-table with a neural network Q(s, a; theta); the 2013 target is Y = r + gamma max_a' Q(s', a'; theta) using the SAME parameters theta, which creates the chasing-the-target feedback loop fixed by the 2015 target network.

\[Y = r + \gamma \max_{a'} Q(s', a'; \theta)\]

⚠️ Top pitfall: Assuming the 2013 and 2015 architectures are identical; also assuming replay buffer needs no initialization (it must be pre-populated, e.g., by random play).

Self-check: Why does stacking four frames (84x84x4) help rather than one frame? — A single frame gives no motion information; four frames reveal direction and speed.

Connects to: Section 13.2 (DQN (2015) target network), Section 13.3 — Double DQN

Improved DQN (2015) — The Target Network

Must-know: 2015 DQN target: Y = r + gamma max_a' Q-hat(s', a'; theta-) with the target network frozen and refreshed every C steps (theta- <- theta); this breaks the feedback loop of the 2013 version.

\[Y = r + \gamma \max_{a'} \hat{Q}(s', a'; \theta^-)\]

⚠️ Top pitfall: Thinking the target network learns independently — it is a frozen snapshot, only copied every C steps, and never used for action selection.

Self-check: What happens to the target Y during the C steps between refreshes? — It is constant: theta- is frozen, so the target is fixed.

Connects to: Section 13.1 — DQN (2013), Section 13.3 — Double DQN

Double DQN (DDQN) — Addressing Maximization Bias

Must-know: Maximization bias: max over noisy Q-estimates overestimates because the selected action's noise is positive by construction. Double DQN target: Y = r + gamma Q(s', argmax_a' Q(s', a'; theta); theta-) — online selects, target evaluates.

\[Y = r + \gamma Q\left(s', \arg\max_{a'} Q(s', a'; \theta); \theta^-\right)\]

⚠️ Top pitfall: Confusing the 2015 target network fix (stability) with Double DQN's fix (bias); or thinking the argmax is still overestimating — evaluation by the independent target network makes the target unbiased.

Self-check: Why does Double DQN use the target network to evaluate the action the online network selected? — Independence: the target network's noise is uncorrelated with the online network's selection, so the selected action's lucky noise is not passed into the target.

Connects to: Section 13.2 (DQN (2015) target network), Section 13.1 — DQN (2013)

DQN Summary — Framework, Not Just an Algorithm

Must-know: Three-variant progression: 2013 (unstable, one network), 2015 (frozen target network every C steps, stable), DDQN (online selects, target evaluates, less overestimation). Exam focus is 2015 DQN and DDQN; Bayesian DQN is not examinable; hyperparameter numbers are not tested.

\[Y = r + \gamma \hat{Q}(s', \arg\max_{a'} Q(s', a'; \theta); \theta^-)\]

⚠️ Top pitfall: Memorizing hyperparameters (filter sizes, buffer capacity) instead of the structure and reasoning of each variant.

Self-check: Which DQN versions should be studied for the exam? — 2015 DQN and DDQN; the 2013 version is less critical.

Connects to: Section 13.1 — DQN (2013), Section 13.2 (DQN (2015) target network), Section 13.3 — Double DQN

Feature Construction in Classical RL

Must-know: Classical RL used manual feature construction (polynomial, Fourier, tile coding); tile width controls the bias-variance trade-off; deep learning replaced all of it with automatic end-to-end feature learning.

\[v(s) \approx \sum_{i \in \text{active tiles}(s)} w_i\]

⚠️ Top pitfall: Thinking classical features are still used in modern deep RL — they are obsolete; the network learns features automatically.

Self-check: Why do overlapping tiles give generalization? — Nearby points share active tiles, so they share weights and get similar values.

Connects to: Section 13.1 — DQN (2013)

Transition to Policy-Based Methods — A New Paradigm

Must-know: Policy network outputs pi(a|s; theta) — action probabilities summing to 1 (softmax); the balanced stochastic policy (0.59/0.41) beats deterministic policies in the aliased adversarial grid world; policy-based methods: smooth convergence, continuous actions, domain priors, stochastic optimal policies.

\[\pi(a \mid s; \theta) = \text{probability of taking action } a \text{ in state } s\]

⚠️ Top pitfall: Thinking epsilon-greedy can represent any stochastic policy — it cannot: with aliased states the greedy action must be the same everywhere, and the wall at the start state forces 'right' greedy, which the adversarial state exploits.

Self-check: Why does the balanced 0.59/0.41 policy beat right-greedy? — Right-greedy cycles 1->2->1 forever (adversarial flip); the balanced policy escapes the trap either direction with substantial probability.

Connects to: Section 13.7 — Performance measure and gradient ascent, Section 13.8 — Policy gradient theorem, Section 13.9 — REINFORCE update

Performance Measure and Policy Gradient Objective

Must-know: J(theta) = v_pi_theta(s0) for episodic tasks (expected return from the start, averaged over episodes); policy gradients maximize with gradient ascent theta <- theta + alpha grad J — the sign is the only difference from supervised descent.

\[\theta \leftarrow \theta + \alpha \nabla_\theta J(\theta)\]

⚠️ Top pitfall: Sign errors between descent and ascent; assuming J(theta) is directly differentiable — the environment sits inside the chain, which the policy gradient theorem resolves.

Self-check: What is the performance measure for episodic tasks? — The expected return from the starting state: J(theta) = v_pi_theta(s0).

Connects to: Section 13.8 — Policy gradient theorem, Section 13.9 — REINFORCE update

The Policy Gradient Theorem

Must-know: Policy gradient theorem: grad J(theta) proportional to sum_s mu(s) sum_a q_pi(s,a) grad_theta pi(a|s;theta). Only the network is differentiated; the environment never appears inside a gradient. q_pi appears as an estimated quality signal, not a learned Q-value.

\[\nabla_\theta J(\theta) \propto \sum_{s} \mu(s) \sum_{a} q_\pi(s, a) \nabla_\theta \pi(a \mid s; \theta)\]

⚠️ Top pitfall: Believing policy methods never use Q-values — they use q_pi as a quality signal; the contradiction is resolved because values are estimated as critique, not learned as the actor's output.

Self-check: Why can't we backpropagate through J(theta) directly? — The environment's dynamics sit inside the dependency chain and are not differentiable; the theorem moves the gradient onto the policy network alone.

Connects to: Section 13.7 — Performance measure and gradient ascent, Section 13.9 — REINFORCE update

From Theorem to Algorithm — Deriving the REINFORCE Update

Must-know: REINFORCE update: theta <- theta + alpha G_t grad_theta ln pi(a_t|s_t;theta); G_t is the unbiased Monte Carlo quality signal replacing q_pi; good outcomes raise the action's probability, bad outcomes lower it; known weakness is high variance (motivating baselines and actor-critic).

\[\theta \leftarrow \theta + \alpha \, G_t \, \nabla_\theta \ln \pi(a_t \mid s_t; \theta)\]

⚠️ Top pitfall: Forgetting the log-derivative trick (gradient of ratio is numerically unstable); thinking G_t is the true q-value (it is an unbiased sample, hence high variance); sign errors in ascent.

Self-check: Why is the update proportional to grad_theta ln pi(a_t|s_t;theta) rather than grad_theta pi? — The log-derivative trick rewrites the ratio grad pi / pi as grad ln pi, turning the multiply-divide identity into a computable, stable expectation.

Connects to: Section 13.8 — Policy gradient theorem, Section 13.7 — Performance measure and gradient ascent

Exam Guidance Summary

Must-know: For the exam: study 2015 DQN and DDQN; skip Bayesian DQN and hyperparameter memorization; understand the policy gradient theorem's form and significance; the 0.59/0.41 stochastic policy example is key.

⚠️ Top pitfall: Spending excessive time on numerical drills — the course emphasizes understanding algorithms and their reasoning.

Self-check: Which DQN versions are examinable? — 2015 DQN and DDQN; the 2013 version is less critical.

Connects to: Section 13.1 — DQN (2013), Section 13.3 — Double DQN, Section 13.4 — DQN as a framework, Section 13.6 — Policy-based methods, Section 13.8 — Policy gradient theorem

Key Industry Applications

Must-know: DQN framework + hybrid supervised/RL pre-training pattern; policy gradients for continuous control (Gaussian action distributions) and expert-prior initialization.

Self-check: Why are policy gradient methods preferred for continuous control? — They sample actions from parameterized continuous distributions, while Q-learning's max over actions requires discrete actions.

Connects to: Section 13.1 — DQN (2013), Section 13.6 — Policy-based methods

Named References

Must-know: DQN 2013 -> DQN 2015 (target network) -> Double DQN (maximization bias) is the canonical progression; Sutton & Barto Ch. 13 is the source of the policy gradient theorem.

Self-check: Which paper introduced the target network? — DQN (2015), 'Human-level control through deep reinforcement learning'.

Connects to: Section 13.1 — DQN (2013), Section 13.2 (DQN (2015) target network), Section 13.3 — Double DQN, Section 13.8 — Policy gradient theorem

Was this lecture useful?

Loading comments…