The RL foundations note evaluates a fixed policy through its Bellman equation. To improve a parameterized policy, we now differentiate that value with respect to its parameters. After proving the discounted policy-gradient theorem, we examine how algorithms estimate the gradient, control the update, and change the objective.
Recap: The Bellman inverse used in the proof
For a stationary policy in a finite discounted MDP, policy evaluation gives
Here is the policy's state-transition matrix and its expected reward vector. The series converges for . We use this inverse to propagate a policy change through future state visits.
1. One gradient, several algorithmic choices
We begin with a finite-state, finite-action, time-homogeneous Markov decision process. The environment's transition probabilities and expected immediate rewards do not depend on the policy parameter. Assume bounded rewards, a fixed initial distribution , and .
Let be a continuously differentiable stationary policy, with in an open subset of . Define
The normalized discounted state distribution and state–action distribution are
Write : first draw , then . This distribution weights state visits across time by their discount factors. It is not the distribution at a single time or an arbitrary distribution sampled from stored experience. Define the policy score , which measures how the log action probability changes with the policy parameters.
Let be the trajectory distribution generated by , actions from , and next states/rewards from the fixed environment kernel of the foundations note. We write for trajectory expectations, including their conditional versions. The notation fixes instead of drawing it from . All these averages hold fixed; differentiating them later accounts for their dependence on .
The methods below change different parts of policy optimization. REINFORCE and actor–critic estimate the gradient differently. Natural gradients change how we measure the size of a policy update, while TRPO and PPO change the update criterion. Deterministic gradients require different policy and action-space assumptions. Entropy regularization changes the objective to also reward randomness in action choices. An algorithm can combine several of these choices.
2. The discounted policy-gradient theorem
Theorem 1. Under the assumptions above,
This is the discounted start-distribution form of the policy-gradient theorem in Sutton et al. (1999), Theorem 1. The factor appears because is normalized.
First, differentiate the Bellman identity . Put
Since the environment is fixed, . The product rule gives
where . The inverse exists by the Neumann-series argument. Applied coordinatewise to ,
Next, average over the initial distribution:
The final equality uses . Differentiability follows directly from the finite-dimensional inverse formula for ; the convergent series represents that derivative. We have not discarded the effect of changing state visitation: the inverse propagates it through every future transition.
Finally, for each state,
Thus any finite state-only baseline has . Choosing proves the advantage form.
3. REINFORCE: Use sampled returns
The likelihood-ratio construction leads to the Monte Carlo estimator
The batch consists of independent current-policy trajectories. Conditional on , the return under has mean . The tower property and the mean-zero score therefore give . This is the return-based policy-gradient construction associated with Williams's REINFORCE algorithms.
The identity uses full returns, or returns through genuine terminal states in episodic problems. An arbitrary rollout cutoff without its continuation value changes the target. The baseline must be held fixed relative to the trajectory used for this unbiasedness argument; estimating it from those same outcomes needs an additional argument.
Which baseline minimizes variance?
Fix a state and consider the vector contribution . In this subsection, is drawn by sampling and then the discounted continuation return from the environment and policy. The conditional expectations below use that distribution, with fixed. Its conditional mean is independent of . Hence minimizing the trace of its conditional covariance is equivalent to minimizing
Differentiate this scalar quadratic in . If its denominator is positive, the minimizer is
If the denominator is zero, the score is zero almost surely at that state and every baseline is equivalent. This is a variance optimum for a single conditional score contribution, not automatically for the sum of correlated contributions in an episode. In general .
For one decision, let with , reward , and score . Only is random, so
The value baseline reduces variance from to ; makes both possible gradient contributions equal to . This is an exact illustrative calculation, not an empirical benchmark.
4. Actor–critic and generalized advantage estimation
An actor–critic method learns a value function alongside the policy. With an approximate action value , replacing in the theorem gives
Consequently Cauchy–Schwarz yields
A critic can introduce bias; a small prediction error and an exactly unbiased gradient are different properties. Sutton et al., Theorem 2 gives an important exception. For a compatible advantage critic , minimize the population loss
Stationarity in gives
Here the fitted critic gives the exact gradient because the mean product of its residual and the policy score is zero. This is the orthogonality established by the preceding equation. The result requires the displayed population regression, with policy parameters and the sampling distribution fixed. It does not hold for an arbitrary neural critic.
From TD residuals to GAE
For a bounded state-value approximation , define its temporal-difference residual
Here and are fixed. Conditional on , varies through . If , the Bellman equation gives . To incorporate more subsequent rewards, sum residuals:
The intermediate value terms cancel. Generalized advantage estimation (GAE) mixes these horizons. For ,
Bounded rewards and justify the rearrangement by absolute convergence. Here is a trace parameter, unrelated to the kernel noise scale in the earlier article.
At , the estimator is one TD residual. At , the residual series telescopes to because . The latter gives an unbiased score-gradient contribution for any fixed state-only ; its conditional mean need not equal the true advantage unless .
If , all later residuals have zero conditional mean after averaging over their policy-selected actions. Thus every yields the correct conditional advantage. With an imperfect critic, can introduce bias while changing variance. No universal monotone ordering of variances is implied. Unlike the GAE paper's discussion of discounting an undiscounted objective, our target is explicitly with the fixed discount .
5. Natural gradients: Measure changes in policies
Ordinary ascent uses the direction in parameter coordinates. Natural policy gradients instead use a local metric on action distributions. Following Kakade's natural policy gradient, define
For this derivation, assume the policy is twice continuously differentiable and is positive definite. We measure the change between action distributions using Kullback–Leibler (KL) divergence. Holding the reference state distribution fixed, expand its average:
The linear term vanishes by the mean-zero score. For the Hessian, differentiating twice gives
The KL expansion measures policy change by a quadratic form. We therefore compare candidate update directions under the local constraint
For and , the Lagrangian equation and an active constraint give
The natural-gradient direction is . For , choose . Redundant parameterizations, including unrestricted softmax logits, can make singular; an ordinary inverse is then unavailable. Damping or an appropriate pseudoinverse requires a modified treatment, not the positive-definite calculation above.
The compatible-critic normal equations from the preceding section are . When the inverse exists, its coefficients therefore point in the natural-gradient direction. Kakade's original presentation uses an average-reward distribution; the factor here follows from our normalized discounted convention.
6. TRPO and PPO: Change the update criterion
Let be the old policy and a candidate. The performance-difference identity is
To establish it, take a trajectory under . Conditional expectation of given equals . Discount and sum through time :
Bounded values make the final term vanish as . The definition of normalized occupancy then gives the identity. This is the starting point of Schulman et al.'s TRPO analysis.
A local surrogate and a trust region
Replace the candidate state distribution by the old one to define
At , it equals and has the same parameter gradient as . For the derivative, any change in multiplies at the old policy, leaving exactly the policy-gradient term. Away from the old policy the two objectives need not agree.
Practical trust region policy optimization (TRPO) approximately maximizes the sample surrogate subject to an average KL constraint. It uses a linear approximation to the objective and a quadratic approximation to KL, giving the natural-gradient calculation above. It then checks the proposed update.
The paper's theoretical improvement bound instead controls the largest divergence over all states. Replacing that quantity by a sampled average KL is a practical approximation. It does not guarantee that every update improves the true return.
PPO's clipped surrogate
Proximal policy optimization (PPO) uses the action ratio and a fixed advantage estimate . For , its clipped term is
The two signs of advantage give different plateaus:
The sampled objective averages these terms. The original PPO paper's Figure 1 shows the sign-dependent clipping directly.
At ratio one, its derivative matches the ordinary surrogate's derivative. Clipping removes an individual sample's incentive to increase a favorable ratio beyond its plateau. It does not constrain every ratio to the clipping interval, clip the policy's action probabilities, or establish a hard KL bound. This is why PPO's objective and TRPO's constrained update remain distinct.
7. Deterministic and reparameterized policy gradients
We now change assumptions. Keep finite states and , but let actions range over an open subset of . A deterministic policy takes values in that set. Assume , the expected reward, and transition probabilities are continuously differentiable in the relevant parameters/actions; rewards remain bounded. These finite-state conditions make the Bellman inverse differentiable.
Let be the action Jacobian. Differentiating the deterministic Bellman equation gives
Differentiating the current action produces the first term. The second accounts for changes in future actions, which we propagate through the Bellman inverse as in Theorem 1:
This is a finite-state version of Silver et al.'s deterministic policy-gradient theorem. There is no for a point-mass policy. A deterministic argmax over categorical action labels is not the differentiable continuous-action map required here.
The gradient passes through the action input of a critic, not through the unknown physical environment. Exploration may use a separate stochastic behavior policy. Replacing by an uncorrected replay-state distribution does not preserve this exact start-distribution gradient in general; Silver et al. explicitly distinguish their off-policy approximation.
A stochastic policy can also admit a pathwise gradient: write with parameter-independent noise . The policy remains stochastic because varies. This differs from both a deterministic actor and a score-function estimator; Jang et al., Figure 2 illustrates the distinction between differentiating a likelihood and differentiating a sample transformation.
8. Entropy-regularized stochastic actors
Soft actor–critic (SAC) combines a stochastic actor, a critic, off-policy training, and an entropy-regularized objective. It is not another name for natural gradients or PPO. In the finite-action setting, the discounted maximum-entropy target is
The conditional mean of is the policy's entropy. To isolate one policy-improvement subproblem, hold a soft critic fixed at a state and consider the actor loss
For finite actions, define and . Direct substitution gives
Nonnegativity of KL shows that unrestricted minimization chooses . This is the finite-action counterpart of the soft policy-improvement projection in Haarnoja et al., Sections 4.1–4.2. Its critic is entropy-regularized; simply adding entropy to an update using an unchanged ordinary critic is not a derivation of the full SAC algorithm.
For continuous actions and a reparameterizable actor, let be the fixed distribution used to draw replay states (for uniform sampling from a buffer of states, ). Draw and independently , a specified parameter-independent noise distribution, with . Hold the critic, buffer, and fixed. The SAC-style actor objective is
Assuming differentiability and an integrable local bound that permits differentiation under the expectation, its pathwise derivative is
The log density changes in two ways: its parameters change directly, and its action input changes through the sampled action. The total derivative includes both terms. This gives the actor-loss derivative in the SAC paper, Equations (12)–(13), with written explicitly. Averaging this actor loss over stored states does not generally give the ordinary on-policy gradient of .
9. An on-policy actor–critic template
For a compact algorithm, specialize to episodes that terminate after decisions, include decision time in the state, and set terminal value to zero. The continuing formulation above then represents the same problem with absorbing zero rewards after termination. Take unconstrained policy parameters in .
Input: Initial policy parameters and critic parameters ; ; ; iterations ; episodes per iteration; positive actor learning rates .
Output: Fitted stochastic policy .
- for do
- Freeze the current actor and critic .
- Collect independent complete episodes under .
- for each episode do
- Set , , and at the terminal state.
- for do
- Set .
- Set and .
- end for
- end for
- Compute , holding all advantages fixed.
- Update .
- Fit to the fixed targets , retaining value zero at terminal states.
- end for
- return .
This is a simplified methodological template, not a reproduction of TRPO, PPO, or SAC. Advantages use the critic frozen before the current batch. For , critic approximation can bias the actor update; no general global-convergence guarantee is asserted. The factor retains the start-distribution discounted objective used in this article.
10. Connect the method to its assumptions
| Choice | What changes | Principal qualification |
|---|---|---|
| REINFORCE | Estimate action values using sampled returns | On-policy sampling and complete returns for the displayed unbiased estimator |
| Actor–critic / GAE | Estimate values or advantages using a critic and TD residuals | Approximation error, baseline dependence, and rollout boundaries matter |
| Natural policy gradient | Use the Fisher metric instead of Euclidean parameter length | The inverse formula needs a nonsingular metric |
| TRPO | Optimize a local surrogate with a divergence constraint | Practical average-KL optimization approximates the theoretical bound |
| PPO | Optimize a clipped, sign-dependent surrogate | Clipping is not a hard probability-ratio or KL constraint |
| Deterministic policy gradient | Differentiate a smooth continuous-action actor through action values | Not an argmax derivative for categorical actions; data-distribution correction remains separate |
| SAC-style stochastic actor | Optimize an entropy-regularized critic objective, often pathwise | Different objective and critic; stochastic even with reparameterization |
The offline-learning article separates data access from policy type. Neither an actor–critic label nor a single action-probability ratio automatically corrects the state distribution of arbitrary logged data.
References
- Ronald J. Williams (1992). Simple Statistical Gradient-Following Algorithms for Connectionist Reinforcement Learning. Machine Learning, 8, 229–256. Open paper. REINFORCE and likelihood-ratio updates.
- Richard S. Sutton, David McAllester, Satinder Singh, and Yishay Mansour (1999). Policy Gradient Methods for Reinforcement Learning with Function Approximation. NeurIPS. Theorems 1–2: policy gradients and compatible critics.
- Sham Kakade (2001). A Natural Policy Gradient. NeurIPS. Fisher geometry and compatible function approximation. We use a normalized discounted variant rather than the paper's average-reward convention.
- John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel (2016). High-Dimensional Continuous Control Using Generalized Advantage Estimation. ICLR. Section 3, Equations (14)–(18).
- John Schulman, Sergey Levine, Philipp Moritz, Michael Jordan, and Pieter Abbeel (2015). Trust Region Policy Optimization. ICML. Performance differences, surrogate objectives, and theoretical versus practical divergence control.
- John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov (2017). Proximal Policy Optimization Algorithms. Section 3 and Figure 1.
- David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin Riedmiller (2014). Deterministic Policy Gradient Algorithms. ICML. Theorem 1 and the distinction between on-policy identities and off-policy approximations.
- Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine (2018). Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor. ICML. Soft policy improvement and the reparameterized actor loss.
- Eric Jang, Shixiang Gu, and Ben Poole (2017). Categorical Reparameterization with Gumbel-Softmax. ICLR. The reproduced Figure 2 distinguishes several gradient estimators; its final panel is the paper's categorical relaxation, not a continuous-action SAC diagram.


