Reinforcement Learning
Learning what to do from rewards alone: an agent acts, sees rewards, and improves its policy to maximise discounted future reward.
Needs a step first: 24
An agent in a state chooses an action, receives a reward and moves to a new state, as in a Markov chain whose steps it can steer, aiming for the most total reward with future rewards discounted by a factor per step. The value of a state satisfies the Bellman equation : the best now is the best immediate reward plus the discounted best from where you land. Q-learning estimates these values from experience, while policy-gradient methods, used to train game-playing programs and to tune language models towards answers people prefer, adjust a network's action probabilities by gradient ascent.
Where it shows up: The Bellman equation is dynamic programming, which also runs route planners and the control of robots and machines.
How to hold it: In your head
See the Bellman equation as "the best from here is the best reward now plus the discounted best from where you land", and how the discount trades patience against haste.
What knowing it looks like
- Solve the Bellman equation for a small deterministic problem and read off the best policy.
- Explain how the discount factor changes which policy is best.
- Carry out one Q-learning update by hand.
Test yourself
From state A an agent can "stay" (reward 1, remain in A) or "go" (reward 0, move to B). From B the only action gives reward 10 and ends the episode. Find the optimal value and the best action in A when , and again when .
Show the worked answer
Needs a step first: 24
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Reinforcement Learning" (Frontier tier): Learning what to do from rewards alone: an agent acts, sees rewards, and improves its policy to maximise discounted future reward. I already know: Markov Chains, Gradient Descent. Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away. Finish by testing me with this: From state A an agent can "stay" (reward 1, remain in A) or "go" (reward 0, move to B). From B the only action gives reward 10 and ends the episode. Find the optimal value $V^*(A)$ and the best action in A when $\gamma = 0.9$, and again when $\gamma = 0.5$. Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.
Needs first
- Markov ChainsA random process hopping between states, where the next step depends only on the current state and not on how it got there.Undergraduate II · Probability & Statistics
- Gradient DescentRepeatedly stepping against the gradient, , to walk downhill towards a minimum.Undergraduate I · Optimisation & Information
Leads to
This is the end of a path.
On the way to
Recommended
- Neural Networks: Zero to HeroAndrej Karpathy · VideosFree lectures that build backpropagation, a language model and a small GPT from scratch in Python, explaining every line.
- Understanding Deep LearningSimon J. D. Prince (MIT Press) · BookA clear, well-illustrated 2023 textbook covering networks, training, transformers, diffusion models and reinforcement learning, free as a PDF with Python notebooks.
- 动手学深度学习阿斯顿·张、李沐等 · Book · 中文The Chinese edition of Dive into Deep Learning: a free textbook in which every model, from linear regression to transformers, runs as code beside the maths.
- 跟李沐学AI李沐 · Videos · 中文Mu Li's own Bilibili channel: the video course for Dive into Deep Learning and paragraph-by-paragraph readings of key papers, including the Transformer paper.