Back to Reinforcement Learning Mind Map
中文·English
🎮 Reinforcement LearningID: policy-gradient

Policy Gradient Theorem

策略梯度 REINFORCE
🎯Core Definition
The policy gradient theorem gives a model-free gradient of J(θ)=Eτ[R(τ)]J(\theta)=\mathbb{E}_{\tau}[R(\tau)]; the core is the log-derivative trick and the expectation form θJ=Eτ[tθlogπθ(atst)Gt]\nabla_\theta J = \mathbb{E}_{\tau}[\sum_t \nabla_\theta \log \pi_\theta(a_t|s_t) G_t]. Derivation:
📌Overview
1. Differentiate and multiply/divide by πθ(τ)\pi_\theta(\tau): θJ=Eτ[θlogπθ(τ)R(τ)]\nabla_\theta J = \mathbb{E}_{\tau}[\nabla_\theta \log \pi_\theta(\tau) R(\tau)], via the log-derivative trick θlogπθ(as)=θπθ(as)πθ(as)\nabla_\theta \log \pi_\theta(a|s) = \frac{\nabla_\theta \pi_\theta(a|s)}{\pi_\theta(a|s)} (turning a gradient of probabilities into the gradient of their logs, keeping the estimator unbiased); 2. Factor the trajectory πθ(τ)=μ(s0)tπθ(atst)P(st+1st,at)\pi_\theta(\tau) = \mu(s_0)\prod_t \pi_\theta(a_t|s_t)P(s_{t+1}|s_t,a_t) and take the log: the dynamics terms μ,P\mu, P do not depend on θ\theta and cancel, leaving tθlogπθ(atst)\sum_t \nabla_\theta \log \pi_\theta(a_t|s_t) — which is why no model is needed; 3. By causality, action ata_t affects only future returns, so replace the full return with reward-to-go Gt=ktγktrkG_t = \sum_{k\ge t}\gamma^{k-t}r_k (lower variance), giving the REINFORCE update θθ+ηtθlogπθ(atst)Gt\theta \leftarrow \theta + \eta \sum_t \nabla_\theta \log \pi_\theta(a_t|s_t) G_t.
💡Use Cases
episodic tasks (full trajectories, MC-style) and continuous action spaces; REINFORCE is the simplest implementation, and GRPO/RLHF group-relative updates build on it.
Key Problems Solved
differentiating the probability directly is hard and full-return estimates have huge variance. Subtracting a baseline b(s)b(s) gives θJ=E[θlogπθ(as)(Gtb(s))]\nabla_\theta J = \mathbb{E}[\nabla_\theta \log \pi_\theta(a|s)(G_t - b(s))]. Unbiasedness proof: E[θlogπθ(as)b(s)]=b(s)aπθ(as)θπθ(as)πθ(as)=b(s)θaπθ(as)=b(s)θ1=0\mathbb{E}[\nabla_\theta \log \pi_\theta(a|s) b(s)] = b(s)\sum_a \pi_\theta(a|s)\frac{\nabla_\theta \pi_\theta(a|s)}{\pi_\theta(a|s)} = b(s)\nabla_\theta\sum_a \pi_\theta(a|s) = b(s)\nabla_\theta 1 = 0, so a baseline never biases the gradient and only cancels action-independent variance; b(s)=V(s)b(s)=V(s) gives the advantage form and leads to Actor-Critic; step-size sensitivity led to TRPO/PPO.
🎯5 High-Frequency Exam Points
1
Whiteboard: derive the policy gradient theorem from J(θ)=E_τ[R(τ)]; why do the dynamics terms cancel?
2
What is the log-derivative trick, and why does it yield an unbiased gradient estimator?
3
Prove E[∇log π(a|s)·b(s)] = 0 and explain why a baseline reduces variance without biasing the gradient.
4
Why does reward-to-go G_t have lower variance than the full return? How does REINFORCE relate to MC methods?
5
Root causes of high variance and step-size sensitivity; which improvements (TRPO/PPO/GAE) emerged?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Policy Gradient Theorem"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardExploration-ExploitationNext CardTRPO → PPO Lineage

🔗 More Reinforcement Learning Knowledge Cards

Actor-CriticBehavioral CloningContextual BanditCoT & Reasoning RL