Policy gradient theorem with baseline (13.10)
ProvedSuttonBartoRL.PolicyGradient.policy_gradient_baselinebaselinep2o-batch-b23bp2o-gran-per-chapterp2o-plan-bookp2o-v1policy-gradientreinforcement-learning
Let a finite episodic MDP with start state and a differentiable policy parameterization be given, let episodes terminate under , and let be any baseline (a function of the state that does not vary with the action). Then:
- for every state , ;
- is differentiable at and
where is the expected number of visits from and the on-policy distribution.
Subtracting a state-dependent baseline leaves the gradient unchanged; this is what REINFORCE with baseline (13.11) relies on.
Formalization Note The book's "∝" is made exact: the constant is , the average length of an episode (p. 326). The book allows the baseline to be "even a random variable" not depending on the action; here it is a deterministic function of the state.
Preamble
import Mathlib import Definitions.Def_SuttonBartoRL_PolicyGradient_Model import Definitions.Def_SuttonBartoRL_PolicyGradient_EpisodicValues
Formal statement
namespace SuttonBartoRL.PolicyGradient
/-- (13.10), p. 329: the policy gradient theorem with a baseline `b(s)` that does not vary with the
action. For every `b : S → ℝ`, `Σ_a b(s) ∇π(a|s, θ₀) = 0` for every state, and under termination
`∇J(θ₀) = (Σ_{s'} η(s')) Σ_s µ(s) Σ_a (q_π(s, a) − b(s)) ∇π(a|s, θ₀)`. -/
theorem policy_gradient_baseline {S A : Type} [Fintype S] [DecidableEq S] [Fintype A] {d : ℕ}
(M : EpisodicMDP S A) (π : ParamPolicy S A d) (s₀ : S) (θ₀ : EuclideanSpace ℝ (Fin d))
(b : S → ℝ) (hT : M.Terminates π θ₀) :
(∀ s, ∑ a, b s • gradient (fun θ => π.prob θ s a) θ₀ = 0) ∧
HasGradientAt (M.performance π s₀)
((∑ s', M.visits π θ₀ s₀ s') • ∑ s, M.onPolicyDist π θ₀ s₀ s •
∑ a, (M.actionValue π θ₀ s a - b s) • gradient (fun θ => π.prob θ s a) θ₀) θ₀ := by sorry
end SuttonBartoRL.PolicyGradient
Source
Sutton & Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press (2018), ISBN 9780262039246, Eq. (13.10) and the display following it, p. 329
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.