AI & ML Atlas
Reinforcement LearningalgorithmInteractive simulation
REINFORCE Algorithm
The basic Monte Carlo policy gradient: reinforce actions in proportion to the return.
The idea
After each full episode, increase the log-probability of every action taken, weighted by the return that followed. Subtracting a baseline (such as the average return) leaves the expected gradient unchanged but greatly reduces variance.
θ ← θ + α · ∇θ log π(a|s) · (G − b)
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- probability of action
- sample pushed up
- sample pushed down
The policy starts uniform: every action is equally likely.
- iteration:
- 0
- expected reward:
- 0.5
1/41
Dots under each bar are the sampled actions in the latest batch.
Step by step
- 1Play one episode with the current policy.
- 2For each step compute the return Gₜ.
- 3Compute ∇ log π(aₜ|sₜ)·(Gₜ − b).
- 4Update θ in that direction.
Where it is used
Simple problems and teaching.
Watch out for
Very noisy and sample-inefficient.