◇【论文_20181020 v6】广义优势估计器 (generalized advantage estimator, GAE)

https://arxiv.org/abs/1506.02438

ICLR 2016
加州伯克利 电子工程与计算机科学系

High-Dimensional Continuous Control Using Generalized Advantage Estimation

文章目录

  • 摘要
  • 1 引言
  • 2 预备知识
  • 3 优势函数估计
  • 4 解释为 奖励设计reward shaping
  • 5 价值函数估计
  • 6 实验
    • 6.1 策略优化算法
    • 6.2 实验设置
      • 6.2.1 网络架构
      • 6.2.2 任务细节
    • 6.3 实验结果
      • 6.3.1 Cart-pole
      • 6.3.2 3D 双足运动
      • 6.3.3 其他 3D 机器人任务
  • 7 讨论
  • 致谢
  • A 常见问题
  • B 证明

摘要

Policy gradient methods are an appealing approach in reinforcement learning because they directly optimize the cumulative reward and can straightforwardly be used with nonlinear function approximators such as neural networks. 【xx 是… (定义),(优点)】
策略梯度方法在强化学习中是一种极好的方法,因为它们直接优化累积奖励,并且可以直接与非线性函数近似器(如神经网络)一起使用。
The two main challenges are the large number of samples typically required, and the difficulty of obtaining stable and steady improvement despite the nonstationarity of the incoming data. 【当前的 2 个挑战】
两个主要的挑战是通常需要大量的样本,以及尽管输入数据具有非平稳性,但难以获得稳定持续的改进。
We address the first challenge by using value functions to substantially reduce the variance of policy gradient estimates at the cost of some bias, with an exponentially-weighted estimator of the advantage function that is analogous to TD( λ \lambda λ). 【本文相应的 2 个 应对方法】
我们通过使用价值函数来解决第一个挑战,以一些偏差为代价大幅减少策略梯度估计的方差,并使用类似于 TD( λ \lambda λ) 的优势函数的指数加权估计器。
We address the second challenge by using trust region optimization procedure for both the policy and the value function, which are represented by neural networks.
我们通过对由神经网络表示的策略和价值函数使用信任域优化程序来解决第二个挑战。

Our approach yields strong empirical results on highly challenging 3D locomotion tasks, learning running gaits for bipedal and quadrupedal simulated robots, and learning a policy for getting the biped to stand up from starting out lying on the ground. 【做了哪些实验来评估 拟议解决方案】
我们的方法在极具挑战性的 3D 运动任务中产生了强有力的经验结果,学习双足和四足模拟机器人的跑步步态,以及学习 让双足动物从开始躺在地上到站起来的策略。
In contrast to a body of prior work that uses hand-crafted policy representations, our neural network policies map directly from raw kinematics to joint torques. 【与其他类似方法相比, 优点】
与之前使用手工制作策略表示的工作相比,我们的神经网络策略直接从原始运动学 映射到 关节扭矩。
Our algorithm is fully model-free, and the amount of simulated experience required for the learning tasks on 3D bipeds corresponds to 1-2 weeks of real time.
我们的算法是完全 无模型的model-free,3D 两足动物学习任务所需的模拟经验量对应于 1-2 周的现实时间。

1 引言

【拟处理的问题的基本背景】

The typical problem formulation in reinforcement learning is to maximize the expected total reward of a policy.
强化学习中典型的问题表述是最大化 策略总奖励期望
A key source of difficulty is the long time delay between actions and their positive or negative effect on rewards; this issue is called the credit assignment problem in the reinforcement learning literature (Minsky, 1961; Sutton & Barto, 1998), and the distal reward problem in the behavioral literature (Hull, 1943).
困难的一个关键来源是动作与其对奖励的积极或消极影响之间的长时间延迟;
这个问题在强化学习文献中被称为信度分配问题credit assignment problem (Minsky, 1961;Sutton & Barto, 1998),以及行为文献中的远端奖励问题distal reward problem (Hull, 1943)。
Value functions offer an elegant solution to the credit assignment problem—they allow us to estimate the goodness of an action before the delayed reward arrives.
价值函数为信度分配问题提供了一个优雅的解决方案——它们允许我们在延迟奖励到来之前估计一个动作的好坏。
Reinforcement learning algorithms make use of value functions in a variety of different ways; this paper considers algorithms that optimize a parameterized policy and use value functions to help estimate how the policy should be improved.
强化学习算法以各种不同的方式利用价值函数;
本文考虑优化参数化策略 并使用价值函数来帮助估计策略应该如何改进 的算法。

【拟处理的问题:偏差-方差的 trade-off权衡 问题】

When using a parameterized stochastic policy, it is possible to obtain an unbiased estimate of the gradient of the expected total returns (Williams, 1992; Sutton et al., 1999; Baxter & Bartlett, 2000); these noisy gradient estimates can be used in a stochastic gradient ascent algorithm.
当使用参数化随机策略时,有可能获得 总回报的期望 的梯度 的无偏估计;
这些带噪声的梯度估计可用于随机梯度上升算法。
Unfortunately, the variance of the gradient estimator scales unfavorably with the time horizon, since the effect of an action is confounded with the effects of past and future actions.
不幸的是,梯度估计器的方差随着时间范围的变化而变化,因为一个动作的影响 与 过去和未来动作的影响 混杂。
Another class of policy gradient algorithms, called actor-critic methods, use a value function rather than the empirical returns, obtaining an estimator with lower variance at the cost of introducing bias (Konda & Tsitsiklis, 2003; Hafner & Riedmiller, 2011).
另一类策略梯度算法,称为 行动者-评论员actor-critic 方法,使用价值函数而不是经验回报,以引入偏差为代价获得方差较低的估计值 (Konda & Tsitsiklis, 2003;Hafner & Riedmiller, 2011)。
But while high variance necessitates using more samples, bias is more pernicious—even with an unlimited number of samples, bias can cause the algorithm to fail to converge, or to converge to a poor solution that is not even a local optimum.
虽然高方差需要使用更多的样本,但偏差更有害——即使有无限数量的样本,偏差也会导致算法无法收敛,或者收敛到一个甚至不是局部最优的糟糕解。

行动者-评论员actor-critic 方法:使用 价值函数 获得 低方差, 这样需要的样本少些。代价是:
偏差 ——> 算法无法收敛,或者收敛到一个甚至不是局部最优的糟糕解。

【我们提出了…(作用是),关键的 idea】

We propose a family of policy gradient estimators that significantly reduce variance while maintaining a tolerable level of bias.
我们提出了一组策略梯度估计器,它们在保持可接受的偏差水平的同时显著减少方差。
We call this estimation scheme, parameterized by γ ∈ [ 0 , 1 ] \gamma \in [0, 1] γ[0,1] and λ ∈ [ 0 , 1 ] \lambda \in [0, 1] λ[0,1], the generalized advantage estimator (GAE).
我们将这种由 γ ∈ [ 0 , 1 ] \gamma \in [0, 1] γ[0,1] λ ∈ [ 0 , 1 ] \lambda \in [0, 1] λ[0,1] 参数化的估计方案称为 广义优势估计器 (generalized advantage estimator, GAE)
Related methods have been proposed in the context of online actor-critic methods (Kimura & Kobayashi, 1998; Wawrzyński, 2009).
在在线 actor-critic 方法的背景下,已经提出了相关的方法。
We provide a more general analysis, which is applicable in both the online and batch settings, and discuss an interpretation of our method as an instance of reward shaping (Ng et al., 1999), where the approximate value function is used to shape the reward.
我们提供了一个更一般的分析,这适用于在线和批处理设置,并讨论了我们的方法作为奖励设计reward shaping 的一个实例的解释 (Ng et al., 1999),其中近似的价值函数用于设计奖励。

【在哪些任务上进行了方法评估】

We present experimental results on a number of highly challenging 3D locomotion tasks, where we show that our approach can learn complex gaits using high-dimensional, general purpose neural network function approximators for both the policy and the value function, each with over 104 parameters.
我们在许多极具挑战性的 3D 运动任务上展示了实验结果,实验结果表明我们的方法可以使用高维、通用的神经网络函数近似器来学习复杂的步态,这些神经网络函数近似器用于策略和价值函数,每个函数的参数个数都超过 104 。
The policies perform torque-level control of simulated 3D robots with up to 33 state dimensions and 10 actuators.
该策略对具有多达 33 个状态维度和 10 个执行器的模拟 3D 机器人进行扭矩级控制。

【3 点贡献】

The contributions of this paper are summarized as follows:
本文的贡献总结如下:

  1. We provide justification and intuition for an effective variance reduction scheme for policy gradients, which we call generalized advantage estimation (GAE). 【贡献 1:减小方差的方案 GAE】
    我们为策略梯度的有效的方差减少方案提供了解释和直觉,这个方案我们称之为广义优势估计(generalized advantage estimation,GAE)。
    While the formula has been proposed in prior work (Kimura & Kobayashi, 1998; Wawrzyński, 2009), our analysis is novel and enables GAE to be applied with a more general set of algorithms, including the batch trust-region algorithm we use for our experiments.
    该公式已在先前的工作中被提出 (Kimura & Kobayashi, 1998;Wawrzyński, 2009),我们的分析是新颖的,使 GAE 能够应用于一组更通用的算法,包括我们在实验中使用的批处理信任区域算法
  2. We propose the use of a trust region optimization method for the value function, which we find is a robust and efficient way to train neural network value functions with thousands of parameters. 【贡献 2:价值函数 + 信任域优化】
    我们提出了对价值函数使用信任域优化方法,我们发现这是一种稳健且有效的方法来训练具有数千个参数的神经网络价值函数。
  3. By combining (1) and (2) above, we obtain an algorithm that empirically is effective at learning neural network policies for challenging control tasks. 【贡献 3:高维连续控制 算法】
    通过结合上述 (1) 和 (2),我们获得了一种用于学习具有挑战性的控制任务的神经网络策略的经验上有效的算法。
    The results extend the state of the art in using reinforcement learning for high-dimensional continuous control.
    结果扩展了在高维连续控制中使用强化学习的最先进水平。
    Videos are available at https://sites.google.com/site/gaepapersupp.
    视频链接

2 预备知识

我们考虑策略优化问题的一种无折扣表述。
初始状态 s 0 s_0 s0 是从 分布 ρ 0 \rho_0 ρ0 中采样的。
根据策略 a t ∼ π ( a t ∣ s t ) a_t \sim\pi (a_t | s_t) atπ(atst) 采样 动作,根据动态 s t + 1 ∼ P ( s t + 1 ∣ s t , a t ) s_{t+1}\sim P(s_{t+1}| s_t, a_t) st+1P(st+1st,at) 采样 状态,直至达到终止(吸收)状态terminal (absorbing) state,得到轨迹trajectory ( s 0 , a 0 , s 1 , a 1 , ⋯   ) (s_0, a_0, s_1, a_1,\cdots) (s0,a0,s1,a1,)
奖励reward r t = r ( s t , a t , s t + 1 ) r_t = r(s_t, a_t, s_{t+1}) rt=r(st,at,st+1) 是在每个时间步收到的。
目标是最大化 总奖励 ∑ t = 0 ∞ r t \sum\limits_{t=0}^\infty r_t t=0rt 的期望,假设对所有策略都是有限的。
请注意,我们没有将折扣作为问题说明的一部分;
它将在下面显示为调整偏差-方差权衡的算法参数。
但折扣问题(最大化 ∑ t = 0 ∞ γ t r t \sum\limits_{t=0}^\infty \gamma^t r_t t=0γtrt)可以作为无折扣问题的一个实例来处理,其中我们将折扣因子吸收到奖励函数中,使其与时间相关。

策略梯度方法通过反复估计梯度 g : = ∇ θ E [ ∑ t = 0 ∞ r t ] g:=\nabla_\theta{\mathbb E}\Big[\sum\limits_{t=0}^\infty r_t\Big] g:=θE[t=0rt]最大化总奖励的期望
策略梯度有几个不同的相关表达式,其形式为:
  ~  
g = E [ ∑ t = 0 ∞ Ψ t ∇ θ log ⁡ π θ ( a t ∣ s t ) ]            ( 1 ) g={\mathbb E}\Big[\sum\limits_{t=0}^\infty\Psi_t\nabla_\theta\log\pi_\theta(a_t|s_t)\Big]~~~~~~~~~~(1) g=E[t=0Ψtθlogπθ(atst)]          (1)
  ~  
其中 Ψ t \Psi_t Ψt 可以是以下的其中一个:

1.     ∑ t = 0 ∞ r t     ~~~\sum\limits_{t=0}^\infty r_t~~~    t=0rt    轨迹的总奖励
  ~  
2.     ∑ t ′ = t ∞ r t ′     ~~~\sum\limits_{\textcolor{blue}{t^\prime=t}}^\infty r_{t^\prime}~~~    t=trt    动作 a t a_t at 之后的奖励
  ~  
3.     ∑ t ′ = t ∞ r t ′ − b ( s t )     ~~~\sum\limits_{t^\prime=t}^\infty r_{t^\prime}\textcolor{blue}{-b(s_t)}~~~    t=trtb(st)    之前形式的 基线版本         ~~~~~~~        这个基线只根据 状态 s t s_t st 计算一次,后续时间步不再计算
  ~  
4.     Q π ( s t , a t )     ~~~Q^\pi(s_t, a_t)~~~    Qπ(st,at)    状态-动作 价值函数state-action value function
  ~  
       Q π ( s t , a t ) : = E s t + 1 : ∞ ,   a t + 1 : ∞ [ ∑ l = 0 ∞ r t + l ] ~~~~~~Q^\pi(s_t,a_t):={\mathbb E}_{s_{t+1:\infty},~a_{t+1:\infty}}\Big[\sum\limits_{l=0}^\infty r_{t+l}\Big]       Qπ(st,at):=Est+1:, at+1:[l=0rt+l]
  ~  
5.     A π ( s t , a t )     ~~~A^\pi(s_t, a_t)~~~    Aπ(st,at)    优势函数advantage function
  ~  
       A π ( s t , a t ) : = Q π ( s t , a t ) − V π ( s t ) = Q π ( s t , a t ) − E s t + 1 : ∞ ,   a t : ∞ [ ∑ l = 0 ∞ r t + l ] ~~~~~~A^\pi(s_t, a_t):=Q^\pi(s_t,a_t)\textcolor{blue}{-V^\pi(s_t)}=Q^\pi(s_t,a_t)-{\mathbb E}_{s_{t+1:\infty},~a_{\textcolor{blue}{t}:\infty}}\Big[\sum\limits_{l=0}^\infty r_{t+l}\Big]       Aπ(st,at):=Qπ(st,at)Vπ(st)=Qπ(st,at)Est+1:, at:[l=0rt+l]
  ~  
6.     r t + V π ( s t + 1 ) − V π ( s t )     ~~~r_t+V^\pi(s_{t+1})-V^\pi(s_t)~~~    rt+Vπ(st+1)Vπ(st)    TD残差 TD residual ( temporal-difference 时序差分)

这里, E \mathbb E E 的下标列举了被积分的变量,其中状态和动作分别从动态模型 P ( s t + 1 ∣ s t , a t ) P(s_{t+1} | s_t, a_t) P(st+1st,at) 和策略 π ( a t ∣ s t ) \pi(a_t|s_t) π(atst) 中依次采样。
冒号 a : b a: b a:b 表示包含范围 ( a , a + 1 , ⋯   , b ) (a, a + 1,\cdots,b) (a,a+1,,b)
这些公式是众所周知的,而且很容易得到;
它们直接来自命题 1,稍后会说明。

选择 Ψ t = A π ( s t , a t ) \Psi_t = A^\pi(s_t, a_t) Ψt=Aπ(st,at) 产生的方差几乎是最小的,尽管在实践中,优势函数是未知的,必须进行估计。
这种说法可以通过以下对策略梯度的解释直观地证明:在策略梯度方向上的一步应该会增加 优于平均水平的动作actions 的概率,并降低 低于平均水平的动作actions 的概率。
根据优势函数 的定义 A π ( s , a ) = Q π ( s , a ) − V π ( s ) A^\pi (s, a) = Q^\pi (s, a) - V^\pi(s) Aπ(s,a)=Qπ(s,a)Vπ(s)衡量该动作是比策略的默认行为更好还是更差。
因此,我们令 Ψ t Ψ_t Ψt 为优势函数 A π ( s t , a t ) A ^\pi (s_t, a_t) Aπ(st,at),使得当且仅当 A π ( s t , a t ) > 0 A^\pi (s_t, a_t) > 0 Aπ(st,at)>0 时,梯度项 Ψ t ∇ θ log ⁡ π θ ( a t ∣ s t ) Ψ_t\nabla_\theta \log π_\theta(a_t | s_t) Ψtθlogπθ(atst) 指向 π ( a t ∣ s t ) π (a_t | s_t) π(atst) 增大的方向。
参见 Greensmith 等人(2004) 对策略梯度估计器的方差 和 使用基线的影响进行的更严谨的分析。

我们将引入一个参数 γ \gamma γ,它让我们通过降低 与延迟效应相对应的奖励 的权重来减小方差,代价是引入偏差。
该参数对应于 MDPs 折扣公式中使用的折扣因子,但我们将其视为无折扣问题中的方差减小参数;
Marbach & Tsitsiklis (2003); Kakade (2001b); Thomas (2014) 对该技术进行了理论分析;
折扣价值函数由下式给出:

V π , γ ( s t ) : = E s t + 1 : ∞ ,   a t : ∞ [ ∑ l = 0 ∞ γ l r t + l ] V^{\pi,\gamma}(s_t):={\mathbb E}_{s_{t+1:\infty},~a_{t:\infty}}\Big[\sum\limits_{l=0}^\infty \textcolor{blue}{\gamma^l} r_{t+l}\Big] Vπ,γ(st):=Est+1:, at:[l=0γlrt+l]
  ~  
Q π , γ ( s t , a t ) : = E s t + 1 : ∞ ,   a t + 1 : ∞ [ ∑ l = 0 ∞ γ l r t + l ]            ( 4 ) Q^{\pi,\gamma}(s_t,a_t):={\mathbb E}_{s_{t+1:\infty},~a_{t+1:\infty}}\Big[\sum\limits_{l=0}^\infty \textcolor{blue}{\gamma^l} r_{t+l}\Big]~~~~~~~~~~(4) Qπ,γ(st,at):=Est+1:, at+1:[l=0γlrt+l]          (4)
  ~  
A π , γ ( s t , a t ) : = Q π , γ ( s t , a t ) − V π , γ ( s t )            ( 5 ) A^{\pi,\gamma}(s_t,a_t):=Q^{\pi,\gamma}(s_t,a_t)-V^{\pi,\gamma}(s_t)~~~~~~~~~~(5) Aπ,γ(st,at):=Qπ,γ(st,at)Vπ,γ(st)          (5)
  ~  

策略梯度的折扣近似定义如下:
  ~  
g γ : = E s 0 : ∞ ,   a 0 : ∞ [ ∑ t = 0 ∞ A π , γ ( s t , a t ) ∇ θ log ⁡ π θ ( a t ∣ s t ) ]            ( 6 ) g^\gamma:={\mathbb E}_{s_{0:\infty},~a_{0:\infty}}\Big[\sum\limits_{t=0}^\infty A^{\pi,\gamma}(s_t,a_t)\nabla_\theta\log\pi_\theta(a_t|s_t)\Big]~~~~~~~~~~(6) gγ:=Es0:, a0:[t=0Aπ,γ(st,at)θlogπθ(atst)]          (6)
  ~  
下一节讨论如何获得 A π , γ A^{\pi,\gamma} Aπ,γ 的有偏(但不是太偏)估计量,给出式 (6) 中折扣策略梯度的有噪声估计。

在继续之前,我们将引入优势函数的 仅 γ \gamma γ 估计器 γ \gamma γ-just estimator 的概念,这是一个估计器,当我们用它代替式 (6) 中的 A π , γ A^{\pi,\gamma} Aπ,γ (未知且必须估计) 来估计 g γ g^\gamma gγ 时,它不会引入偏差。
考虑一个优势估计 A ^ t ( s 0 : ∞ , a 0 : ∞ ) Â_t(s_{0:\infty}, a_{0:\infty}) A^t(s0:,a0:),它通常可能是整个轨迹的函数。

  • 脚注:请注意,我们已经通过使用 A π , γ A^{\pi,\gamma} Aπ,γ 来代替 A π A^\pi Aπ 引入了偏差;
    这里我们关心的是获得 g γ g^\gamma gγ 的无偏估计, g γ g^\gamma gγ 是无折扣 MDP 的策略梯度的有偏估计。

命题 1: 假设 A ^ t \hat A_t A^t 可以写成 A ^ t ( s 0 : ∞ , a 0 : ∞ ) = Q t ( s t : ∞ , a t : ∞ ) − b t ( s t : ∞ , a t : ∞ ) Â_t(s_{0:\infty}, a_{0:\infty})= Q_t(s_{t:\infty}, a_{t:\infty})-b_t(s_{t:\infty}, a_{t:\infty}) A^t(s0:,a0:)=Qt(st:,at:)bt(st:,at:) 使得对于所有 ( s t , a t ) (s_t, a_t) (st,at), 有 E s t + 1 : ∞ , a t + 1 : ∞ ∣ s t , a t [ Q t ( s t : ∞ , a t : ∞ ) ] = Q π , γ ( s t , a t ) {\mathbb E}_{s_{t+1:\infty},a_{t+1:\infty}|s_t,a_t}[Q_t(s_{t:\infty}, a_{t:\infty})] = Q^{\pi,\gamma}(s_t, a_t) Est+1:,at+1:st,at[Qt(st:,at:)]=Qπ,γ(st,at)。那么 A ^ Â A^ γ \gamma γ-just (仅 γ \gamma γ 的)。

证明如附录 B 所示。
很容易验证以下表达式是 A ^ t Â_t A^t γ \gamma γ-just 优势估计量:

  • ∑ l = 0 ∞ γ l t t + l \sum\limits_{l=0}^\infty\gamma^lt_{t+l} l=0γltt+l
  • A π , γ ( s t , a t ) A^{\pi,\gamma}(s_t,a_t) Aπ,γ(st,at)
  • Q π , γ ( s t , a t ) Q^{\pi,\gamma}(s_t,a_t) Qπ,γ(st,at)
  • r t + γ V π , γ ( s t + 1 ) − V π , γ ( s t ) r_t+\gamma V^{\pi,\gamma}(s_{t+1})-V^{\pi,\gamma}(s_t) rt+γVπ,γ(st+1)Vπ,γ(st)

3 优势函数估计

本节将关注产生 折扣优势函数 A π , γ ( s t , a t ) A^{\pi,\gamma}(s_t, a_t) Aπ,γ(st,at) 的准确估计 A ^ t \hat A_t A^t,然后 用于构造以下形式的策略梯度估计器:
  ~  
g ^ = 1 N ∑ n = 1 N ∑ t = 0 ∞ A ^ t n ∇ θ log ⁡ π θ ( a t n ∣ s t n )            ( 9 ) \hat g=\frac{1}{N}\sum\limits_{n=1}^N\sum\limits_{t=0}^\infty\hat A_t^n\nabla _\theta\log \pi_\theta(a_t^n|s_t^n)~~~~~~~~~~(9) g^=N1n=1Nt=0A^tnθlogπθ(atnstn)          (9)
  ~  
其中 n n n 表示 回合batch 的索引。

V V V 是一个近似的价值函数。
定义 Δ t V = r t + γ V ( s t + 1 ) − V ( s t ) \Delta _t^V=r_t +\gamma V(s_{t+1})-V(s_t) ΔtV=rt+γV(st+1)V(st),即 折扣 γ \gamma γ V V V 的 TD误差(Sutton & Barto, 1998)。
注意 Δ t V \Delta _t^V ΔtV 可以被认为是对动作 a t a_t at 的优势的估计。
事实上,如果我们有正确的价值函数 V = V π , γ V =V^{\pi,\gamma} V=Vπ,γ,那么它是一个 γ \gamma γ-just 优势估计器 γ \gamma γ-just advantage estimator,且实际上是 A π , γ A^{\pi,\gamma} Aπ,γ 的无偏估计量:
  ~  
E s t + 1 [ Δ t V π , γ ] = E s t + 1 [ r t + γ V π , γ ( s t + 1 ) − V π , γ ( s t ) ] = E s t + 1 [ Q π , γ ( s t , a t ) − V π , γ ( s t ) ] = A π , γ ( s t , a t )            ( 10 ) \begin{aligned}{\mathbb E}_{s_{t+1}}[\Delta_t^{V^{\pi,\gamma}}]&={\mathbb E}_{s_{t+1}}[\textcolor{blue}{r_t+\gamma V^{\pi,\gamma}(s_{t+1})}-V^{\pi, \gamma}(s_t)]\\ &={\mathbb E}_{s_{t+1}}[\textcolor{blue}{Q^{\pi,\gamma}(s_t,a_t)}-V^{\pi, \gamma}(s_t)]\\ &=A^{\pi,\gamma}(s_t,a_t)~~~~~~~~~~(10)\end{aligned} Est+1[ΔtVπ,γ]=Est+1[rt+γVπ,γ(st+1)Vπ,γ(st)]=Est+1[Qπ,γ(st,at)Vπ,γ(st)]=Aπ,γ(st,at)          (10)
  ~  
然而,该估计量仅对于 V = V π , γ V = V^{\pi, \gamma} V=Vπ,γ γ \gamma γ-just,否则将产生有偏的策略梯度估计。

接下来,让我们考虑取前 k k k Δ \Delta Δ 项的和,我们用 A ^ t ( k ) \hat A_t^{(k)} A^t(k) 表示。

A ^ t ( 1 ) : = Δ t V = − V ( s t ) + r t + γ V ( s t + 1 ) \hat A_t^{(1)}:=\Delta_t^V=-V(s_t)+r_t +\gamma V(s_{t+1}) A^t(1):=ΔtV=V(st)+rt+γV(st+1)
  ~  
A ^ t ( 2 ) : = Δ t V + γ Δ t + 1 V = − V ( s t ) + r t + γ V ( s t + 1 ) + γ [ − V ( s t + 1 ) + r t + 1 + γ V ( s t + 2 ) ] = − V ( s t ) + r t + γ r t + 1 + γ 2 V ( s t + 2 ) \begin{aligned}\hat A_t^{(2)}&:=\Delta_t^V+\gamma\Delta_{t+1}^V\\ &=-V(s_t)+r_t +\gamma V(s_{t+1}) + \gamma [-V(s_{t+1})+r_{t+1} +\gamma V(s_{t+2})]\\ &=-V(s_t)+r_t+\gamma r_{t+1}+\gamma^2V(s_{t+2})\end{aligned} A^t(2):=ΔtV+γΔt+1V=V(st)+rt+γV(st+1)+γ[V(st+1)+rt+1+γV(st+2)]=V(st)+rt+γrt+1+γ2V(st+2)
  ~  
A ^ t ( 3 ) : = Δ t V + γ Δ t + 1 V + γ 2 Δ t + 2 V = − V ( s t ) + r t + γ r t + 1 + γ 2 V ( s t + 2 ) + γ 2 [ − V ( s t + 2 ) + r t + 2 + γ V ( s t + 3 ) ] = − V ( s t ) + r t + γ r t + 1 + γ 2 r t + 2 + γ 3 V ( s t + 3 ) \begin{aligned}\hat A_t^{(3)}&:=\Delta_t^V+\gamma\Delta_{t+1}^V+\gamma^2\Delta_{t+2}^V\\ &=-V(s_t)+r_t+\gamma r_{t+1}+\gamma^2V(s_{t+2})+\gamma^2[-V(s_{t+2})+r_{t+2} +\gamma V(s_{t+3})]\\ &=-V(s_t)+r_t+\gamma r_{t+1}+\gamma^2 r_{t+2}+\gamma^3V(s_{t+3})\end{aligned} A^t(3):=ΔtV+γΔt+1V+γ2Δt+2V=V(st)+rt+γrt+1+γ2V(st+2)+γ2[V(st+2)+rt+2+γV(st+3)]=V(st)+rt+γrt+1+γ2rt+2+γ3V(st+3)
           ⋮ ~~~~~~~~~~\vdots           
A ^ t ( k ) : = ∑ l = 0 k − 1 γ l Δ t + 1 V = − V ( s t ) + r t + γ r t + 1 + ⋯ + γ k − 1 r t + k − 1 + γ k V ( s t + k )            ( 14 ) \hat A_t^{(k)}:=\sum\limits_{l=0}^{k-1}\gamma^l\Delta_{t+1}^V=\textcolor{blue}{-V(s_t)}+r_t+\gamma r_{t+1}+\cdots+\gamma^{\textcolor{blue}{k-1}}r_{t+\textcolor{blue}{k-1}}+\textcolor{blue}{\gamma^kV(s_{t+k})}~~~~~~~~~~(14) A^t(k):=l=0k1γlΔt+1V=V(st)+rt+γrt+1++γk1rt+k1+γkV(st+k)          (14)

这些方程是由一个可伸缩和 得出的,我们看到 A ^ t ( k ) \hat A_t^{(k)} A^t(k) 涉及对回报的 k k k 步估计,减去一个基线项 − V ( s t ) -V(s_t) V(st)
Δ t V = A ^ t ( 1 ) \Delta_t^V=\hat A_t^{(1)} ΔtV=A^t(1) 的情况类似,我们可以认为 A ^ t ( k ) \hat A_t^{(k)} A^t(k) 是优势函数的一个估计量,仅当 V = V π , γ V = V^{\pi, \gamma} V=Vπ,γ 时它才 是 γ \gamma γ-just。
然而,请注意,当 k → ∞ k→\infty k 时,偏置通常会变小,因为 γ k V ( s t + k ) \gamma^kV(s_{t+k}) γkV(st+k) 项的大打折扣,而 − V ( s t ) -V(s_t) V(st) 项不会影响偏置。
k → ∞ k→\infty k,我们得到
  ~  
A ^ t ( ∞ ) : = ∑ l = 0 ∞ γ l Δ t + 1 V = − V ( s t ) + ∑ l = 0 ∞ γ l Δ t + l            ( 15 ) \hat A_t^{(\infty)}:=\sum\limits_{l=0}^\infty\gamma^l\Delta_{t+1}^V=-V(s_t)+\sum\limits_{l=0}^\infty\gamma^l\Delta_{t+l}~~~~~~~~~~(15) A^t():=l=0γlΔt+1V=V(st)+l=0γlΔt+l          (15)
  ~  
也就是 经验回报 减去 价值函数基线

广义优势估计器 GAE ( γ , λ ) \text{GAE}(\gamma, \lambda) GAE(γ,λ) 定义为这些 k k k 步估计器的指数加权平均:
  ~  
A ^ t GAE ( γ , λ ) : = ( 1 − λ ) ( A ^ t ( 1 ) + λ A ^ t ( 2 ) + λ 2 A ^ t ( 3 ) + ⋯ ) = ( 1 − λ ) ( Δ t V + λ ( Δ t V + γ Δ t + 1 V ) + λ 2 ( Δ t V + γ Δ t + 1 V + γ 2 Δ t + 2 V ) + ⋯   ) = ( 1 − λ ) ( Δ t V ( 1 + λ + λ 2 + ⋯   ) +                    γ Δ t + 1 V ( λ + λ 2 + λ 3 + ⋯   ) +                    γ 2 Δ t + 2 V ( λ 2 + λ 3 + λ 4 + ⋯   ) + ⋯   ) = ( 1 − λ ) ( Δ t V ( 1 1 − λ + γ Δ t + 1 V ( λ 1 − λ ) + γ 2 Δ t + 2 V ( λ 2 1 − λ ) + ⋯ ) = ∑ l = 0 ∞ ( γ λ ) l Δ t + l V            ( 16 ) \begin{aligned}\hat A_t^{\text{GAE}(\gamma, \lambda)}&:=(1-\lambda)\Big(\hat A_t^{(1)}+\lambda \hat A_t^{(2)}+\lambda^2 \hat A_t^{(3)}+\cdots\Big)\\ &=(1-\lambda)(\Delta_t^V+\lambda(\Delta_t^V+\gamma \Delta_{t+1}^V)+\lambda^2(\Delta_t^V+\gamma \Delta_{t+1}^V+\gamma^2 \Delta_{t+2}^V)+\cdots)\\ &=(1-\lambda)(\Delta_t^V(1+\lambda + \lambda^2+\cdots)+\\ &~~~~~~~~~~~~~~~~~~\gamma \Delta_{t+1}^V(\lambda+\lambda^2+\lambda^3+\cdots)+\\ &~~~~~~~~~~~~~~~~~~\gamma^2\Delta_{t+2}^V(\lambda^2+\lambda^3+\lambda^4+\cdots)+\cdots)\\ &=(1-\lambda)\Big(\Delta_t^V(\frac{1}{1-\lambda}+\gamma\Delta_{t+1}^V(\frac{\lambda}{1-\lambda})+\gamma^2\Delta_{t+2}^V(\frac{\lambda^2}{1-\lambda})+\cdots\Big)\\ &=\sum\limits_{l=0}^\infty(\gamma\lambda)^l\Delta_{t+l}^V~~~~~~~~~~(16)\end{aligned} A^tGAE(γ,λ):=(1λ)(A^t(1)+λA^t(2)+λ2A^t(3)+)=(1λ)(ΔtV+λ(ΔtV+γΔt+1V)+λ2(ΔtV+γΔt+1V+γ2Δt+2V)+)=(1λ)(ΔtV(1+λ+λ2+)+                  γΔt+1V(λ+λ2+λ3+)+                  γ2Δt+2V(λ2+λ3+λ4+)+)=(1λ)(ΔtV(1λ1+γΔt+1V(1λλ)+γ2Δt+2V(1λλ2)+)=l=0(γλ)lΔt+lV          (16)
  ~  
从式 (16) 中,我们看到优势估计器有一个非常简单的公式,涉及Bellman 残差项的折扣和。第 4 节讨论了对该公式的解释,即带有改动奖励函数的 MDP 中的回报。
我们上面使用的结构与用于定义 TD( λ \lambda λ) 的结构非常相似 (Sutton & Barto, 1998),但是 TD( λ \lambda λ) 是价值函数的估计器,而这里我们是在估计优势函数

这个公式有两个值得注意的特例,分别是令 λ = 0 \lambda= 0 λ=0 λ = 1 \lambda= 1 λ=1
  ~  
GAE ( γ , 0 ) :    A ^ t : = Δ t              = r t + γ V ( s t + 1 ) − V ( s t )            ( 17 ) \text{GAE}(\gamma, 0):~~\hat A_t:=\Delta_t~~~~~~~~~~~~=r_t+\gamma V(s_{t+1})-V(s_t)~~~~~~~~~~(17) GAE(γ,0):  A^t:=Δt            =rt+γV(st+1)V(st)          (17)
  ~  
GAE ( γ , 1 ) :    A ^ t : = ∑ l = 0 ∞ γ l Δ t + l = ∑ l = 0 ∞ γ l r t + l − V ( s t )            ( 18 )      \text{GAE}(\gamma, 1):~~\hat A_t:=\sum\limits_{l=0}^\infty\gamma^l\Delta_{t+l}=\sum\limits_{l=0}^\infty\gamma^lr_{t+l}-V(s_t)~~~~~~~~~~(18)~~~~ GAE(γ,1):  A^t:=l=0γlΔt+l=l=0γlrt+lV(st)          (18)    方差大,需要更多样本
  ~  
不考虑 V V V 的准确性, GAE ( γ , 1 ) \text{GAE}(\gamma, 1) GAE(γ,1) γ \gamma γ-just,但由于项的和,它有很高的方差。
GAE ( γ , 0 ) \text{GAE}(\gamma, 0) GAE(γ,0) 仅当 V = V π , γ V=V^{\pi, \gamma} V=Vπ,γ 时是 γ \gamma γ-just,否则会引起偏差,但它的方差通常要小得多。
0 < λ < 1 0<\lambda<1 0<λ<1 的广义优势估计器 是偏差和方差之间的折衷,由参数 λ λ λ 控制。

我们描述了一个具有两个独立参数 γ \gamma γ λ \lambda λ 的优势估计器,当使用近似价值函数时,这两个参数都有助于偏差-方差权衡。
然而,它们服务于不同的目的,并且在不同的值范围内效果最好。
γ \gamma γ 最重要的是决定了价值函数 V π , γ V^{\pi,\gamma} Vπ,γ 的范围,它不依赖于 λ \lambda λ
γ < 1 \gamma < 1 γ<1 时,无论价值函数的精度如何,都会在策略梯度估计中引入偏差。
另一方面, λ < 1 \lambda< 1 λ<1 仅在价值函数不准确时才会引入偏差。
根据经验,我们发现 λ \lambda λ 的最佳值远低于 γ \gamma γ 的最佳值,这可能是因为对于一个相当准确的价值函数, λ \lambda λ 引入的偏差远小于 γ \gamma γ

利用广义优势估计器,我们可以从式 (6) 中构造折扣策略梯度 g γ g^\gamma gγ 的有偏估计量:
  ~  
g γ ≈ E [ ∑ t = 0 ∞ ∇ θ log ⁡ π θ ( a t ∣ s t ) A ^ t GAE ( γ , λ ) ] = E [ ∑ t = 0 ∞ ∇ θ log ⁡ π θ ( a t ∣ s t ) ∑ l = 0 ∞ ( γ λ ) l Δ t + l V ]            ( 19 ) g^\gamma\approx{\mathbb E}\Big[\sum\limits_{t=0}^\infty\nabla_\theta\log \pi_\theta(a_t|s_t)\hat A_t^{\text{GAE}(\gamma,\lambda)}\Big]={\mathbb E}\Big[\sum\limits_{t=0}^\infty\nabla_\theta\log \pi_\theta(a_t|s_t)\sum\limits_{l=0}^\infty(\gamma\lambda)^l\Delta_{t+l}^V\Big]~~~~~~~~~~(19) gγE[t=0θlogπθ(atst)A^tGAE(γ,λ)]=E[t=0θlogπθ(atst)l=0(γλ)lΔt+lV]          (19)
  ~  
λ = 1 \lambda= 1 λ=1 时,等式成立。

4 解释为 奖励设计reward shaping

在本节中,我们将讨论如何将 λ \lambda λ 解释为在 MDP上执行奖励设计转换后应用的额外折扣因子
我们还引入了响应函数的概念,以帮助理解 γ \gamma γ λ \lambda λ 引入的偏差。

奖励设计 (Ng et al.,1999) 是指对 MDP 的奖励函数进行如下变换:设 Φ : S → R \Phi:{\cal S}→{\mathbb R} Φ:SR 为状态空间上的任意标量价值函数,将变换后的奖励函数 r ~ \widetilde r r 定义为:
  ~  
r ~ ( s , a , s ′ ) = r ( s , a , s ′ ) + γ Φ ( s ′ ) − Φ ( s )            ( 20 ) \widetilde r(s,a,s^\prime)=r(s,a,s^\prime)+\gamma\Phi(s^\prime)-\Phi(s)~~~~~~~~~~(20) r (s,a,s)=r(s,a,s)+γΦ(s)Φ(s)          (20)
  ~  
反过来定义转换后的 MDP。
该变换使折扣优势函数 A π , γ A^{\pi,\gamma} Aπ,γ 对任何策略 π π π 都不变。
为了理解这一点,考虑从状态 s t s_t st 开始的轨迹的奖励折扣和:
  ~  
∑ l = 0 ∞ γ l r ~ ( s t + l , a t , s t + l + 1 ) = ∑ l = 0 ∞ γ l r ( s t + l , a t + l , s t + l + 1 ) − Φ ( s t )            ( 21 ) \sum\limits_{l=0}^\infty\gamma^l\widetilde r(s_{t+l},a_t,s_{t+l+1})=\sum\limits_{l=0}^\infty\gamma^l\textcolor{blue}{r}(s_{t+l},a_{t+\textcolor{blue}{l}},s_{t+l+1})\textcolor{blue}{-\Phi(s_t)}~~~~~~~~~~(21) l=0γlr (st+l,at,st+l+1)=l=0γlr(st+l,at+l,st+l+1)Φ(st)          (21)
  ~  
Q ~ π , γ , V ~ π , γ , A ~ π , γ \widetilde Q^{\pi,\gamma}, \widetilde V^{\pi,\gamma}, \widetilde A^{\pi,\gamma} Q π,γ,V π,γ,A π,γ 为变换后的 MDP 的价值函数和优势函数,由这些量的定义可得:
  ~  
Q ~ π , γ ( s , a ) = Q π , γ ( s , a ) − Φ ( s )            ( 22 ) \widetilde Q^{\pi,\gamma}(s,a)=Q^{\pi,\gamma}(s,a)-\Phi(s)~~~~~~~~~~(22) Q π,γ(s,a)=Qπ,γ(s,a)Φ(s)          (22)
  ~  
V ~ π , γ ( s , a ) = V π , γ ( s ) − Φ ( s )            ( 23 ) \widetilde V^{\pi,\gamma}(s,a)=V^{\pi,\gamma}(s)-\Phi(s)~~~~~~~~~~(23) V π,γ(s,a)=Vπ,γ(s)Φ(s)          (23)
  ~  
A ~ π , γ ( s , a ) = ( Q π , γ ( s , a ) − Φ ( s ) ) − ( V π , γ ( s ) − Φ ( s ) ) = A π , γ ( s , a )            ( 24 ) \widetilde A^{\pi,\gamma}(s,a)=\Big(Q^{\pi,\gamma}(s,a)-\Phi(s)\Big)-\Big(V^{\pi,\gamma}(s)-\Phi(s)\Big)=A^{\pi,\gamma}(s,a)~~~~~~~~~~(24) A π,γ(s,a)=(Qπ,γ(s,a)Φ(s))(Vπ,γ(s)Φ(s))=Aπ,γ(s,a)          (24)
  ~  
注意,如果 Φ Φ Φ 恰好是 来自原始 MDP 的 状态-价值函数state-value function V π , γ V^{\pi,\gamma} Vπ,γ,那么变换后的 MDP 具有有趣的性质, V ~ π , γ ( s ) \widetilde V^{\pi,\gamma}(s) V π,γ(s) 在每个状态下都为零。

注意 (Ng et al.,1999) 表明,当我们的目标是最大化奖励的折扣总和 ∑ t = 0 ∞ γ t r ( s t , a t , s t + 1 ) \sum\limits_{t=0}^\infty \gamma^tr(s_t, a_t, s_{t+1}) t=0γtr(st,at,st+1) 时,奖励设计变换 使策略梯度和最优策略保持不变。
相比之下,本文关注的是最大化无折扣奖励和,其中折扣 γ \gamma γ 作为方差减小参数。

在回顾了奖励设计reward shaping 的idea 之后,让我们考虑如何使用它来获得策略梯度估计。
最自然的方法是构造使用 设计的奖励 r ~ \widetilde r r 折扣和的策略梯度估计器。
然而, 式 (21) 表明,我们得到了原始 MDP 奖励 r r r 减去基线项的折扣和。
接下来,让我们考虑使用“更陡峭”的折扣 γ λ \gamma λ γλ,其中 0 ≤ λ ≤ 1 0 \leq\lambda\leq1 0λ1
很容易看出,设计的奖励 r ~ \widetilde r r 等于 Bellman残差项 Δ V \Delta ^V ΔV,在第 3 节中,我们令 Φ = V \Phi=V Φ=V
Φ = V \Phi=V Φ=V,我们得到
  ~  
∑ l = 0 ∞ ( γ λ ) l r ~ ( s t + l , a t , s t + l + 1 ) = ∑ l = 0 ∞ ( γ λ ) l Δ t + l V = A ^ t GAE ( γ , λ )            ( 25 ) \sum\limits_{l=0}^\infty(\gamma\lambda)^l\widetilde r(s_{t+l},a_t,s_{t+l+1})=\sum\limits_{l=0}^\infty(\gamma\lambda)^l\Delta_{t+l}^V=\hat A_t^{\text{GAE}(\gamma,\lambda)}~~~~~~~~~~(25) l=0(γλ)lr (st+l,at,st+l+1)=l=0(γλ)lΔt+lV=A^tGAE(γ,λ)          (25)
  ~  
因此,通过考虑 设计的奖励的 γ λ \gamma\lambda γλ 折扣和,我们正得到了第 3 节的广义优势估计器。
如前所示, λ = 1 \lambda= 1 λ=1 给出 g γ g^\gamma gγ 的无偏估计,而 λ < 1 \lambda <1 λ<1 给出有偏估计。

为了进一步分析这种设计变换以及参数 γ \gamma γ λ \lambda λ 的影响,引入响应函数 χ \chi χ 的概念是有用的,我们将其定义为:
  ~  
χ ( l ; s t , a t ) = E [ r t + 1 ∣ s t , a t ] − E [ r t + 1 ∣ s t ]            ( 26 ) \chi(l;s_t,a_t)={\mathbb E}[r_{t+1}|s_t,a_t]-{\mathbb E}[r_{t+1}|s_t]~~~~~~~~~~(26) χ(l;st,at)=E[rt+1st,at]E[rt+1st]          (26)
  ~  
注意, A π , γ ( s , a ) = ∑ l = 0 ∞ γ l χ ( l ; s , a ) A^{\pi,\gamma}(s, a) = \sum\limits_{l=0}^\infty \gamma^l\chi(l;s, a) Aπ,γ(s,a)=l=0γlχ(l;s,a),因此响应函数跨时间步分解优势函数。
响应函数让我们量化了时序信度分配问题:动作和奖励之间的长期依赖关系对应于 l ≫ 0 l\gg0 l0 时的响应函数的非零值。

$\chi$     χ ~~~\chi    χ

接下来,让我们回顾一下折扣因子 γ \gamma γ 和我们使用 A π , γ A^{\pi,\gamma} Aπ,γ 而不是 A π , 1 A^{\pi,1} Aπ,1 所做的近似。
式 (6) 中的折扣策略梯度估计器具有如下形式的项和
  ~  
∇ θ log ⁡ π θ ( a t ∣ s t ) A π , γ ( s t , a t ) = ∇ θ log ⁡ π θ ( a t ∣ s t ) ∑ l = 0 ∞ γ l χ ( l ; s t , a t )            ( 27 ) \nabla_\theta\log \pi_\theta(a_t|s_t)\textcolor{blue}{A^{\pi,\gamma}(s_t,a_t)}=\nabla_\theta\log \pi_\theta(a_t|s_t)\textcolor{blue}{\sum\limits_{l=0}^\infty\gamma^l\chi(l;s_t,a_t)}~~~~~~~~~~(27) θlogπθ(atst)Aπ,γ(st,at)=θlogπθ(atst)l=0γlχ(l;st,at)          (27)
  ~  
使用折扣 γ < 1 \gamma < 1 γ<1 对应于 去掉 l ≫ 1 1 − γ l\gg\frac{1}{1-\gamma} l1γ1 的项。
因此,如果 χ \chi χ 随着 l l l 的增加而迅速衰减,即如果 ≈ 1 1 − γ ≈\frac{1}{1-\gamma} 1γ1 时间步之后,动作对奖励的影响被“遗忘”,则由这种近似引入的误差将很

如果使用 Ф = V π , γ Ф = V^{\pi, \gamma} Ф=Vπ,γ 获得奖励函数 r ~ \widetilde r r ,则当 l > 0 l > 0 l>0 时,我们将得到 E [ r ~ t + l ∣ s t , a t ] = E [ r ~ t + l ∣ s t ] = 0 {\mathbb E}[\widetilde r_{t+l}| s_t, a_t] = {\mathbb E}[\widetilde r_{t+l}| s_t] = 0 E[r t+lst,at]=E[r t+lst]=0,即响应函数仅在 l = 0 l = 0 l=0 时是非零的。
因此,这种设计转换将把暂时延长的响应转变为即时响应。
假设 V π , γ V^{\pi,\gamma} Vπ,γ 完全减小了响应函数的时序扩散,我们可以期望一个好的近似 V ≈ V π , γ V\approx V^{\pi,\gamma} VVπ,γ 部分减小它。
这一观察结果表明了对式 (16) 的解释: 使用 V V V 重新设计奖励 以缩小响应函数的时序范围,然后引入“更陡峭”的折扣 γ λ \gammaλ γλ 来切断长延迟引起的噪声,即当 l ≫ 1 1 − γ λ l\gg\frac{1}{1-\gamma \lambda} l1γλ1 忽略项 ∇ θ log ⁡ π θ ( a t ∣ s t ) Δ t + l V \nabla_\theta \log π_\theta(a_t | s_t)\Delta_{t+l}^V θlogπθ(atst)Δt+lV

5 价值函数估计

【估计价值函数的蒙特卡洛Monte Carlo 或 TD(1) 方法】

可以使用各种不同的方法来估计价值函数 (例如,参见Bertsekas(2012))。
当使用非线性函数近似器表示价值函数时,最简单的方法是求解非线性回归问题:
  ~  
minimize ϕ ∑ n = 1 N ∥ V ϕ ( s n ) − V ^ n ∥ 2            ( 28 ) \underset{\phi}{\text{minimize}}\sum\limits_{n=1}^N \Vert V_\phi(s_n)-\hat V_n\Vert^2~~~~~~~~~~(28) ϕminimizen=1NVϕ(sn)V^n2          (28)
  ~  
其中 V ^ t = ∑ l = 0 ∞ γ l r t + l \hat V_t = \sum\limits_{l=0}^\infty \gamma^lr_{t+l} V^t=l=0γlrt+l 是奖励的折扣和,
在一批轨迹的所有时间步的索引为 n n n     ~~~    共 N 条轨迹
这有时被称为估计价值函数的蒙特卡洛Monte Carlo 或 TD(1) 方法(Sutton & Barto, 1998)

  • 脚注:另一个自然的选择是使用基于 TD( λ \lambda λ)备份backup 的估计器来计算目标价值(Bertsekas,2012;Sutton & Barto, 1998),反映了我们用于策略梯度估计的表达式: V ^ t λ = V ϕ old ( s n ) + ∑ l = 0 ∞ ( γ λ ) l Δ t + l \hat V_t^\lambda = V_{\phi_\text{old}} (s_n)+ \sum\limits_{l=0}^\infty(\gamma \lambda)^l\Delta_{t+l} V^tλ=Vϕold(sn)+l=0(γλ)lΔt+l
    当我们尝试这种选择时,我们没有看到与式 (28) 中的 λ = 1 λ= 1 λ=1 的估计器在性能上的差异。

对于本工作中的实验,我们使用信任域方法在批量优化过程的每次迭代中优化价值函数。
信任区域帮助我们避免了对最近一批数据的过拟合
为了构造信任域问题,我们首先计算 σ 2 = 1 N ∥ V ϕ ( s n ) − V ^ n ∥ 2 \sigma^2=\frac{1}{N}\Vert V_\phi (s_n)-\hat V_n\Vert^2 σ2=N1Vϕ(sn)V^n2,其中 ϕ old \phi_{\text{old}} ϕold 为优化前的参数向量。
然后求解如下约束优化问题:
  ~  
minimize ϕ ∑ n = 1 N ∥ V ϕ ( s n ) − V ^ n ∥ 2      \underset{\phi}{\text{minimize}}\sum\limits_{n=1}^N \Vert V_\phi(s_n)-\hat V_n\Vert^2~~~~ ϕminimizen=1NVϕ(sn)V^n2    式 (28)
  ~  
subject to    1 N ∑ n = 1 N ∥ V ϕ ( s n ) − V ^ n ∥ 2 2 σ 2 ≤ ϵ            ( 29 ) \text{subject to}~~~\frac{1}{N}\sum\limits_{n=1}^N\frac{ \Vert V_\phi(s_n)-\hat V_n\Vert^2}{2\sigma^2}\leq \epsilon~~~~~~~~~~(29) subject to   N1n=1N2σ2Vϕ(sn)V^n2ϵ          (29)
  ~  
这个约束相当于约束前一个价值函数新的价值函数之间的平均 KL 散度小于 ϵ \epsilon ϵ,其中价值函数被用来参数化一个均值为 V ϕ ( s ) V_\phi(s) Vϕ(s),方差为 σ 2 \sigma^2 σ2 的条件高斯分布。

我们使用共轭梯度算法计算信任域问题的近似解 (Wright & Nocedal, 1999)。
具体来说,我们是在解二次方程
  ~  
minimize ϕ     g T ( ϕ − ϕ old )            ( 29 ) \underset{\phi}{\text{minimize}}~~~g^T(\phi-\phi_\text{old})~~~~~~~~~~(29) ϕminimize   gT(ϕϕold)          (29)
  ~  
object to    1 N ∑ n = 1 N ( ϕ − ϕ old ) T H ( ϕ − ϕ old ) ≤ ϵ            ( 30 ) \text{object to}~~~\frac{1}{N}\sum\limits_{n=1}^N({\phi-\phi_\text{old}})^TH({\phi-\phi_\text{old}})\leq \epsilon~~~~~~~~~~(30) object to   N1n=1N(ϕϕold)TH(ϕϕold)ϵ          (30)
  ~  
其中 g g g 为目标函数的梯度,且 H = 1 N ∑ n j n j n T H = \frac{1}{N}\sum\limits_{n}j_nj_n^T H=N1njnjnT,其中 j n = ∇ ϕ V ( s n ) j_n = \nabla_\phi V(s_n) jn=ϕV(sn)
注意, H H H 是目标的 Hessian 的“高斯-牛顿”近似,当将价值函数解释为条件概率分布时,它是 Fisher 信息矩阵(最高为 σ 2 \sigma^2 σ2 因子)。
利用矩阵向量积 v → H v v→Hv vHv 实现共轭梯度算法,计算出 step 方向 s ≈ H − 1 g s\approx H^{-1}g sH1g
然后我们重新调整 s → α s s→\alpha s sαs,使 1 2 ( α s ) T H ( α s ) = ϵ \frac{1}{2}(\alpha s)^TH(\alpha s) = \epsilon 21(αs)TH(αs)=ϵ,并令 ϕ = ϕ old + α s \phi = \phi_\text{old} + \alpha s ϕ=ϕold+αs
此过程类似于我们用于更新策略的过程,该过程将在第 6 节中进一步描述,并基于 Schulman 等人(2015) 的工作。

6 实验

我们设计了一组实验来调查以下问题:

  1. 在使用广义优势估计 优化 回合式总奖励时,改变 λ ∈ [ 0 , 1 ] \lambda \in[0,1] λ[0,1] γ ∈ [ 0 , 1 ] \gamma \in[0,1] γ[0,1] 的经验效应是什么?
  2. 广义优势估计,以及 策略 和 价值函数优化的信任域算法,是否可以用于优化大型神经网络策略 以解决具有挑战性的控制问题?

6.1 策略优化算法

虽然广义优势估计可以与各种不同的策略梯度方法一起使用,但对于这些实验,我们使用信任域策略优化( trust region policy optimization, TRPO) 进行策略更新(Schulman et al., 2015)。
每次迭代,TRPO 通过近似求解以下约束优化问题来更新策略:
  ~  
minimize θ   L θ old ( θ ) \underset{\theta}{\text{minimize}} ~L_{\theta_\text{old}}(\theta) θminimize Lθold(θ)
  ~  
subject to  D ‾ KL θ old ( π θ old , π θ ) ≤ ϵ \text{subject to}~\overline D_\text{KL}^{\theta_\text{old}}(\pi_{\theta_\text{old}},\pi_\theta)\leq\epsilon subject to DKLθold(πθold,πθ)ϵ
  ~  
其中 L θ old ( θ ) = 1 N ∑ n = 1 N π θ ( a n ∣ s n ) π θ old ( a n ∣ s n ) A ^ n L_{\theta_\text{old}}(\theta)=\frac{1}{N}\sum\limits_{n=1}^N\frac{\pi_\theta(a_n|s_n)}{\pi_{\theta_\text{old}}(a_n|s_n)}\hat A_n Lθold(θ)=N1n=1Nπθold(ansn)πθ(ansn)A^n
  ~  
        D ‾ KL θ old ( π θ old , π θ ) = 1 N ∑ n = 1 N D KL ( π θ old ( ⋅ ∣ s n ) ∥ π θ ( ⋅ ∣ s n ) )               ( 31 ) ~~~~~~~\overline D_\text{KL}^{\theta_\text{old}}(\pi_{\theta_\text{old}},\pi_\theta)=\frac{1}{N}\sum\limits_{n=1}^ND_\text{KL}\Big(\textcolor{blue}{\pi_{\theta_\text{old}}}(·|s_n)\Big\Vert \textcolor{blue}{\pi_\theta}(·|s_n)\Big)~~~~~~~~~~~~~(31)        DKLθold(πθold,πθ)=N1n=1NDKL(πθold(sn) πθ(sn))             (31)
  ~  
如(Schulman et al., 2015)所述,我们通过对目标函数进行线性化并对约束进行二次化来近似地解决这个问题,从而得到在 θ − θ old ∝ − F − 1 g θ- \theta_\text{old}\propto-F^{-1}g θθoldF1g 方向上的一个 step,其中 F F F 是平均 Fisher 信息矩阵, g g g 是策略梯度估计。
这种策略更新 产生与自然策略梯度 (Kakade, 2001a) 和 自然 actor-critic (Peters & Schaal, 2008)相同的步长方向,但它使用不同的步长确定方案和计算步长的数值过程。

为完整起见,迭代更新 策略 和 价值函数的整个算法如下:

在这里插入图片描述

初始化策略的参数 θ 0 \theta_0 θ0 和 价值函数的参数 ϕ 0 \phi_0 ϕ0
f o r   i = 0 , 1 , 2 , ⋯   ,   d o {\bf for~} i=0,1,2,\cdots,~{\bf do} for i=0,1,2,, do
        ~~~~~~~        模拟当前策略 π θ i \pi_{\theta_i} πθi 直到获得 N N N 个时间步
        ~~~~~~~        使用 V = V ϕ i V=V_{\phi_i} V=Vϕi, 在所有时间步 t ∈ { 1 , 2 , ⋯   , N } t\in \{1,2,\cdots,N\} t{1,2,,N} 计算 Δ t V                    Δ t V = − V ( s t ) + r t + γ V ( s t + 1 ) \Delta_t^V~~~~~~~~~~~~~~~~~~\textcolor{blue}{\Delta_t^V=-V(s_t)+r_t +\gamma V(s_{t+1})} ΔtV                  ΔtV=V(st)+rt+γV(st+1)
        ~~~~~~~        在所有时间步计算 A ^ t = ∑ l = 0 ∞ ( γ λ ) l Δ t + l V \hat A_t=\sum\limits_{l=0}^\infty(\gamma \lambda)^l\textcolor{blue}{\Delta_{t+l}^V} A^t=l=0(γλ)lΔt+lV
        ~~~~~~~        计算 θ i + 1 \theta_{i+1} θi+1。 式 (31) ↓
        ~~~~~~~        计算 ϕ i + 1 \phi_{i+1} ϕi+1。式 (30) ↓
e n d   f o r {\bf end ~for} end for

在这里插入图片描述

在这里插入图片描述

注意,策略更新 θ i → θ i + 1 \theta_i→θ_{i+1} θiθi+1 是使用价值函数 V ϕ i V_{\phi_i} Vϕi (用于优势估计) 执行的,而不是使用 V ϕ i + 1 V_{\phi_{i+1}} Vϕi+1
如果我们先更新价值函数,就会引入额外的偏差
为了了解这一点,考虑极端情况,我们过拟合价值函数,并且Bellman 残差 r t + γ V ( s t + 1 ) − V ( s t ) r_t + \gamma V(s_{t+1}) - V(s_t) rt+γV(st+1)V(st) 在所有时间步长都变为零——策略梯度估计值将为零。

6.2 实验设置

我们在以下任务评估了我们的方法:经典的推车-杆平衡问题,以及几个具有挑战性的 3D 运动任务:
(1) 两足运动;
(2) 四足运动;
(3) 动态站起来,对于两足动物来说,它开始时是仰卧的。
模型如图 1 所示。

在这里插入图片描述

6.2.1 网络架构

我们对所有的 3D 机器人任务使用了相同的神经网络架构,这是一个有 3 个隐藏层的前馈网络,分别有100, 50 和 25 个 tanh 单元。
策略和价值函数使用了相同的神经网络架构。
最后的输出层是线性激活的。
价值函数估计器使用相同的架构,但只有一个标量输出
对于更简单的 cart-pole 任务,我们使用了线性策略和一个包含 20 个单元的隐藏层的神经网络作为价值函数。

6.2.2 任务细节

对于 cart-pole 平衡任务,我们使用 Barto等人(1983)的物理参数,每批收集 20 个轨迹,最大长度为 1000 个时间步长

模拟机器人任务使用 MuJoCo 物理引擎进行模拟 (Todorov et al., 2012)。
人形机器人模型有 33 个状态维度和 10 个驱动自由度,四足机器人模型有 29 个状态维度和 8 个驱动自由度。
这些任务的初始状态由以参考配置为中心的均匀分布组成。
对于两足运动,我们每批使用 50000 个时间步长50000 timesteps per batch,对于四足运动和两足站立,我们每批使用 200000 个时间步长 200000 timesteps per batch
如果机器人事先没有达到终止状态,每一个回合将在 2000 个时间步后终止
时间步长为 0.01 秒。

奖励函数如下表所示。

在这里插入图片描述

在运动任务中,如果 actor 的质心低于预先设定的高度(两足动物为 0.8 米,四足动物为 0.2 米),则该回合终止。
奖励函数中的常数偏移量鼓励更长的回合;否则,二次奖励项可能会导致尽快结束回合的策略。

6.3 实验结果

所有结果都以损失表示,cost 被定义为负奖励,并被最小化。
习得的策略的视频可以在 https://sites.google.com/site/ gaepapersupp 上找到。
在图中,“No VF ”意味着我们使用了不依赖于状态的时间相关基线,而不是对状态价值函数的估计
时间相关的基线是通过在批次的轨迹上平均每个时间步的回报来计算的。

6.3.1 Cart-pole

结果是用不同随机种子进行的 21 次实验的平均值
结果如图 2 所示,在参数 γ ∈ [ 0.96 , 0.99 ] γ\in [0.96, 0.99] γ[0.96,0.99] λ ∈ [ 0.92 , 0.99 ] λ\in[0.92,0.99] λ[0.92,0.99] 的中间值处获得最佳效果。

在这里插入图片描述

图 2: 左:推车杆cart-pole 任务的学习曲线,在 γ = 0.99 \gamma = 0.99 γ=0.99 时使用不同 λ \lambda λ 值的广义优势估计。
通过 λ \lambda λ 在 [0.92,0.98] 范围内的中间值获得最快的策略改进。
右:在不同的 γ \gamma γ λ \lambda λ 下, 策略优化 20 次迭代后的性能。白色意味着更高的奖励。在两者的中间值处得到最佳结果。

6.3.2 3D 双足运动

每次试验在 16 核机器上运行大约需要 2 小时,其中并行化了模拟部署,以及优化策略和价值函数时使用的函数、梯度和矩阵向量乘积评估。
这里,使用不同随机种子的 9 个试验的平均结果。
使用中间值 γ ∈ [ 0.99 , 0.995 ] , λ ∈ [ 0.96 , 0.99 ] \gamma \in [0.99, 0.995],\lambda \in[0.96,0.99] γ[0.99,0.995]λ[0.96,0.99] 再次获得最佳性能
1000 次迭代后的结果是快速、平滑、稳定的步态,实际上是完全稳定的。
我们可以计算在这个学习过程中使用了多少“实时real”时间:
在这里插入图片描述
因此,如果有一种方法可以重置机器人的状态并确保它不会损坏自己,那么这个算法可以在一个真实的机器人上运行,或者在多个并行学习的真实机器人上运行。

在这里插入图片描述

图 3:
左: 3D 双足运动的学习曲线,算法在 9 次运行中平均。
右: 3D 四足运动的学习曲线,对 5 次运行进行平均。

6.3.3 其他 3D 机器人任务

考虑的另外两种运动行为是四足运动和 3D 双足动物离开地面。
同样,我们在每个实验条件下执行了 5 次试验,使用不同的随机种子(和初始化)。
在一台 32 核的机器上,每次试验大约需要 4 个小时。
我们对这些领域进行了更有限的比较(由于运行这些实验需要大量的计算资源),固定 γ = 0.995 \gamma = 0.995 γ=0.995,但变化 λ ∈ { 1 , 0.96 } \lambda\in\{1,0.96\} λ{1,0.96},以及没有价值函数的实验条件。
对于四足运动,使用 6.3.2 节中 γ = 0.96 \gamma=0.96 γ=0.96 的价值函数获得最佳结果。
对于 3D 站立,价值函数总是有帮助的,但对于 γ = 0.96 \gamma= 0.96 γ=0.96 λ = 1 \lambda= 1 λ=1,结果大致相同。

在这里插入图片描述

图 4:
(a) 四足行走学习曲线,
(b) 3D 站立学习曲线,
(c) 3D 站立片段。

7 讨论

Policy gradient methods provide a way to reduce reinforcement learning to stochastic gradient descent, by providing unbiased gradient estimates.
策略梯度方法通过提供无偏梯度估计,提供了一种将强化学习 转成 随机梯度下降的方法。
However, so far their success at solving difficult control problems has been limited, largely due to their high sample complexity.
然而,到目前为止,它们在解决困难的控制问题上的成功是有限的,很大程度上是由于他们的高 样本复杂度
We have argued that the key to variance reduction is to obtain good estimates of the advantage function.
我们认为,减小方差的关键是获得优势函数的良好估计

We have provided an intuitive but informal analysis of the problem of advantage function estimation, and justified the generalized advantage estimator, which has two parameters γ , λ \gamma, \lambda γ,λ which adjust the bias-variance tradeoff.
我们对优势函数估计问题提供了一个直观但非正式的分析,并证明了广义优势估计器,它有两个参数 γ , λ \gamma, \lambda γ,λ 来调节偏差-方差权衡。
We described how to combine this idea with trust region policy optimization and a trust region algorithm that optimizes a value function, both represented by neural networks.
我们描述了如何将这一思想与信任域策略优化 和 优化价值函数的信任域算法结合起来,这两种算法都由神经网络表示。
Combining these techniques, we are able to learn to solve difficult control tasks that have previously been out of reach for generic reinforcement learning methods.
结合这些技术,我们能够学习解决以前通用强化学习方法无法实现的困难控制任务。

【后续工作展望 1:价值函数估计 误差 与 策略梯度估计误差 之间的关系。】

One question that merits future investigation is the relationship between value function estimation error and policy gradient estimation error.
值得进一步研究的一个问题是 价值函数估计 误差 与 策略梯度估计误差 之间的关系。
If this relationship were known, we could choose an error metric for value function fitting that is well-matched to the quantity of interest, which is typically the accuracy of the policy gradient estimation.
如果这个关系是已知的,我们可以为 价值函数拟合 选择一个误差指标,它与感兴趣的量非常匹配,这通常是策略梯度估计的准确性。
Some candidates for such an error metric might includethe Bellman error or projected Bellman error, as described in Bhatnagar et al. (2009).
如 Bhatnagar 等人(2009) 所述,这种误差指标的一些候选者可能包括 Bellman 误差 或 预测 Bellman 误差。

【后续工作展望 2:共享函数近似架构 ——> 特征共用, 更快地学习】

Another enticing possibility is to use a shared function approximation architecture for the policy and the value function, while optimizing the policy using generalized advantage estimation.
另一种诱人的可能性是为策略和价值函数使用共享函数近似架构,同时使用广义优势估计优化策略。
While formulating this problem in a way that is suitable for numerical optimization and provides convergence guarantees remains an open question, such an approach could allow the value function and policy representations to share useful features of the input, resulting in even faster learning.
虽然以一种适合于数值优化并提供收敛保证的方式来表述这个问题仍然是一个悬而未决的问题,但这种方法可以让价值函数和策略表示 共享输入的有用特征,从而更快地学习

【同期工作比较】

In concurrent work, researchers have been developing policy gradient methods that involve differentiation with respect to the continuous-valued action (Lillicrap et al., 2015; Heess et al., 2015). 【同期工作有哪些?】
在并行工作中,研究人员一直在开发涉及连续值动作 微分的策略梯度方法 (Lillicrap等人,2015;Heess et al., 2015)。
While we found empirically that the one-step return ( λ = 0 \lambda= 0 λ=0) leads to excessive bias and poor performance, these papers show that such methods can work when tuned appropriately. 【同期工作的主要发现】
我们从经验上发现 一步回报 ( λ = 0 \lambda= 0 λ=0) 会导致过大的偏差和较差的性能,但这些论文表明,这些方法在适当调整时可以工作。
However, note that those papers consider control problems with substantially lower-dimensional state and action spaces than the ones considered here. 【本工作 与 同期工作的区别之处】
然而,请注意,那些论文考虑的控制问题具有比本文考虑的低维状态和动作空间的问题。
A comparison between both classes of approach would be useful for future work.
两类方法之间的比较将有助于今后的工作。

致谢

我们感谢 Emo Todorov 提供了模拟器以及富有见地的讨论,
我们感谢 Greg Wayne、Yuval Tassa、Dave Silver、Carlos Florensa Campo 和 Greg Brockman 进行了富有见地的讨论。
这项研究的部分资金是由海军研究办公室通过一个年轻研究者奖 和 拨款编号 NO0014-11-1-0688, DARPA 通过青年教师奖,由 陆军研究办公室通过 MAST 项目 获得。

A 常见问题

A.1 与兼容特征的关系是什么?
与使用价值函数的策略梯度算法相关的兼容特征经常被提到,Konda 和 Tsitsiklis (2003) 在《On Actors - Critic Methods》一文中提出了这个想法。
这些作者指出,由于策略的表示能力有限,策略梯度只依赖于优势函数空间的某一个子空间。
这个子空间是由相容特征 ∇ θ i log ⁡ π θ ( a t ∣ s t ) \nabla_{\theta_i} \log π_\theta(a_t| s_t) θilogπθ(atst) 张成的,其中 i ∈ { 1 , 2 , ⋯   , dim ⁡ θ } i \in\{1,2,\cdots,\dim \theta\} i{1,2,,dimθ}
这种兼容特征理论没有提供如何利用问题的时序结构来获得更好的优势函数估计 的指导,使其与本文的思想ideas 基本正交。

兼容特征的想法激发了一种计算自然策略梯度的优雅方法(Kakade, 2001;Peters & Schaal, 2008)。
给定优势函数 A ^ t \hat A_t A^t 在每个时间步的经验估计,我们可以通过求解以下最小二乘问题将其投影到兼容特征的子空间:
  ~  
minimize r ∑ t ∥ r ⋅ ∇ θ log ⁡ π θ ( a t ∣ s t ) − A ^ t ∥ 2            ( 32 ) \underset{\bf r}{\text{minimize}}\sum\limits_{t}\Vert{\bf r}·\nabla_\theta\log \pi_\theta(a_t|s_t)-\hat A_t\Vert^2~~~~~~~~~~(32) rminimizetrθlogπθ(atst)A^t2          (32)
  ~  
如果 A ^ t \hat A_t A^t γ \gamma γ-just,则最小二乘解是自然策略梯度(Kakade, 2001a)。
注意,任何优势函数的估计量都可以代入这个公式,包括我们在本文中推导的估计量。
对于我们的实验,我们也计算自然策略梯度步steps,但我们使用 Schulman 等人(2015) 的计算效率更高的数值过程,如第 6 节所述。

A.2 为什么不直接用 Q Q Q 函数呢?
先前的 actor-critic 方法,例如 Konda 和 Tsitsiklis(2003),使用 Q 函数来获得潜在的低方差策略梯度估计。
最近的论文包括 Heess et al. (2015);Lillicrap 等人(2015) 已经证明,神经网络 Q Q Q 函数近似器可以有效地用于策略梯度方法。
然而,以本文的方式使用 状态-价值函数 有几个优点
首先,状态-价值函数的输入维度较低,因此比 状态-动作价值函数 更容易学习
其次,本文的方法允许我们在高偏差估计器 ( λ \lambda λ = 0) 和 低偏差估计器 ( λ \lambda λ = 1)之间平滑地插值。
另一方面,使用参数化 Q Q Q 函数只允许我们使用高偏差估计器。
我们发现,当使用回报的一步估计时,即 λ \lambda λ = 0 估计器, A ^ t = Δ t V = r t + γ V ( s t + 1 ) − V ( s t ) Â_t = \Delta_t^V= r_t +\gamma V(s_{t+1}) - V(s_t) A^t=ΔtV=rt+γV(st+1)V(st),偏差是非常大的。
我们预计,当使用涉及参数化 Q Q Q 函数的优势估计器 A ^ t = Q ( s , a ) − V ( s ) Â_t =Q(s, a) - V(s) A^t=Q(s,a)V(s)时,也会遇到类似的困难。
有一个有趣的可能算法空间,使用参数化的 Q Q Q 函数并尝试减少偏差,然而,对这些可能性的探索超出了本工作的范围。

  • 使用参数化的 Q Q Q 函数并尝试减少偏差

B 证明

在这里插入图片描述

命题 1 证明:首先我们可以把期望分成包含 Q Q Q b b b 的项,

E s 0 : ∞ , a 0 : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) ( Q t ( s 0 : ∞ , a 0 : ∞ ) − b t ( s 0 : t , a 0 : t − 1 ) ) ] = E s 0 : ∞ , a 0 : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) Q t ( s 0 : ∞ , a 0 : ∞ ) ]       − E s 0 : ∞ , a 0 : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) b t ( s 0 : t , a 0 : t − 1 ) ]            ( 33 ) \begin{aligned}&{\mathbb E}_{s_{0:\infty}, a_{0:\infty}}\Big[\nabla_\theta\log \pi_\theta(a_t|s_t)\Big(Q_t(s_{0:\infty}, a_{0:\infty})-b_t(s_{0:t},a_{0:t-1})\Big)\Big]\\ &={\mathbb E}_{s_{0:\infty}, a_{0:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)Q_t(s_{0:\infty}, a_{0:\infty})]\\ &~~~~~-{\mathbb E}_{s_{0:\infty}, a_{0:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)b_t(s_{0:t},a_{0:t-1})]~~~~~~~~~~(33)\end{aligned} Es0:,a0:[θlogπθ(atst)(Qt(s0:,a0:)bt(s0:t,a0:t1))]=Es0:,a0:[θlogπθ(atst)Qt(s0:,a0:)]     Es0:,a0:[θlogπθ(atst)bt(s0:t,a0:t1)]          (33)

我们将依次考虑 Q Q Q 项和 b b b 项。

E s 0 : ∞ , a 0 : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) Q t ( s 0 : ∞ , a 0 : ∞ ) ] = E s 0 : t , a 0 : t [ E s t + 1 : ∞ , a t + 1 : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) Q t ( s 0 : ∞ , a 0 : ∞ ) ] ] = E s 0 : t , a 0 : t [ ∇ θ log ⁡ π θ ( a t ∣ s t ) E s t + 1 : ∞ , a t + 1 : ∞ [ Q t ( s 0 : ∞ , a 0 : ∞ ) ] ]        注意时间步,后一个求期望只考虑时间步  t + 1  及之后的,因此可以把梯度项移到期望求解之外 = E s 0 : t , a 0 : t [ ∇ θ log ⁡ π θ ( a t ∣ s t ) A π ( s t , a t ) ] \begin{aligned}&{\mathbb E}_{s_{0:\infty}, a_{0:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)Q_t(s_{0:\infty}, a_{0:\infty})]\\ &={\mathbb E}_{s_{0:t}, a_{0:t}}\Big[{\mathbb E}_{s_{t+1:\infty}, a_{t+1:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)Q_t(s_{0:\infty}, a_{0:\infty})]\Big]\\ &={\mathbb E}_{s_{0:t}, a_{0:t}}\Big[\nabla_\theta\log \pi_\theta(a_t|s_t){\mathbb E}_{s_{t+1:\infty}, a_{t+1:\infty}}[Q_t(s_{0:\infty}, a_{0:\infty})]\Big]~~~~~~\textcolor{blue}{注意时间步,后一个 求期望 只 考虑 时间步~ t + 1 ~及之后的,因此可以把 梯度项 移到期望求解之外}\\ &={\mathbb E}_{s_{0:t}, a_{0:t}}\Big[\nabla_\theta\log \pi_\theta(a_t|s_t)\textcolor{blue}{A^\pi(s_t,a_t)}\Big]\end{aligned} Es0:,a0:[θlogπθ(atst)Qt(s0:,a0:)]=Es0:t,a0:t[Est+1:,at+1:[θlogπθ(atst)Qt(s0:,a0:)]]=Es0:t,a0:t[θlogπθ(atst)Est+1:,at+1:[Qt(s0:,a0:)]]      注意时间步,后一个求期望只考虑时间步 t+1 及之后的,因此可以把梯度项移到期望求解之外=Es0:t,a0:t[θlogπθ(atst)Aπ(st,at)]

  ~  

E s 0 : ∞ , a 0 : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) b t ( s 0 : t , a 0 : t − 1 ) ] = E s 0 : t , a 0 : t − 1 [ E s t + 1 : ∞ , a t : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) b t ( s 0 : t , a 0 : t − 1 ) ] ] = E s 0 : t , a 0 : t − 1 [ E s t + 1 : ∞ , a t : ∞ [ ∇ θ log ⁡ π θ ( a t ∣ s t ) ] ⏟ 0 b t ( s 0 : t , a 0 : t − 1 ) ] = E s 0 : t , a 0 : t − 1 [ 0 ⋅ b t ( s 0 : t , a 0 : t − 1 ) ] = 0 \begin{aligned}&{\mathbb E}_{s_{0:\infty}, a_{0:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)b_t(s_{0:t},a_{0:t-1})]\\ &={\mathbb E}_{s_{0:t}, a_{0:t-1}}\Big[{\mathbb E}_{s_{t+1:\infty}, a_{t:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)b_t(s_{0:t},a_{0:t-1})]\Big]\\ &={\mathbb E}_{s_{0:t}, a_{0:t-1}}\Big[\underbrace{{\mathbb E}_{s_{t+1:\infty}, a_{t:\infty}}[\nabla_\theta\log \pi_\theta(a_t|s_t)\textcolor{blue}{]}}_{0}b_t(s_{0:t},a_{0:t-1})\Big]\\ &={\mathbb E}_{s_{0:t}, a_{0:t-1}}\Big[0·b_t(s_{0:t},a_{0:t-1})\Big]\\ &=0\end{aligned} Es0:,a0:[θlogπθ(atst)bt(s0:t,a0:t1)]=Es0:t,a0:t1[Est+1:,at:[θlogπθ(atst)bt(s0:t,a0:t1)]]=Es0:t,a0:t1[0 Est+1:,at:[θlogπθ(atst)]bt(s0:t,a0:t1)]=Es0:t,a0:t1[0bt(s0:t,a0:t1)]=0

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/888504.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

九、Drf序列化器

九、序列化器 9.1序列化 从数据库取QuerySet或数据对象转换成JSON 9.1.1序列化器的简易使用 #新建一张部门表 class Depart(models.Model):titlemodels.CharField(verbose_name部门,max_length32)ordermodels.IntegerField(verbose_name顺序)countmodels.IntegerField(verb…

C语言_内存函数

内存函数是 C 标准库中的一组函数&#xff0c;用于管理和操作内存。使用时需要包含头文件<string.h>。 1. memcpy的使用和模拟实现 函数形式如下&#xff1a; void* memcpy(void* destination, const void* source, size_tnum);函数解析和注意事项&#xff1a; memcp…

LinuxO(1)调度算法

概念 在Linux中&#xff0c;O(1)调度算法是一种进程调度算法。O(1)表示算法的时间复杂度是常数级别的&#xff0c;与系统中的进程数量无关。 运行队列结构 他采用了两个运行队列&#xff0c;一个活动队列和一个过期队列。活动队列中的进程是有资格获取CPU时间片的进程&#x…

AWS EC2 部署Echarts大屏展示项目

前言 Echarts简介 ECharts是一个由JavaScript开发的开源可视化库。它能使数据生动、直观、互动、高度个性化数据可视化图表。ECharts适用大部分浏览器&#xff0c;如IE6 、Chrome、Firefox、Safari等&#xff0c;同时支持PC和移动设备。 开源&#xff1a;ECharts是一个开源项目…

【JavaEE】——文件IO

阿华代码&#xff0c;不是逆风&#xff0c;就是我疯 你们的点赞收藏是我前进最大的动力&#xff01;&#xff01; 希望本文内容能够帮助到你&#xff01;&#xff01; 目录 一&#xff1a;认识文件 1&#xff1a;文件的概念 2&#xff1a;文件的结构 3&#xff1a;文件路径…

矩阵求解复数(aniwoth求解串扰)

所以这种求解串扰的格式是因为&#xff0c;有串扰的共轭项在方程组中 复数共轭项的作用&#xff0c;但是这是二次方程&#xff0c;

【深度学习】yolov8n模型的剪枝操作记录

原始 剪枝微调后 可以看到模型大小了&#xff0c; 测试结果显示再cpu 上加速5%-10% from ultralytics import YOLOimport time # Load a pretrained YOLO11n model count_num 500 def test1():model YOLO("/home/justin/Desktop/code/v8_prun/runs/detect/train3/weig…

算法知识点————贪心

贪心&#xff1a;只考虑局部最优解&#xff0c;不考虑全部最优解。有时候得不到最优解。 DP&#xff1a;考虑全局最优解。DP的特点&#xff1a;无后效性&#xff08;正在求解的时候不关心前面的解是怎么求的&#xff09;&#xff1b; 二者都是在求最优解的&#xff0c;都有最优…

微服务实战——ElasticSearch(保存)

商品上架——ElasticSearch&#xff08;保存&#xff09; 0.商城架构图 1.商品Mapping 分析&#xff1a;商品上架在 es 中是存 sku 还是 spu &#xff1f; 检索的时候输入名字&#xff0c;是需要按照 sku 的 title 进行全文检索的检索使用商品规格&#xff0c;规格是 spu 的…

No package nodejs available.No package npm available.

安装nodejs时出现的报错 这个错误的原因是当前的 yum 源没有包含 Node.js 和 npm 的安装包。 解决方法 使用 NodeSource 仓库 curl -fsSL https://rpm.nodesource.com/setup_14.x | bash -运行 yum install 安装 Node.js 和 npm&#xff1a; yum install -y nodejs使用 E…

深入了解Oracle OCP认证,开启数据库专业之旅

使用Oracle数据库的公司内部&#xff0c;经常有员工们在讨论OCP认证(Oracle Certified Professional&#xff0c;Oracle认证专家)&#xff0c;这是甲骨文Oracle公司提供的一种专业认证&#xff0c;认证用于使用者在Oracle技术领域的专业知识和技能。 在这里&#xff0c;有一点…

华为、华三、锐捷网络设备的常用命令整理

华为&#xff08;Huawei&#xff09;、华三&#xff08;H3C&#xff09;、锐捷&#xff08;Ruijie&#xff09;常用网络设备命令&#xff1a; 华为&#xff08;Huawei&#xff09; 查看设备的信息&#xff0c;可执行“display version”命令。 查看当下的配置&#xff0c;则…

动手学深度学习9.3. 深度循环神经网络-笔记练习(PyTorch)

本节课程地址&#xff1a;58 深层循环神经网络【动手学深度学习v2】_哔哩哔哩_bilibili 本节教材地址&#xff1a;9.3. 深度循环神经网络 — 动手学深度学习 2.0.0 documentation (d2l.ai) 本节开源代码&#xff1a;...>d2l-zh>pytorch>chapter_multilayer-perceptr…

计算机毕业设计Tensorflow交通标志识别检测 车流量预测 车速检测 自动驾驶 机器学习 深度学习 人工智能 PyTorch 大数据毕设

《Tensorflow交通标志识别检测》开题报告 一、研究背景及意义 随着智能交通系统和无人驾驶技术的快速发展&#xff0c;交通标志识别系统成为智能驾驶系统的重要组成部分。传统的交通标志识别方法主要依赖于人工检查和识别&#xff0c;存在效率低下、易受主观因素影响等问题。…

聚观早报 | 苹果重磅更新;OpenAI推出ChatGPT Canvas

聚观早报每日整理最值得关注的行业重点事件&#xff0c;帮助大家及时了解最新行业动态&#xff0c;每日读报&#xff0c;就读聚观365资讯简报。 整理丨Cutie 10月1日消息 苹果重磅更新 OpenAI推出ChatGPT Canvas Meta发布Movie Gen iQOO 13影像规格曝光 华为HarmonyOS N…

高效微调理解(prompt-tuning,p-tuning v1,p-tuning v2,lora)

高效微调&#xff08;prompt-tuning&#xff0c;p-tuning v1&#xff0c;p-tuning v2&#xff0c;lora&#xff09; 1.prompt-tuning&#xff1a; 例子理解&#xff1b;保持原本模型参数不变&#xff0c;通过训练提示词的参数调整prompt&#xff0c;使其与下游任务匹配。 例子…

计算机毕业设计 基于Django的在线考试系统的设计与实现 Python+Django+Vue 前后端分离 附源码 讲解 文档

&#x1f34a;作者&#xff1a;计算机编程-吉哥 &#x1f34a;简介&#xff1a;专业从事JavaWeb程序开发&#xff0c;微信小程序开发&#xff0c;定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事&#xff0c;生活就是快乐的。 &#x1f34a;心愿&#xff1a;点…

职场上的人情世故,你知多少?这五点一定要了解

职场是一个由人组成的复杂社交网络&#xff0c;人情世故在其中起着至关重要的作用。良好的人际关系可以帮助我们更好地融入团队&#xff0c;提升工作效率&#xff0c;甚至影响职业发展。在职场中&#xff0c;我们需要了解一些关键要素&#xff0c;以更好地处理人际关系&#xf…

[C++]使用纯opencv部署yolov11-cls图像分类onnx模型

【算法介绍】 在C中使用纯OpenCV部署YOLOv11-cls图像分类ONNX模型是一项具有挑战性的任务&#xff0c;因为YOLOv11通常是用PyTorch等深度学习框架实现的&#xff0c;而OpenCV本身并不直接支持加载和运行PyTorch模型。然而&#xff0c;可以通过一些间接的方法来实现这一目标&am…

【MySQL】Ubuntu环境下MySQL的安装与卸载

目录 1.MYSQL的安装 2.MySQL的登录 3.MYSQL的卸载 4.设置配置文件 1.MYSQL的安装 首先我们要看看我们环境里面有没有已经安装好的MySQL 我们发现是默认是没有的。 我们还可以通过下面这个命令来确认有没有mysql的安装包 首先我们得知道我们当前的系统版本是什么 lsb_…