5.2.6 · D5Deep & Advanced RL

Question bank — REINFORCE algorithm

2,089 words9 min readBack to topic

Before the traps, let's pin down every symbol used below, in plain words and pictures — so no line surprises you.

The picture below shows a trajectory as a chain and how is the discounted sum of the future part of that chain — everything to the right of the chosen action.

Figure — REINFORCE algorithm

True or false — justify

TF1. REINFORCE learns a value function and then acts greedily.
False. It learns the policy directly by nudging ; any value function here is only an optional baseline, not the thing used to pick actions.
TF2. The transition model must be known to compute the REINFORCE gradient.
False. does not depend on , so and it drops out — REINFORCE is model-free.
TF3. Subtracting a baseline makes the gradient estimate biased.
False. As long as doesn't depend on the action, , so it changes only the variance.
TF4. Using reward-to-go instead of the full return changes the expected gradient.
False. By causality — action cannot influence rewards that were already earned before step , so those past rewards are statistically independent of and contribute zero in expectation; both estimators point the same way, but has lower variance.
TF5. The minus sign in the loss is a typo — we should maximize the log-probs.
False. Optimizers minimize, but we want to maximize the objective (average total return); minimizing is exactly gradient ascent on . The minus is essential.
TF6. REINFORCE is an on-policy method.
True. The expectation is over trajectories drawn from the current , so samples from an old policy are not valid without importance corrections.
TF7. A negative advantage means we should never take that action again.
False. It only means "push its probability down this update"; it stays available and can recover if later experience favors it.
TF8. Using as the baseline is a good, unbiased choice, and it is essentially the variance-minimizing state baseline.
True. The value function — the expected reward-to-go from state — is the natural, unbiased state-dependent baseline and (to a very close approximation) the one that minimizes the estimator's variance, which is exactly why it gives the advantage .
TF9. REINFORCE is a Monte Carlo method.
True. It estimates the gradient expectation by sampling whole trajectories and averaging — no bootstrapping from other estimates.
TF10. With a perfect baseline, the REINFORCE gradient variance becomes zero.
False. A baseline can't remove variance from the return itself ; it only removes the state-average component. Residual variance from stochastic trajectories remains.

Spot the error

SE1. "Loss , then run the minimizer."
Error: wrong sign. Minimizing decreases good-action probabilities. Correct loss is .
SE2. "Credit action with the total trajectory return including rewards before ."
Error: no reward exists before , and more generally each should be credited only with its reward-to-go , not reward already banked before it (recall , only correct for the very first action).
SE3. " since has no ."
Error: the expectation's distribution depends on . You cannot push through ; that dependence on is exactly why the log-derivative trick is needed.
SE4. " can depend on the chosen action to be even smarter."
Error: an action-dependent baseline breaks unbiasedness. The proof that the baseline term vanishes needs constant across actions in a state.
SE5. "Since appears in the trajectory probability , its log contributes to the gradient."
Error: its gradient is zero. Although sits inside , it has no in it, so ; only survives.
SE6. "Normalize returns to mean 0 and variance 1 — this changes the algorithm's target."
Partial error. Subtracting the mean is just a constant baseline and is provably unbiased (it leaves the true gradient direction unchanged). Dividing by the standard deviation, however, rescales the whole update like an adaptive learning rate — it is a heuristic that is not part of the unbiased gradient and can change the effective step size per batch.
SE7. "REINFORCE and Actor-Critic are the same because both have a policy."
Error: Actor-Critic bootstraps. It replaces the Monte Carlo with a learned critic estimate (e.g. ), trading variance for bias; REINFORCE uses full-episode returns.

Why questions

WHY1. Why use instead of ?
Start from ; differentiating gives , but is not a probability, so we can't sample it. The identity (just rearranged) rewrites it as — now it's an average we can estimate by sampling trajectories.
WHY2. Why does REINFORCE work for continuous action spaces where value methods struggle?
A Gaussian Policy outputs a mean and spread and samples ; the gradient has a clean closed form, so we never need over an infinite set — an optimization that value methods cannot do exactly in continuous spaces.
WHY3. Why does subtracting a baseline speed up learning even though it's "just adding zero"?
In expectation , so the mean is untouched; but per-sample, if raw returns are all near , every term points up by a huge amount and the useful differences between actions are drowned out. Centering by turns -ish numbers into small advantages, so good actions get a positive push and bad ones a negative push — a cleaner, lower-variance signal.
WHY4. Why is high variance the central problem of REINFORCE?
is a single-sample Monte Carlo estimate summing many random actions and transitions; its spread grows with episode length, so one trajectory's gradient can point far from the true , forcing tiny learning rates and slow, unstable training.
WHY5. Why does the softmax automatically decrease when we increase ?
Softmax sets , and these probabilities must sum to 1; raising the numerator for raises the shared denominator too, so every other action's fraction — including — must shrink. You get "punish the untaken action" for free.
WHY6. Why is REINFORCE called a "policy gradient" method and not a "value gradient" method?
The object it differentiates is , the expected return, taken with respect to the policy parameters — see Policy Gradient Methods. Value functions enter only as optional baselines for variance reduction, never as the thing being maximized.
WHY7. Why can two different baselines give the same expected gradient but different training curves?
Every action-independent baseline contributes in expectation, so all share the same mean gradient (unbiased); but each reshapes the per-sample advantages differently, giving different variances — and lower variance means smoother, faster convergence. This is the core idea of Variance Reduction in RL.

Edge cases

EC1. What is the update when a sampled episode has total return exactly (with no baseline)?
Every term is multiplied by its ; if all the gradient contribution is zero — that episode teaches nothing. This is why sparse-reward tasks train slowly.
EC2. What happens if the baseline equals the return exactly, , for a sample?
The advantage , so that timestep contributes nothing to this update — expected across samples it still gives the correct centered gradient.
EC3. What if the policy becomes deterministic ( for one action)?
Then and its gradient shrinks, so exploration collapses; the agent can get stuck because it never samples alternative actions to learn about them.
EC4. With , what does become and what does the agent optimize?
collapses to just (only the term survives, since and every later ), so each action is credited solely with its immediate reward — a myopic agent ignoring all future consequences.
EC5. With in a non-terminating (infinite-horizon) task, what breaks?
(no shrinking, since ) can diverge to infinity, so returns are ill-defined; you need or an episodic (terminating) task for finite .
EC6. A state is visited only once in the whole dataset — is its baseline reliable?
No; with one sample the value estimate is essentially the single noisy return itself, so the advantage barely reduces variance there. Baselines help most for frequently-visited states.
EC7. All actions in a state are equally good (same true value). What does the advantage do?
Expected advantages are all , so the policy is (correctly) not pushed to prefer any action — REINFORCE leaves indifferent states alone.
EC8. The learning rate is set large because "variance is high anyway." Good idea?
No — high variance already means noisy gradients; a large amplifies that noise and destabilizes training. High variance calls for smaller steps or better variance reduction.

Recall One-sentence summary of the traps

Every trap here reduces to four truths: the gradient is an expectation of a gradient (log-trick), the transition drops out (model-free), an action-independent baseline is unbiased (adds zero in expectation), and the sign must produce ascent on the objective .