09 Reinforcement learning

Home | Previous: 08 Diffusion and Flow Matching | Next: 10 Offline RL and Data Coverage

Reinforcement learning improves decisions using consequences. An agent takes an action, the environment changes, and a reward provides feedback. Unlike imitation, it need not have an expert action for every training example.

The Markov decision process

An MDP contains states , actions , transition law , reward , and discount . Markov means the current state contains enough information to predict the next-state distribution given an action.

weights future reward; it does not fix a badly specified reward. A robot rewarded only for approaching an object may learn never to grasp it.

The value is expected return starting at state . The action-value fixes the first action before following . Their Bellman relationship is

This decomposes a long prediction into immediate reward plus a future estimate. The Spinning Up introduction is a primary teaching reference for the notation.

Value iteration on one grid with two discounts. Each sweep applies the Bellman update to every cell, so value spreads one cell per sweep. From the start, the +1 is 2 moves away and the +10 is 10. At the +10 is worth , so the agent takes the +1 (); at it is worth , so the agent goes the long way. Source: Tools/animations/ch09_value_iteration.py.

Actor, critic, and policy gradient

The actor chooses actions; the critic estimates their usefulness. A common policy-gradient form is

with the expectation using the appropriate discounted visitation weighting. The advantage compares an action with the policy’s usual performance at that state. Subtracting a state-only baseline can reduce estimator variance without changing its expectation.

flowchart LR
  Policy["Actor chooses action"] --> Env["Environment"]
  Env --> Data["State, reward, next state"]
  Data --> Critic["Critic estimates return"]
  Critic --> Policy

PPO limits the effect of large policy updates through a clipped objective. SAC learns from replay data and includes an entropy incentive. Neither acronym alone tells you which method fits your task.

Exercise

A transition gives reward 1 and leads to a state valued at 5 with . Compute the one-step target.

Learn first in a small simulator with a proven implementation. Compare learning across multiple random seeds and inspect reward exploitation. Your physical SO-101 should begin with supervised demonstrations and established controllers, not unrestricted trial-and-error exploration.