← Back to Reinforcement Learning Mind Map
🎮 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⁡πθ(at∣st)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⁡πθ(a∣s)=∇θπθ(a∣s)πθ(a∣s)\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πθ(at∣st)P(st+1∣st,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⁡πθ(at∣st)\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=∑k≥tγk−trkG_t = \sum_{k\ge t}\gamma^{k-t}r_k (lower variance), giving the REINFORCE update θ←θ+η∑t∇θlog⁡πθ(at∣st)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⁡πθ(a∣s)(Gt−b(s))]\nabla_\theta J = \mathbb{E}[\nabla_\theta \log \pi_\theta(a|s)(G_t - b(s))]. Unbiasedness proof: E[∇θlog⁡πθ(a∣s)b(s)]=b(s)∑aπθ(a∣s)∇θπθ(a∣s)πθ(a∣s)=b(s)∇θ∑aπθ(a∣s)=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.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Policy Gradient Theorem.
Use Cases
In production engineering, what are the primary use cases for Policy Gradient Theorem and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
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
🎯
Verify Mastery: Practice Exam Questions for "Policy Gradient Theorem"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardExploration-ExploitationNext Card →TRPO → PPO Lineage

🔗 More Reinforcement Learning Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/RL/card/policy-gradient
中文速览与面试要点

策略梯度 REINFORCE (Policy Gradient Theorem)

定义: 策略梯度定理给出目标 J( )= E_ [R( )] 对参数 的无模型梯度,核心是 Log-Derivative Trick 与期望形式 _ J = E_ [ _t _ _ (a_t|s_t) G_t]。推导链: 1. 对目标求导并乘除 _ ( ): _ J = _ _ ( )R( )\,d = _ ( ) _ _ ( ) _ ( )R( )\,d = E_ [ _ _ ( ) R( )],其中 Log-Derivative Trick 为 _ _ (a|s) = _ _ (a|s) _ (a|s)(把对概率求导转为对对数概率求导,期望仍无偏); 2. 分解轨迹 _ ( ) = (s_0) _t _ (a_t|s_t)P(s_t+1|s_t,a_t) 并取对数:动力学项 , P 不含 ,求导后消去,只剩 _t _ _ (a_t|s_t) —— 这就是“无需模型、状态分布不可导也能更新”的关键; 3. 因果性:动作 a_t 只影响未来回报,把整段回报换成 reward-to-go G_t = _k t ^k-tr_k(方差更低),得到期望形式,即 REINFORCE 的更新量 + _t _ _ (a_t|s_t) G_t。 使用场景: 回合式任务(需完整轨迹、MC 风格)、连续动作空间;REINFORCE 是最简实现,GRPO/RLHF 的组内相对更新也以其为出发点。 解决的问题: 直接对概率求导困难,且整段回报估计方差极大。引入基线 b(s) 得 _ J = E[ _ _ (a|s)(G_t - b(s))]。基线无偏性证明: E[ _ _ (a|s) b(s)] = b(s) _a _ (a|s) _ _ (a|s) _ (a|s) = b(s) _ _a _ (a|s) = b(s) _ 1 = 0,即减基线不改变梯度期望(无偏),只抵消与动作无关的方差分量;取 b(s) = V(s) 即优势形式,催生 Actor-Critic;步长敏感性则催生 TRPO/PPO。

核心要点

  • 白板手推: 从 J(θ)=E_τ[R(τ)] 出发推导策略梯度定理,说明动力学项为何消去?
  • Log-Derivative Trick 的原理?为什么由此得到的梯度估计是无偏的?
  • 证明 E[∇log π(a|s)·b(s)] = 0,并解释基线为什么能降方差而不改变梯度期望?
  • reward-to-go G_t 与整段回报相比为什么方差更低?REINFORCE 与 MC 的关系?
  • 策略梯度高方差与步长敏感的根源?演化出哪些改进(TRPO/PPO/GAE)?