Policy Gradient Algorithm
Directly adjusts the probabilities of actions to increase expected reward.
The idea
Parameterise the policy πθ(a|s) (for example a softmax over action scores). Run it, and nudge θ so that actions followed by high returns become more likely and those followed by low returns less likely. The policy-gradient theorem gives an unbiased estimate of the gradient of expected return without needing a model.
∇θ J(θ) = E[ ∇θ log πθ(a|s) · Gₜ ]
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
Dots under each bar are the sampled actions in the latest batch.
Step by step
- 1Run the policy to collect trajectories.
- 2Compute the return of each action.
- 3Estimate ∇θ J = E[∇θ log π(a|s) · G].
- 4Take a gradient-ascent step on θ.
- 5Repeat with fresh data.
Where it is used
Continuous actions, stochastic policies, and the base of modern RL.
Watch out for
High variance, so it needs baselines, many samples and small steps.