Value Function Approximation

Reinforcement Learning · Lecture 5
Christopher Mutschler
University of Technology Nuremberg
12 November 2026
Today

Where we are going

  1. Why function approximation? Generalize beyond a table.
  2. Linear VFA. Features, regression, semi-gradient updates.
  3. Fitted Q-Iteration. Turn Bellman backups into supervised learning.
  4. Deep Q-Networks. Neural approximation plus two stabilizers.
Today's question
How do we keep Q-learning useful when the state space is too large to enumerate?
Part 1

Why approximate value functions?

Tables remember. Function approximators generalize.

Recap · Lecture 4

Tabular Q-learning updates one entry at a time

One-step target

Great when every state-action pair has its own cell. Not so great when there are millions, billions, or infinitely many states.

state←→
0.20.3
−0.10.7
0.01.4
⋮⋮⋮
??
No automatic sharing between similar rows.
Challenge #1

In real world problems, the state space can be large

Backgammon states
approx. number of states:
Backgammon board
Computer Go states
approx. number of states:
AlphaGo board position
Robot arm: infinitely many states
approx. number of states:
Franka Emika Panda robot arm in MuJoCo
Storage
There are too many states and/or actions to store in memory.
Data
Even if the table fits, visiting enough state-action pairs takes far too long.
Local updates
Only nearby states are observed, so value information propagates slowly.
Challenge #2

Generalization across states

Let’s say we discover through experience that this state is bad:
Pac-Man state 1
In naïve Q-learning, we know nothing about this state:
Pac-Man state 2
Or even this one!
Pac-Man state 3
We need a representation that generalizes and speeds up learning across states.
Reference: Pieter Abbeel: CS 188 Introduction to Artificial Intelligence. Fall 2018.
Representation

From a table to a parameterized function

Value Function Representations

Exact:

  • A table with a distinct value for each case
  • : one entry per
  • : one entry for each pair

Approximate:

  • Approximate or with a function approximator
  • e.g., neural networks, polynomials, RBFs, …
+ We only need to store the approximator parameters
− Convergence properties do not hold anymore in general
State-value approximator
State-action value approximator
Multi-output action-value approximator
David Silver, Reinforcement Learning lecture notes, 2016.
Features

Describe a state using a vector of features

VFA: Describe a state using a vector of features.

Features are functions from states to real numbers that capture important properties of the state.

Example features for Pac-Man:

  • Distance to closest ghost
  • Distance to closest dot
  • Number of ghosts
  • …
Pac-Man state used to motivate feature representations
Example adapted from Pieter Abbeel, CS 188 Introduction to Artificial Intelligence.
Learning the parameters

Turn value approximation into a regression problem

Our goal is to learn parameters that approximate the target action value well.

↓
↓ gradient
↓ gradient-descent update
Where does come from?
Method
Target
Q-learning
SARSA
Monte Carlo
The regression target is supplied by the RL algorithm.
Linear VFA

Linear in the parameters, rich in the features

Why we like it
Fast updates, interpretable features, and much stronger stability results than arbitrary nonlinear approximators.
But
Good performance depends heavily on choosing a feature map that makes the value function easy to represent.
The learner tunes ; the designer decides what can express.
Feature design

Several ways to turn a state into features

Polynomial
Products and powers of coordinates
∿
Fourier
Cosine basis at multiple frequencies
▦
Tile coding
Sparse overlapping partitions
◡
RBF
Localized Gaussian features
Same learner, different geometry
Changing changes which states share parameters — and therefore which states generalize to one another.
The approximation is linear in the parameters . The feature map may be highly non-linear.
Feature design · Polynomial basis

Polynomial features create non-linear value functions

Action A
Action B
Action C
Action D
Four example polynomial fits for four actions
Feature design · Polynomial basis

A feature map can lift a low-dimensional state into many monomials

Trade-off
Higher degree increases expressiveness — but the number of features grows quickly with state dimension.
Polynomial examples
Feature design · Fourier basis

Fourier features represent smooth structure with different frequencies

Four Fourier basis functions of increasing frequency
Sutton, R. S., & Barto, A. G. (2018). Reinforcement Learning: An Introduction. MIT Press.
Feature design · Tile coding

Tile coding turns a continuous state into a sparse binary representation

Several offset tilings cover the same continuous state space. A point activates one tile per tiling.
Tile coding with four overlapping tilings
Key idea
Nearby states share some active tiles → local generalization without a single hard discretization.
Sutton, R. S., & Barto, A. G. (2018). Reinforcement Learning: An Introduction. MIT Press.
Feature design · RBFs

Radial basis functions create local, smooth features

Example features: Radial Basis Functions (RBFs)
Three radial basis functions centered at neighboring points with width sigma_i
Sutton, R. S., & Barto, A. G. (2018). Reinforcement Learning: An Introduction. MIT Press.
Why linear VFA?

Convergence of control algorithms

Function approximation lets us generalize, but it changes the convergence story.

AlgorithmTable LookupLinearNon-linear
Monte-Carlo Control✓(✓)✕
SARSA✓(✓)✕
Q-learning✓✕✕

(✓) = chatters around a near-optimal value function

Value Function Approximation

Two important questions

  1. Can we approximate any value function with a linear function approximator?
  2. Is it easy to find such a linear function approximator?
Keep both questions separate
Expressiveness and feature discovery are not the same problem.
Question 1 · Expressiveness

Can a linear FA approximate any value function?

1. Can we approximate any value function with a linear FA?
Answer
YES! (But the proof is out of scope for this class.)
Question 2 · Feature discovery

Is it easy to find such a linear FA?

2. Is it easy to find such a linear FA? → YES!
Example Gridworld
  • No obstacles
  • deterministic actions (U/D/L/R)
  • no discounting
  • reward is −1 everywhere except +10 at the goal
goal at the top-right corner
Linear VFA · calculation

Represent the state and perform linear VFA

Represent state by a feature vector:

Perform linear value-function approximation:

Linear VFA · calculation

Is there a good linear approximation? → YES

Choose weights that encode distance to the goal:

Interpretation
The value decreases linearly with the Manhattan distance to the goal.
goal value +10
Feature design · calculation

Move the reward: the same features no longer work

With reward in the interior
Is there a good linear approximation with only ? → NO!

Add a nonlinear feature that measures distance to the new goal:

Now: → YES!

reward moved to (3,3)
Feature engineering · Tetris

Is it easy to find a good linear FA? → NO!

FeatureDescription
Landing HeightHeight of last piece is added.
Eroded Piece Cells#rows eliminated in the last move × #bricks eliminated from the last piece.
Row Transitions#horizontal full↔empty transitions between cells.
Column TransitionsSame idea for vertical transitions.
Holes#empty cells covered by at least one full cell.
Tetris feature engineering example
Thierry, C. & Scherrer, B.: Improvements on Learning Tetris with Cross-Entropy. 2010. · Tetris illustration: flaticon.com/free-icon/tetris_1006985
Feature engineering · Tetris

Is it easy to find a good linear FA? → NO!

FeatureDescription
Board WellsSum of well depths (triangular depth penalty).
Column HeightHeight of the p-th column.
Column DifferenceAbsolute height difference between adjacent columns.
Maximum HeightMaximum pile height.
HolesEmpty cells covered by at least one full cell.
Tetris board
Thierry, C. & Scherrer, B.: Improvements on Learning Tetris with Cross-Entropy. 2010. · Tetris illustration: flaticon.com/free-icon/tetris_1006985
Feature engineering · Ms. Pac-Man

Hand-crafted features must encode the relevant geometry

FeatureDescription
Nearby WallsExistence of walls in all four directions.
Nearest TargetDirection of the nearest target where Ms. Pac-Man should move.
Nearby GhostsExistence of a ghost in all four directions.
Existence of EscapeWhether Ms. Pac-Man can move freely or is trapped.
Ms Pac-Man example 1Ms Pac-Man example 2Ms Pac-Man example 3
Tziortziotis, N., Tziortziotis, K. & Blekas, K.: Play Ms. Pac-Man Using an Advanced Reinforcement Learning Agent. 2014.
Feature engineering · LSPI

A pendulum: 30 carefully placed basis functions

LSPI pendulum basis-function description
Pendulum animation
with
Lagoudakis, M. G. & Parr, R.: Least-Squares Policy Iteration. JMLR, 2003.
Feature engineering · LSPI

A bicycle: 100 hand-designed basis functions

Animated bicycle balancing task
Scale
20 basis functions per action × 5 actions = 100 parameters.
Bicycle task and feature description
Lagoudakis, M. G. & Parr, R.: Least-Squares Policy Iteration. JMLR, 2003.
Value Function Approximation

Idea: Why don’t we replace linear approximation with NNs?

Non-linear function approximation breaks the classical convergence guarantees.

AlgorithmTable LookupLinearNon-linear
Monte-Carlo Control✓(✓)✕
SARSA✓(✓)✕
Q-learning✓✕✕

(✓) = chatters around a near-optimal value function

But in some applications, it did 🙂
World's best Backgammon player:
  • Neural network with 80 hidden units
  • RL from 300,000 games of self-play
  • One of the top players in the world
Backgammon board
Value Function Approximation

Parenthesis: Gerry Tesauro's TD-Gammon ('92, '94, '95)

TD-Gammon neural network
Backgammon board
TD-Gammon self-play learning curve
TD error drives a neural value function; more hidden units improved self-play performance.
Tesauro, G.: Temporal difference learning and TD-Gammon. 1995. · Backgammon illustration: flaticon.com/free-icon/backgammon_683899
Part 2

Fitted Q-Iteration

Freeze the Bellman targets. Fit a regressor. Repeat.

Motivation · Fitted Q-Iteration

Why are one-step online updates not enough?

Use of data
Each update is driven by only one transition, even when we already have a large batch of experience.
Moving targets
Bootstrapped targets change whenever the current value estimate changes.
Model restrictions
Gradient updates tie us to a differentiable parameterization and a particular optimization procedure.
Couldn’t we try the problem differently?
Freeze the current Bellman targets, fit one regressor on the whole batch, and repeat.
Fitted Q-Iteration

Bellman backups become supervised-learning targets

1
Datasettransitions (sᵢ,aᵢ,rᵢ,s′ᵢ)
→
2
Frozen Bellman labelscompute one target per transition
→
3
Regressionfit Q to those labels
Connection to supervised learning
For one FQI iteration, the targets are fixed. Learning is ordinary regression on Bellman targets; the Bellman error is the regression residual.
Fitted Q-Iteration · limitations

What limits Fitted Q-Iteration?

FQI turns reinforcement learning into a sequence of clean regression problems — but each outer iteration is still a batch procedure.
1
Full-batch sweeps
Bellman targets are recomputed for the entire transition dataset at every outer iteration.
2
Refit the regressor
After changing the targets, the function approximator must be fitted again — expensive as the dataset grows.
3
Scaling to rich observations
Hand-designed features and classical regressors become the bottleneck for high-dimensional inputs such as images.
Open question
How can we keep the fixed-target regression idea while learning efficiently from large experience streams and high-dimensional observations?
Part 3

Deep Q-Networks

Use a neural network as the action-value approximator — then stabilize the learning problem.

Deep Q-Networks (DQNs)

A game-changing result: DQN from DeepMind

Atari Breakout example
Atari 2600 game collage
Mnih et al. (2015), Human-level control through deep reinforcement learning, Nature.
Deep Q-Networks (DQNs)

DQN from DeepMind: performance across Atari games

One algorithm, one broad architecture, many different games — evaluated against human-normalized performance.

DQN Atari human-normalized performance chart
Mnih et al. (2015), Human-level control through deep reinforcement learning, Nature.
Deep Q-Networks (DQNs)

How does it work?

  • A convolutional neural network reads the game image — typically a stack of the last 4 frames.
  • The CNN is a value-function approximator for the action-value function.
  • The reward is the game score.
  • The network weights are tuned by backpropagating learning signals derived from rewards.
Atari frame input
→
CNN learned features
→
Q-values for all actions
Mnih et al. (2015) · David Silver, Reinforcement Learning lecture notes.
Deep Q-Networks (DQNs)

How does it work?

Linear VFA
NN VFA
Approximated Q-function:
Target value:
Update:
Mnih et al. (2015)
Deep Q-Networks (DQNs)

From Q-learning to a neural Q-function

Q-learning control loop

Start from the standard Q-learning control loop

The environment produces the next transition after each action.
The policy π acts ε-greedily with respect to the current Q-function.
Q-learning updates the action value using reward + bootstrap target.
Deep Q-Networks (DQNs)

DQN v0.1 · Replace the Q-table by a neural network

DQN v0.1 diagram

The same Q-learning idea, now with parameters w

For one transition, evaluate the network at the current state-action pair and at the next state.
The TD loss uses the same network for the prediction and for the bootstrap target.
Backpropagate the loss and update the network parameters w.
Deep Q-Networks (DQNs)

Stabilizer #1 · Experience Replay

  • How does it work?
  • A bag of tricks for stabilizing learning:
    1. Experience Replay:
      • Problem: Experiences are correlated over time.
        → Oscillations and divergence during learning.
      • Solution: Random sampling of experience mini-batches from a memory.
        → Samples can be re-used to increase data efficiency.
        → Breaking correlations by randomization reduces variance.
Experience replay memory illustration
http://www0.cs.ucl.ac.uk/staff/d.silver/web/Resources_files/deep_rl.pdf
Deep Q-Networks (DQNs)

DQN v0.1 · Before experience replay

DQN v0.1 diagram

The first neural version still trains on the current stream

Consecutive experiences are strongly correlated.
The same network is used to compute both terms of the TD loss.
Experience replay addresses the first problem.
Deep Q-Networks (DQNs)

DQN v0.2 · Add experience replay

DQN v0.2 diagram with replay memory

Train from random mini-batches sampled from memory

Store transitions in a replay memory.
Sample random mini-batches for gradient updates.
Reuse past experience and break temporal correlations between successive updates.
Deep Q-Networks (DQNs)

Stabilizer #2 · The target keeps moving

  • How does it work?
  • A bag of tricks for stabilizing learning:
    1. Experience Replay.
    2. Separate, frozen target Q-network:
      • Problem: Target Q-values change constantly.
      • → Oscillations and divergence during learning.
Deep Q-Networks (DQNs)

Stabilizer #2 · Use two Q-networks

  • How does it work?
  • A bag of tricks for stabilizing learning:
    1. Experience Replay.
    2. Separate, frozen target Q-network:
      • Solution: Two Q-networks:
      • → Frozen Target Q-network with parameters predicts Q-learning targets .
      • → Dynamic Main Q-network with parameters evaluates current Q-values .
      • → Perform a gradient descent step (w.r.t. ) towards
      • Added delay breaks correlations between Q-network and target.
      • Avoids oscillations by having fixed targets.
      • (Note: We periodically update the target Q-network by copying the weights .)
      • Reduces chance of divergence.
Deep Q-Networks (DQNs)

DQN v0.2 · Replay is not enough

DQN v0.2 diagram with experience replay

Replay fixes the correlated data stream — but not the moving target

Random mini-batches reduce correlations between training samples.
The online network still generates its own bootstrap target.
Next: freeze a separate target network for several updates.
Deep Q-Networks (DQNs)

DQN v1.0 · Add the frozen target network

DQN v1.0 diagram with evaluation and target networks

Replay + target network = the core stabilization recipe

The evaluation network is updated by gradient descent.
The frozen target network supplies the bootstrap target.
Every k timesteps, copy the evaluation-network weights to the target network.
Deep Q-Networks (DQNs)

Stabilizer #3 · Reward clipping

  • How does it work?
  • A bag of tricks for stabilizing learning:
    1. Experience Replay.
    2. Separate, frozen target Q-network.
    3. Apply reward clipping:
      • Problem: Large rewards result in large variances in Q-values.
      • Different games have different reward values.
      • Oscillations and divergence during learing.
      • Solution: Clip the rewards (and loss terms) to a range [−1.0, 1.0].
      • Avoids oscillations by normalizing rewards when training for multiple games.
      • Prevents Q-values from becoming too large.
GitHub issue about reward/loss clipping in DQN
Extension #1

Double DQN reduces maximization bias

Vanilla target

The max tends to select actions whose estimates are accidentally high.

Double DQN
online selectstarget evaluates
Extension #2

Prioritized Replay spends updates where the Bellman error is large

Sampling priority

Transitions with surprising targets are replayed more often.

Importance-sampling weights can compensate for the bias introduced by non-uniform sampling.

Extension #3

Dueling networks separate state value from action advantage

Single-stream network
single stream
Dueling network
dueling architecture
Intuition
Learn whether a state is good even when the exact action matters little.
Rainbow
Later work combined Double DQN, prioritized replay, dueling networks and other improvements into one agent.
Extension · Rainbow

Rainbow combines several DQN improvements in one agent

Rainbow and DQN variants on Atari as a function of training frames
Hessel et al. (2018), Rainbow: Combining Improvements in Deep Reinforcement Learning. AAAI.
The Deadly Triad

Three ingredients make instability especially likely

1
Function approximation
shared parameters couple values
2
Bootstrapping
targets use current estimates
3
Off-policy learning
behavior and target policies differ
DQN uses all three — so its stabilizers are not cosmetic.
Takeaways

The conceptual ladder

table
→
features + parameters
→
FQI regression
→
DQN
  1. Function approximation trades exact storage for generalization.
  2. Fitted Q-Iteration makes Bellman backups look like supervised labels.
  3. DQN uses a neural Q-function, but needs a better optimization schedule.
  4. Experience replay decorrelates updates and reuses data.
  5. Target networks slow down the movement of Bellman labels.
Lesson of today
“Be careful with (non-linear) function approximation.”
generalization
↔
interference
↔
stability tricks

Powerful representations are useful precisely because one update can change many predictions. That is also why they can destabilize learning.

Video preview
References

Key sources