Skip to content

Q-learning

Decisions under uncertainty · 1989 · After Value iteration

Q-learning finds good actions without being told how the world works, by nudging its estimates towards what actually happens after each move.

Decisions under uncertainty

Q-Learning

Value iteration and policy iteration both read the rulebook: T and R. What if the robot has no rulebook, and can only try moves and see what happens? Q-learning learns the value of every move in every square straight from experience, without ever learning T.

Same gridworld as the previous pages. This is model-free reinforcement learning; world models vs RL shows what changes when the agent learns a model as well.

1 · The update

Nudge a guess towards what just happened

← Q(s,a) + [ + − Q(s,a) ]

Compare it with the value-iteration update. Where value iteration averages over every possible landing square using T, Q-learning uses the one square it actually landed in, and averages over many visits through the learning rate. Q-values are learned instead of V because choosing an action from V needs T; from Q, the best action is simply the largest of four numbers.

2 · Run it

Thousands of real steps for eleven squares

Lab 1 · Learn by doing

each square shows four Q-values, one per direction; episodes start bottom-left

Progress

Average return of the last 50 episodes

γ = 1, noise 0.2, living reward −0.04, as in the textbook example. “Matches the best action” compares the learned greedy choice in each of the 9 open squares with the policy value iteration computes from the full model. Returns include exploration moves, so they stay below the optimum while ε > 0.

3 · Explore or exploit

You only learn about moves you try

With probability ε the agent moves at random; otherwise it takes its current best move. Set ε to 0 and it can settle on the first route that works and never discover a better one. Set it high and it learns everything but performs badly while doing so. The same tension, handled with a bonus instead of randomness, drives the selection rule in Monte Carlo tree search.

4 · The price of no model

Twenty-eight sweeps versus thousands of steps

With the model, value iteration solved this grid in 28 sweeps and zero real moves. Without it, Q-learning needs thousands of real moves, each one a real-world risk for a robot, and it still wobbles between near-equal moves. That gap is the reason to learn a model: Dyna replays a learned model to cut the real steps, and world models scale the idea up. Deep Q-networks (DQN) replace the table with a neural network so the same update works when the states are screen pixels.

Next: What is a world model