16 Advanced Kitten Play
Deep RL, DQN, Policy Gradients, Actor-Critic, PPO
🐾 Evergreen Chapter: Core mathematics and theory do not expire. Last verified: 2026-02-24
Prerequisites: Chapter 15 Technical Keywords: Deep Reinforcement Learning (Deep RL), Exploration vs. Exploitation, Function Approximation, Deep Q-Networks (DQN), Experience Replay, Policy Gradients, Actor-Critic, PPO (Proximal Policy Optimization)
In Chapter 15, Pixel learned to use a Q-Table. It is a giant spreadsheet:
- Row 1: “Standing on the red rug.” -> Action: Jump.
- Row 2: “Standing on the blue rug.” -> Action: Walk.
But the real world doesn’t have 10 distinct states. The real world has an infinite number of pixels, angles, lighting changes, and smells. A spreadsheet cannot hold the real world.
To survive in a complex environment, Pixel must combine the vision of Phase III (Deep Learning) with the reward-seeking of Phase IV (RL).
He must use a Neural Network to approximate the spreadsheet. Welcome to Deep Reinforcement Learning (Deep RL).
16.1 Exploration vs. Exploitation: The Kitten’s Dilemma
Before we build the neural network, we must solve a psychological problem.
Pixel walks into the kitchen and finds a single piece of dry kibble on the floor. He eats it (+1). According to his math, the kitchen floor is currently the highest-value state in the house. He could just stand there forever, eating one kibble a day. This is Exploitation (using known information to get a guaranteed reward).
But what if there is a massive, freshly opened can of wet tuna in the bedroom (+100)? He will never know, because he refuses to leave the kitchen. To find the tuna, he must engage in Exploration (trying random, unknown things that might result in 0 treats, or might result in the jackpot).
How do we balance this? We use the \epsilon-greedy (Epsilon-greedy) strategy.
- We set \epsilon = 0.10.
- 90% of the time, Pixel does the smartest math-approved action (Exploits).
- 10% of the time, he completely ignores the math and takes a wild, random jump (Explores).
As Pixel gets older and learns the house perfectly, we slowly shrink \epsilon to 0.01.
16.2 Deep Q-Networks (DQN): The Brain Meets the Heat Map
In 2013, researchers at DeepMind combined a Convolutional Neural Network (Chapter 9) with Q-Learning (Chapter 15) to create a Deep Q-Network (DQN) (Mnih et al., 2015). They used it to teach an AI to play Atari video games purely by looking at the pixels on the screen.
Instead of looking up a row in a spreadsheet, the AI feeds the screen’s pixels into a CNN. The CNN outputs 4 numbers—the exact Q-Values for “Up”, “Down”, “Left”, and “Right”.
But deep RL is unstable for a more fundamental reason: the deadly triad (function approximation + bootstrapping + off-policy learning). On top of that, sequential game frames are highly correlated and the Bellman target is moving while the network updates, which can cause divergence.
DeepMind stabilized early DQN results with two key techniques:
1. Experience Replay (Dreaming): As Pixel runs around, he records every step he takes (State, Action, Reward, Next State) into a memory bank. He does not learn immediately. Instead, while he is sleeping, his brain pulls a random handful of 32 memories from the past week and trains the neural network on them. This breaks the chaotic, sequential nature of time and keeps the math stable (Mini-batch SGD from Chapter 3!).
2. Target Networks (The Ghost Kitten): The Bellman Equation relies on guessing the value of the next state. If the neural network is updating its weights every second, the “target” it is aiming for is constantly moving. It’s like a dog chasing its own tail. DQN creates a second, frozen “Ghost” network to calculate the targets. Every 10,000 steps, it copies the real brain into the ghost brain.
16.3 Policy Gradients: Skipping the Map
DQN is great, but it calculates the Value (the heat map) of the room, and then derives the policy from it.
What if the room is a continuous space, like a robot kitten trying to learn the exact angle to bend its mechanical knee? There are an infinite number of angles. You cannot calculate a Q-Value for every decimal point.
Policy Gradients skip the heat map entirely. We train a neural network to directly output the Policy (\pi). The network looks at the room and outputs a probability distribution: “70% chance I should jump, 30% chance I should duck.”
If Pixel jumps and gets a treat, we use Backpropagation (Chapter 8) to mathematically reach into the network and say, “Whatever weights caused you to output ‘Jump’, make them stronger!”
\nabla J(\theta) \propto \sum_t \nabla_\theta \log \pi_\theta(a_t \mid s_t) \cdot G_t (In practice, Actor-Critic methods replace the full discounted return G_t with the Advantage A_t = G_t - V(s_t) to reduce variance.)
16.4 Actor-Critic (PPO): Two Kittens in a Trench Coat
Policy Gradients are fast, but they are incredibly noisy. Sometimes Pixel gets a treat because he made a genius jump. Sometimes he gets a treat because the human accidentally dropped it while he was randomly twitching. Policy Gradients struggle to tell the difference.
We combine the best of both worlds in an Actor-Critic architecture.

Imagine two kittens working together: 1. The Actor (Policy Gradient): Decides what to do. (“I am going to jump!”) 2. The Critic (Value Function): Evaluates how good the Actor’s idea is. (“Wait, the heat map says jumping here usually results in falling. Bad idea!”)
The Actor takes an action, the Critic grades the action, and the Actor updates its probabilities based on the Critic’s grade.
Catastrophic Failure: The Delusional Critic
If the Critic neural network doesn’t have enough training data, it might hallucinate that jumping off the roof yields +10,000 reward. The Actor will blindly trust the Critic, update its policy to jump, and destroy the robot. The two networks must learn in perfect lockstep.
One of the most widely used algorithms in this family is PPO (Proximal Policy Optimization) (Schulman et al., 2017). PPO is an Actor-Critic algorithm with a mathematical safety net. It clips its surrogate objective to discourage overly large policy updates in a single step. It encourages smoother learning, helping prevent the network from accidentally destroying a good strategy during training.
(PPO-style methods are commonly reported in early RLHF pipelines for chat assistants, including publicly described OpenAI work. We will see this family again in Phase V.)
16.5 Removing the Training Wheels
The Real Engineering
We discussed two kittens in a trench coat and dreaming. Deep Q-Networks (DQN) use an Experience Replay buffer to break temporal correlations in the training data, treating RL like supervised learning on mini-batches. Proximal Policy Optimization (PPO) uses a clipped surrogate objective function to discourage the new policy from diverging too far from the old policy in a single update step. The ‘Critic’ is a Value network that estimates the baseline return, reducing the variance of the policy gradient.
16.6 Paws and Reflect: Chapter Quiz
Pixel is playing a game, but he refuses to open the glowing treasure chest in the corner because he is perfectly happy eating the +1 breadcrumbs on the floor. What parameter do you need to increase?
Why did DeepMind adapt “Experience Replay” (originally introduced by Long-Ji Lin, 1992) for DQN instead of just letting the neural network learn from the physical steps exactly in the order they happened?
In an Actor-Critic model, which neural network acts like the “Q-Table/Heat Map” from Chapter 15? Which one acts like the “Rulebook”?
Reveal answers
- You need to increase \epsilon (Epsilon). Pixel is stuck in Exploitation mode. Increasing epsilon forces him to take random actions (Explore) so he can discover the +100 treasure chest.
- Because sequential steps in RL are highly correlated (Step 2 looks almost exactly like Step 1). If a neural network learns on highly correlated data, it overfits to that specific moment and forgets everything else. Replaying random, mixed-up memories stabilizes the math.
- The Critic is the Value Function (the heat map). The Actor is the Policy (the rulebook).
16.7 Chapter 16 Summary
You’ve learned how AI learns to conquer complex, real-world environments:
- Exploration vs. Exploitation: The math of balancing the known safety against the unknown jackpot (\epsilon-greedy).
- Deep RL: Replacing the rigid Q-Table spreadsheet with a fluid Neural Network that can see and generalize.
- DQN: Using Experience Replay (dreaming) and Target Networks to keep the neural network from violently unlearning its own math.
- Policy Gradients: Directly optimizing the probability of taking a good action, bypassing the need for a Value map entirely.
- Actor-Critic & PPO: A widely used modern RL family where one neural network acts, another network critiques, and mathematical guardrails keep learning smoother.
🛑 CHECKPOINT 4: Reinforcement & Reward
You have successfully taught the kitten how to learn from its own actions. You possess the complete blueprint of modern AI: Data, Deep Learning, and Reinforcement Learning.
But Phase V is different. You are no longer learning how to make the AI smarter. You are learning how to make sure the AI doesn’t destroy the house.
The Rules of this Checkpoint:
- You must understand the difference between Loss (Supervised) and Reward (RL).
- You must be able to reason about how agents exploit their environments.
Conceptual Evaluation: 1. The RL Loop: In your own words, map the MDP (State, Action, Reward) to the act of a human teaching a dog to sit. Who is the Environment? What is the State? 2. The Bellman Flow: If a maze has a +100 reward at the exit, and every other square is 0, how does the agent know which way to go when it is 5 steps away from the exit? 3. The Catastrophic Critic: In an Actor-Critic architecture, what happens if the Critic network is poorly trained and constantly outputs the wrong Value for a state? How does the Actor behave? (Answer: The Actor will violently update its policy to take terrible actions, because it trusts the hallucinated grades of the broken Critic).
When you can reason through these checks, continue to Phase V.
We now have highly capable optimization systems. Now, we must align its values with human values. We must look inside its black-box brain. We are entering the Frontier of AI Safety. 🐈🛡️
AI Safety Thread: Chapter 16
Safe Exploration: In a video game, Pixel can die 10,000 times while exploring, and the code just resets. But if you put Deep RL into a physical self-driving car, \epsilon-greedy exploration means that 10% of the time, the car will randomly steer into oncoming traffic just “to see what happens to the Reward.” You cannot allow an agent to explore freely in the physical world. Deep RL often performs well in simulation, but transferring a policy from a safe simulator to the dangerous real world (Sim2Real) remains one of the hardest safety bottlenecks in robotics today.