Concepts / Gradient Descent for Value-Function Approximation

Gradient Descent for Value-Function Approximation

The Gradient Monte Carlo Algorithm evaluates a policy by adjusting the weights of a differentiable value-function approximation.

  • Programming

From Episode Return to Weight Change

A table-based value function can update a state entry directly. With function approximation, the value estimate is represented by v̂(S_t, θ), so learning changes the weight vector θ instead. Gradient Monte Carlo evaluates a policy by generating a complete episode, collecting a return for each visited state, and using those returns to adjust the differentiable approximation.

generatesprovidescompared with estimategradient guides updatePolicy πComplete episodeReturn G_ttarget for S_tWeight vector θupdated approximationv̂(S_t, θ)current estimate
How does a completed episode return flow into the approximate value function and change the weight vector?

Why the Return Is a Useful Target

For a visited state S_t, the algorithm uses G_t, the return from that point in the completed episode. The true state value v_π(S_t) is the expected return after that state. Therefore, G_t is an unbiased estimate of v_π(S_t): across returns generated from the same state under the policy, the expected return equals the true state value. One episode supplies a sample, not the exact value.

contributes to expectationcontributes to expectationcontributes to expectationG_t from episode 1sample returnv_π(S_t)expected returnG_t from episode 2sample returnG_t from episode Nsample return
How do repeated episode returns relate to the true value of the same state?

Unbiased does not mean that every individual return equals the true value. It means that the expected value of the return is the true value.

The Single-State Update

For one visited state, the update compares the episode return G_t with the current estimate v̂(S_t, θ). The difference G_t − v̂(S_t, θ) is the prediction error. This error is multiplied by the gradient of the approximation with respect to θ, scaled by the step size α, and added to θ.

θ ← θ + α [G_t − v̂(S_t, θ)] ∇v̂(S_t, θ)

One return, one parameter update

Consider one visited state with return G_t = 8, current estimate v̂(S_t, θ) = 5, step size α = 0.1, and approximation gradient ∇v̂(S_t, θ) = 2.

Find the prediction error: The error is 8 − 5 = 3.

Scale the gradient direction: The update amount is 0.1 × 3 × 2 = 0.6.

Change the parameter: Add 0.6 to the current parameter value.

The parameter changes by 0.6 in the direction supplied by the approximation gradient.

comparecomparemultiply with gradient and αsets directionG_t = 8episode targetPrediction errorG_t − v̂ = 3Parameter changeα × 3 × 2 = 0.6v̂ = 5current estimateApproximationgradient2
What changes in the weight vector when the prediction error is multiplied by the feature gradient?

Complete-Episode Learning

Gradient Monte Carlo first generates a complete episode using policy π. After the episode is complete, it uses the return G_t for every nonterminal time step t from 0 through T − 1. Each visited state therefore contributes its own comparison between an observed return and the current approximate value. The method is a gradient-descent form of Monte Carlo state-value prediction because the differentiable approximation is improved by changing θ.

extend targetuse complete returnn = 1semi-gradient TD(0)n-stepn-step returnn = infinityGradient Monte Carlo
How does changing n transform the target from one-step TD(0) to an n-step return and finally to the full episode return used by Gradient Monte Carlo?

N-step semi-gradient TD is natural for the on-policy case with a fixed policy because it forms targets from experience generated under that same policy. Semi-gradient TD(0) is the one-step special case. Gradient Monte Carlo is the infinity-step special case, where the target is the full episode return.

generates experiencefollow episodecontributebootstrapsFixed policy πVisited state S_tObserved rewardsthrough the n-step spann-step targetSuccessor estimatewhen the target bootstraps
How do rewards and successor-state estimates move through an episode to form an n-step target under the same fixed policy?

Why Semi-Gradient Is Not True Gradient

A true gradient method differentiates the complete objective with respect to the weight vector. Semi-gradient TD methods use an estimated value in their target, but ignore the target’s dependence on the weight vector when computing the gradient. They therefore use only part of the relevant gradient, which is why they are called semi-gradient methods rather than true gradient methods.

differentiatesdifferentiatesTrue gradientincludes target dependenceComplete gradientprediction and targetSemi-gradient TDignores target dependencePartial gradientprediction only
What differs between differentiating only the estimated value and differentiating through both the prediction and the bootstrapped target?
  • Calling every update involving a gradient a true gradient method.

    Semi-gradient TD ignores the target’s dependence on the weight vector when computing the gradient.

    Fix: Remember that semi-gradient describes a partial gradient calculation.

  • Assuming one return is the exact value of a state.

    G_t is a sample return. Its expected value, rather than every individual sample, equals the true state value.

    Fix: Use the return as an unbiased learning target, not as a claim that the exact value has been observed.

  • Updating a table entry instead of the approximation parameters.

    Function approximation represents values through the weight vector θ.

    Fix: Apply the prediction error, approximation gradient, and step size to update θ.

Convergence and Step Sizes

The convergence guarantee depends on the target being unbiased. If U_t satisfies E[U_t] = v_π(S_t) for every t, and the step size α decreases according to the usual stochastic approximation conditions, then the parameter sequence θ_t is guaranteed to converge to a local optimum.

Variations of stochastic gradient descent are used to find a good weight vector for function approximation. In this setting, the algorithm repeatedly uses sampled targets and parameter updates rather than requiring the exact state value before learning can begin.

Practice Check

MEDIUM

A visited state has current estimate v̂(S_t, θ) = 4. Its completed-episode return is G_t = 10. Explain what the prediction error means, identify the three factors that determine the parameter change, and state whether this target is unbiased for one particular episode or only in expectation across returns.

Hints
  • Compute G_t − v̂(S_t, θ).
  • The update also uses α and ∇v̂(S_t, θ).
  • Distinguish an individual sample return from its expected value.
EASY

Classify each description as Gradient Monte Carlo, semi-gradient TD(0), or a general n-step semi-gradient TD method: a one-step target; a target based on the complete episode return; and a target spanning n steps under a fixed policy.

Hints
  • The one-step case is n = 1.
  • The complete-return case is the infinity-step special case.
  • The general case lies between these endpoints.

Summary

  1. Gradient Monte Carlo generates complete episodes under policy π and uses each visited state’s return G_t as a target.
  2. G_t is an unbiased estimate of v_π(S_t) because the true state value is the expected return after the state.
  3. The parameter update scales the prediction error by the approximation gradient and step size, then adds the result to θ.
  4. With unbiased targets and step sizes satisfying the usual stochastic approximation conditions, the parameter sequence is guaranteed to converge to a local optimum.
  5. Semi-gradient TD methods ignore the target’s dependence on the weight vector, so they are not true gradient methods; semi-gradient TD(0) and Gradient Monte Carlo are the one-step and infinity-step special cases of n-step semi-gradient TD.

Key Takeaways

  • Gradient Monte Carlo improves a differentiable value approximation by adjusting θ from complete-episode returns.
  • The return G_t is a sample target whose expectation equals v_π(S_t).
  • The update uses the prediction error, the approximation gradient, and the step size.
  • Convergence to a local optimum requires unbiased targets and suitable decreasing step sizes.
  • N-step semi-gradient TD connects one-step TD(0) with full-return Gradient Monte Carlo, but semi-gradient TD is not a true gradient method.