Reinforcement Learning Lab

Eight reinforcement-learning labs: classical, deep, policy optimisation, bandits, planning and multi-agent, with experiments trained for real in your browser.

39interactive experiments

The policy-gradient theorem and REINFORCE

Policy Optimization · policy

Learning objectives

  • Write the policy gradient.
  • Explain the role of a baseline.

The idea

Instead of learning values and extracting a policy, we improve the parameters of π_θ directly by gradient ascent on expected return.

Explanation

REINFORCE weights the log-probability of each action by the full return. Its variance is large; subtracting a baseline b(s) does not change the expectation but reduces variance a lot. It works with continuous actions.

Equations

\nabla_\theta J(\theta)=\mathbb{E}_\pi\Big[\sum_t\nabla_\theta\log\pi_\theta(A_t|S_t)\,(G_t-b(S_t))\Big]

A common baseline is the learned V(s).

Worked example

"REINFORCE with a baseline": the baseline curve is often smoother and faster.

Common mistakes

A large learning rate collapses.

Not normalising rewards or observations.

Summary

Policy gradient improves the policy directly; a baseline lowers variance.

Related experiments

Assessment questions

References

  1. Williams, R. J. (1992). Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning 8:229-256. doi:10.1007/bf00992696
  2. Sutton, R. S.; Barto, A. G. (1998). Reinforcement learning: an introduction (first-edition record; the second edition is free at the author's page). IEEE Transactions on Neural Networks 9(5):1054. doi:10.1109/tnn.1998.712192