A linear value function is V^(s)=w⊤ϕ(s) with w=(1,0)⊤. The agent moves from s to s′ with r=2, where ϕ(s)=(1,2)⊤ and ϕ(s′)=(0,1)⊤. With γ=0.9 and α=0.1, compute the semi-gradient TD(0) update, and compare with the residual-gradient update. Why is TD(0) called a "semi-gradient" method?

Reinforcement learning, Function approximation
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can apply TD(0) with function approximation and know that it ignores the dependence of the target on w.

Key idea

Semi-gradient TD(0) is w←w+α δ ϕ(s) with δ=r+γw⊤ϕ(s′)−w⊤ϕ(s). It treats the target as a constant. The residual gradient also differentiates through V^(s′), giving w←w+α δ(ϕ(s)−γϕ(s′)).

Steps

  1. Compute the values: V^(s)=1×1+0×2=1 and V^(s′)=0.
  2. TD error: δ=2+0.9×0−1=1.
  3. Semi-gradient: w←(1,0)+0.1×1×(1,2)=(1.1, 0.2).
  4. Residual gradient: ϕ(s)−γϕ(s′)=(1,2)−0.9 (0,1)=(1, 1.1), so w←(1,0)+0.1×(1,1.1)=(1.1, 0.11).
  5. Explain "semi". The loss 12(r+γV^(s′)−V^(s))2 depends on w through both V^(s) and the target. Semi-gradient differentiates only through V^(s) and treats the target as a fixed number, so it is not the gradient of any fixed objective.
  6. State the consequences: semi-gradient TD usually learns faster and converges (on-policy, linear case) to the TD fixed point. The residual gradient is a true gradient method but converges more slowly and to a different answer.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: Two Bernoulli arms start with uniform Beta(1,1) priors. Arm A has been pulled 4 times with 3 successes and 1 failure. Arm B has been pulled once with 1 success. Give each arm's posterior, mean and variance. What is the probability that Thompson sampling picks B next? Why is this different from a greedy choice?
Next in Reinforcement learning: Show that generalised advantage estimation A^t=∑l≥0(γλ)lδt+l, with δt=rt+1+γV(st+1)−V(st), equals δt when λ=0 and the Monte Carlo advantage Gt−V(st) when λ=1. How do these limits explain the bias–variance role of λ? How do you check your claim on rewards (1,0,2) and values (3,2,1) with γ=0.9?