引言 / Introduction
The extension to function approximation is significantly different and harder for off-policy learning than for on-policy. Tabular off-policy methods extend to semi-gradient algorithms, but these do not converge as robustly as under on-policy training. This chapter explores convergence problems, linear theory, learnability, and new algorithms with stronger guarantees.
函数近似的扩展在off-policy学习中比on-policy显著不同且更难。表格off-policy方法可扩展为半梯度算法,但这些算法不像on-policy训练那样鲁棒地收敛。本章探讨收敛问题、线性理论、可学习性和具有更强保证的新算法。
The challenge of off-policy learning has two parts:
- Part 1 (tabular): correcting the update target — addressed by importance sampling
- Part 2 (function approx only): the update distribution doesn't match on-policy — causes instability
Off-policy学习的挑战有两部分:
- 第1部分(表格):修正更新目标——通过重要性采样解决
- 第2部分(仅函数近似):更新分布不匹配on-policy——导致不稳定
11.1 半梯度方法 / Semi-gradient Methods
To convert tabular off-policy algorithms to semi-gradient form, replace array updates with weight vector updates using approximate value functions and gradients. The per-step importance sampling ratio:
将表格off-policy算法转为半梯度形式,用近似价值函数和梯度将数组更新替换为权重向量更新。逐步重要性采样比率:
ρt = π(At|St) / b(At|St)
Semi-gradient off-policy TD(0) (state values):
wt+1 = wt + αρtδt∇v̂(St, wt)
半梯度off-policy TD(0)(状态价值):
wt+1 = wt + αρtδt∇v̂(St, wt)
For action values, the one-step algorithm is semi-gradient Expected Sarsa (no importance sampling needed for the single action). Multi-step algorithms use ρt+1···ρt+n−1. The tree backup algorithm (from Ch.7) needs no importance sampling at all.
对于动作价值,单步算法是半梯度Expected Sarsa(单动作不需要重要性采样)。多步算法使用ρt+1···ρt+n−1。树备份算法(第7章)完全不需要重要性采样。
⚠️ 注意:这些半梯度方法解决了off-policy挑战的第1部分(修正目标),但没有解决第2部分(修正分布)。因此,它们在某些情况下可能发散。
11.2 Off-policy发散实例 / Examples of Divergence
Simple w-to-2w example: Two states with values w and 2w. Transition from state 1→2 with reward 0. TD error = (2γ−1)w. Update: wt+1 = (1+α(2γ−1))wt. If γ > 0.5, the factor exceeds 1 and w diverges to infinity. This is only possible off-policy because ρt=0 on other transitions prevents counter-balancing updates.
简单w到2w的例子:两个状态,值为w和2w。从状态1→2的转移,奖励为0。TD误差=(2γ−1)w。更新:wt+1=(1+α(2γ−1))wt。如果γ>0.5,因子超过1,w发散到无穷大。这仅在off-policy中可能,因为其他转移上ρt=0阻止了平衡更新。
Baird's Counterexample (Figure 11.1): A 7-state, 2-action MDP. Behavior policy selects dashed/solid actions with prob 6/7 and 1/7 (uniform next-state distribution). Target policy always takes solid action (→ state 7). Linear parameterization with 8 features. Semi-gradient TD(0) and even DP diverge for any positive step size! Changing to on-policy distribution guarantees convergence.
Baird反例(图11.1):7状态、2动作MDP。行为策略以6/7和1/7的概率选择虚线/实线动作(均匀的下一状态分布)。目标策略始终选择实线动作(→状态7)。8个特征的线性参数化。半梯度TD(0)甚至DP都发散(任意正步长)!改为on-policy分布则保证收敛。
Tsitsiklis & Van Roy's Counterexample: Even finding the least-squares best approximation at each DP step doesn't prevent divergence. The w-to-2w example extended with a terminal state shows wk+1 = (6−4ε)/(5−4ε) · wk, which diverges when γ > 5/(6−4ε).
Tsitsiklis和Van Roy的反例:即使在每步DP中找到最小二乘最佳近似也无法防止发散。w到2w的例子加上终止状态显示wk+1=(6−4ε)/(5−4ε)·wk,当γ>5/(6−4ε)时发散。
💡 Averagers(平均器):不推断观测目标之外的函数近似方法(如最近邻、局部加权回归)可保证稳定性,但瓦片编码和ANN等流行方法不在其中。
11.3 致命三要素 / The Deadly Triad
The danger of instability and divergence arises whenever all three of the following are combined:
不稳定和发散的危险在以下三者同时结合时出现:
🔴 函数近似
Function Approximation
线性/ANN等可扩展的泛化方法
🟠 自举
Bootstrapping
使用现有估计作为更新目标
🔵 Off-policy训练
Off-policy Training
非目标策略产生的转移分布
The danger is not due to control, GPI, learning, or environmental uncertainty — it arises in the simpler prediction case and even in planning (DP) with known environments. If any two elements are present but not all three, instability can be avoided. Can any be given up?
危险不是由控制、GPI、学习或环境不确定性导致的——它出现在更简单的预测情况中,甚至在已知环境的规划(DP)中。如果只有两个要素而非三个,可避免不稳定。能放弃哪个?
- Function approximation: Cannot give up — needed for large problems
- Bootstrapping: Possible to give up, but costly — loses computational and data efficiency
- Off-policy: Possible to give up (use Sarsa instead of Q-learning), but essential for parallel learning from one experience stream
- 函数近似:不能放弃——大问题所需
- 自举:可以放弃但代价高——损失计算和数据效率
- Off-policy:可以放弃(用Sarsa代替Q-learning),但对于从一条经验流并行学习是必不可少的
11.5 Bellman误差的梯度下降 / Gradient Descent in BE
True SGD methods always go downhill and have excellent convergence. Only MC methods are true SGD among algorithms seen so far. Can we do SGD on BE or TDE?
真正的SGD方法始终 downhill,收敛性优秀。目前见过的算法中只有MC是真正的SGD。能对BE或TDE做SGD吗?
TDE minimization leads to the naive residual-gradient algorithm:
wt+1 = wt + αρtδt[∇v̂(St) − γ∇v̂(St+1)]. This converges robustly but to wrong values! Example: A-split problem — true values (½,1,0) vs learned (½,¾,¼).
TDE最小化导致朴素残差梯度算法:
wt+1=wt+αρtδt[∇v̂(St)−γ∇v̂(St+1)]。鲁棒收敛但收敛到错误值!例:A-split问题——真值(½,1,0) vs 学到(½,¾,¼)。
BE minimization (residual-gradient algorithm): requires
two independent samples of next state from the same state (double sampling). Works with deterministic environments or simulated environments (roll-back). But:
- Empirically much slower than semi-gradient methods
- Converges to wrong values with genuine function approximation (A-presplit example)
- BE is not learnable from data (next section)
BE最小化(残差梯度算法):需要从同一状态出发的
两个独立下一状态样本(双重采样)。适用于确定性环境或模拟环境(回滚)。但:
- 经验上比半梯度方法慢得多
- 真正的函数近似下收敛到错误值(A-presplit例子)
- BE从数据中不可学习(下一节)
11.6 Bellman误差不可学习 / BE is Not Learnable
Learnability: can a quantity be determined from the observable data distribution (feature vectors, actions, rewards)? Many quantities in RL are well-defined from the MDP but cannot be computed from observed data.
可学习性:一个量能否从可观测数据分布(特征向量、动作、奖励)中确定?RL中许多量从MDP定义良好但无法从观测数据中计算。
🔴 关键结论:VE不可学习,但最优参数可学习:两个不同MDP可以产生相同数据分布但有不同的VE。然而,最小化VE的参数w*在两个MDP中相同。此外,RE(回报误差)= VE + 常数,所以w*可从RE学习。
🔴 致命结论:BE不可学习且最优参数也不可学习:存在两个MDP产生相同数据分布,但有不同的BE且有不同的最小化参数。因此不可能从数据中追求BE作为学习目标。BE仅限于基于模型的场景。
Summary of objectives:
Learnable: RE (and its optimal w*), TDE, PBE (and its optimal w*)
Not learnable: VE (but w* is learnable via RE), BE (and w* is also NOT learnable)
目标总结:
可学习:RE(及其最优w*)、TDE、PBE(及其最优w*)
不可学习:VE(但w*可通过RE学习)、BE(且w*也不可学习)
11.7 Gradient-TD方法 / Gradient-TD Methods
Gradient-TD methods are SGD methods for minimizing the PBE — they have robust convergence even under off-policy training and nonlinear function approximation. The PBE gradient (linear case):
Gradient-TD方法是最小化PBE的SGD方法——即使在off-policy训练和非线性函数近似下也有鲁棒收敛。PBE梯度(线性情况):
∇PBE(w) = 2 E[ρt(γxt+1−xt)xtT] E[xtxtT]−1 E[ρtδtxt]
Store a second learned vector v that approximates E[xtxtT]−1E[ρtδtxt], learned by LMS rule: vt+1 = vt + βρt(δt−vtTxt)xt
存储第二个学习向量v近似E[xtxtT]−1E[ρtδtxt],由LMS规则学习:vt+1=vt+βρt(δt−vtTxt)xt
GTD2: wt+1 = wt + αρt(xt − γxt+1)xtTvt
TDC (GTD(0)): wt+1 = wt + αρt(δtxt − γxt+1xtTvt)
GTD2:wt+1=wt+αρt(xt−γxt+1)xtTvt
TDC(GTD(0)):wt+1=wt+αρt(δtxt−γxt+1xtTvt)
Both are O(d) per step (if xtTvt computed first). They involve two learning processes (a cascade): primary for w, secondary for v. Convergence proofs use two-time-scale analysis (β→0, α/β→0). Extensions: GQ (action values), GTD(λ), nonlinear, hybrid methods.
两者都是每步O(d)(如果先计算xtTvt)。它们涉及两个学习过程(级联):主要学习w,次要学习v。收敛证明使用双时间尺度分析(β→0,α/β→0)。扩展:GQ(动作价值)、GTD(λ)、非线性、混合方法。
11.8 Emphatic-TD方法 / Emphatic-TD Methods
Second major strategy: reweight the states to return the update distribution to the on-policy distribution. Linear semi-gradient TD is stable under on-policy distribution due to positive definiteness of matrix A. Emphatic-TD restores this match using interest It and emphasis Mt:
第二大策略:重新加权状态以将更新分布恢复到on-policy分布。线性半梯度TD在on-policy分布下因矩阵A的正定性而稳定。Emphatic-TD使用interest It和emphasis Mt恢复这种匹配:
One-step Emphatic-TD (episodic)
────────────────────────────────────────────
δt = Rt+1 + γv̂(St+1, wt) − v̂(St, wt)
wt+1 = wt + αMtρtδt ∇v̂(St, wt)
Mt = γρt−1Mt−1 + It (It = interest, Mt−1 init to 0)
On Baird's counterexample, Emphatic-TD converges to the optimal solution (VE→0) in expectation, with all weights converging. However, in practice, the variance is very high, making consistent results hard to obtain computationally.
在Baird反例上,Emphatic-TD在期望意义下收敛到最优解(VE→0),所有权重收敛。然而实际中方差非常高,使计算实验难以获得一致结果。