Deep Reinforcement Learning
Deep reinforcement learning pairs neural perception with trial and error control, so agents learn features and decisions together from raw input.
Why Does This Exist?
Tabular methods need one entry per state. With an 84 by 84 grayscale camera frame the count of possible images is , far beyond any table. The agent also never sees the same exact frame twice, so memorization cannot generalize.
Linear approximation helped but moved the work to people. Engineers hand built tile codings and basis functions, and those features broke under lighting shifts or new viewpoints. Raw video, lidar and torque streams need features that adapt with the task.
Deep RL joins representation learning to control. One network maps raw input to compact features and then to values or a policy, trained end to end by reward. Early layers learn edges and motion, later layers learn decisions. This page frames that joint loop. For the value instance see deep Q-networks. For the policy instance see policy gradient. For the memory trick that stabilizes it see experience replay.
The one idea you need first
A Markov decision process has states , actions , transition odds , rewards and discount . A parametrized function with weights replaces the table. In deep RL that function is a neural network trained by reward feedback.
Think of It Like This
A rookie short order cook who also designs the kitchen
A rookie starts with random instincts. Tickets arrive as raw orders. Over months the cook learns two things at once: where to place each tool so the counter makes sense, and which move to make next given that layout. Better layout makes better moves easier, and better moves teach which layout matters.
The counter layout is the encoder output . Tool placement is weights . Cooking moves are the policy or values from head weights . Reward is tips and returned plates. No coach hands over a perfect kitchen map. The map and the moves improve together.
Where it stops: a human brings prior senses and imitation. The agent starts from random weights and needs far more trial plates to reach the same fluency.
How It Actually Works
Write the network as an encoder plus a head :
Here is the raw observation, is the compact feature vector and collects and . The head outputs either action values or a policy . Both train from the same reward stream that also shapes the encoder.
Three decision styles on shared features
- Value style learns against the Bellman target from a frozen target net.
- Policy style climbs expected return with the score gradient times return or advantage.
- Actor critic style keeps both: the actor proposes and the critic judges with bootstrapped targets to cut variance.
All three reuse the same encoder, which is why perception and control improve together.
Why training is harder than supervised learning
Targets move because depends on the same weights being trained. Data correlates because follows . Representations shift because new rooms overwrite old features. The trio of function approximation plus bootstrapping plus off policy data can diverge, a pattern called the deadly triad. Replay buffers, frozen targets and clipped objectives exist to tame exactly these effects.
Worked example
Take with two actions, discount and step size . Hidden width with ReLU. Weights:
Forward pass. Pre activations:
ReLU keeps both, so . Outputs:
Transition. Act , earn . Target net rates the next state best at . Target and error:
One gradient step with moves from toward . The same backward pass also reshapes the encoder that built , so perception and values learn from one number.
Code
This snippet repeats the forward pass and Bellman numbers with plain Python.
def relu(v: float) -> float: """Rectified linear unit.""" return v if v > 0.0 else 0.0
s = [1.0, 0.5]W1 = [[0.5, -0.2], [0.4, 0.6]]b1 = [0.1, -0.1]W2 = [[0.8, -0.5], [0.3, 0.7]]b2 = [0.2, -0.3]
z1 = [W1[0][0] * s[0] + W1[0][1] * s[1] + b1[0], W1[1][0] * s[0] + W1[1][1] * s[1] + b1[1]]print([round(v, 4) for v in z1]) # -> [0.5, 0.6]h = [relu(v) for v in z1]print([round(v, 4) for v in h]) # -> [0.5, 0.6]Q = [W2[0][0] * h[0] + W2[0][1] * h[1] + b2[0], W2[1][0] * h[0] + W2[1][1] * h[1] + b2[1]]print([round(v, 4) for v in Q]) # -> [0.3, 0.27]y = 1.0 + 0.90 * 0.80print(f"{y:.4f}") # -> 1.7200td = y - Q[0]print(f"{td:.4f}") # -> 1.4200print(f"{0.5 * td * td:.4f}") # -> 1.0082Hidden values, Q values, target, error and loss match the hand pass, which ties the diagram to the prose.
Watch Out For
New rooms erase old features
Online streams feed long correlated runs from one region. Gradient steps tune the encoder for that region and overwrite features older rooms needed. Return to an old room and values collapse even though the head looks trained.
Symptom: performance swings as the agent moves, with frozen target values lagging behind. Fix it with random replay sampling, a frozen or slowly averaged target and, when needed, an auxiliary objective like reconstruction that forces the encoder to keep global shape.
The Quick Version
- Deep RL trains end to end, so features and decisions improve from one reward signal.
- Value, policy and actor critic heads share the encoder and differ only in what the head predicts.
- Moving Bellman targets, correlated streams and shifting features make training less stable than supervised fits.
- Worked numbers: , , , , loss .
- Replay, frozen targets and clipped updates are the standard stabilizers, not optional extras.
- Hand features fail on raw high dimensional input, which is why the encoder earns its keep.