Generative Adversarial Imitation Learning
Generative Adversarial Imitation Learning
Jonathan Ho Affiliation: Stanford University Email: hoj@cs.stanford.edu Stefano Ermon Affiliation: Stanford University Email: ermon@cs.stanford.edu
Abstract
摘要
Consider learning a policy from example expert behavior, without interaction with the expert or access to reinforcement signal. One approach is to recover the expert’s cost function with inverse reinforcement learning, then extract a policy from that cost function with reinforcement learning. This approach is indirect and can be slow. We propose a new general framework for directly extracting a policy from data, as if it were obtained by reinforcement learning following inverse reinforcement learning. We show that a certain instantiation of our framework draws an analogy between imitation learning and generative adversarial networks, from which we derive a model-free imitation learning algorithm that obtains significant performance gains over existing model-free methods in imitating complex behaviors in large, high-dimensional environments.
考虑从示例专家行为中学习策略,且训练时既不与专家交互、也拿不到强化信号。一条路子是用逆强化学习先恢复专家的代价函数,再用强化学习从该代价抽出策略。这条路间接,而且往往很慢。我们提出一个一般框架,直接从数据抽出策略,效果上就像先做了逆强化学习再跑强化学习。我们证明框架的某一实例把模仿学习与生成对抗网络对应起来,由此得到一种无模型模仿学习算法;在大型高维环境中模仿复杂行为时,它相对已有无模型方法有显著性能提升。
1 Introduction
1 引言
We are interested in a specific setting of imitation learning—the problem of learning to perform a task from expert demonstrations—in which the learner is given only samples of trajectories from the expert, is not allowed to query the expert for more data while training, and is not provided reinforcement signal of any kind. There are two main approaches suitable for this setting: behavioral cloning [20], which learns a policy as a supervised learning problem over state-action pairs from expert trajectories; and inverse reinforcement learning [25, 18], which finds a cost function under which the expert is uniquely optimal.
我们关心模仿学习的一种具体设定——从专家演示中学会完成任务:学习者只拿到专家轨迹样本,训练期间不能再向专家查询数据,也得不到任何形式的强化信号。适合这一设定的两条主路线是:行为克隆(behavioral cloning)[20],把专家轨迹中的状态–动作对当成监督学习问题来拟合策略;以及逆强化学习(inverse reinforcement learning)[25, 18],寻找使专家策略唯一最优的代价函数。
Behavioral cloning, while appealingly simple, only tends to succeed with large amounts of data, due to compounding error caused by covariate shift [23, 24]. Inverse reinforcement learning (IRL), on the other hand, learns a cost function that prioritizes entire trajectories over others, so compounding error, a problem for methods that fit single-timestep decisions, is not an issue. Accordingly, IRL has succeeded in a wide range of problems, from predicting behaviors of taxi drivers [31] to planning footsteps for quadruped robots [22].
行为克隆看似简单,却往往需要大量数据才能成功,原因是协变量偏移带来的误差累积 [23, 24]。逆强化学习(IRL)则学习一种对整条轨迹排序的代价函数,因此不会像「按单步决策拟合」的方法那样吃累积误差的亏。相应地,IRL 已在从预测出租车司机行为 [31] 到为四足机器人规划落脚点 [22] 等广泛问题上取得成功。
Unfortunately, many IRL algorithms are extremely expensive to run, requiring reinforcement learning in an inner loop. Scaling IRL methods to large environments has thus been the focus of much recent work [7, 14]. Fundamentally, however, IRL learns a cost function, which explains expert behavior but does not directly tell the learner how to act. Given that learner’s true goal often is to take actions imitating the expert—indeed, many IRL algorithms are evaluated on the quality of the optimal actions of the costs they learn—why, then, must we learn a cost function, if doing so possibly incurs significant computational expense yet fails to directly yield actions?
遗憾的是,许多 IRL 算法运行代价极高,内层还要再跑强化学习。于是把 IRL 扩到大环境成了近期工作的焦点 [7, 14]。但从根本上说,IRL 学到的是代价函数:它解释专家行为,却不直接告诉学习者该怎么动。既然学习者的真实目标常常就是做出像专家那样的动作——事实上许多 IRL 算法正是用所学代价下的最优动作质量来评估的——那为什么还非要先学一个代价函数?这样做可能既贵,又不能直接给出动作。
We desire an algorithm that tells us explicitly how to act by directly learning a policy. To develop such an algorithm, we begin in Section 3, where we characterize the policy given by running reinforcement learning on a cost function learned by maximum causal entropy IRL [31, 32]. Our characterization introduces a framework for directly learning policies from data, bypassing any intermediate IRL step.
我们希望有一种算法,通过直接学习策略,明确告诉我们该怎么行动。为此,第 3 节先刻画:对最大因果熵 IRL [31, 32] 学到的代价再跑强化学习,得到的是怎样的策略。这一刻画引出一个直接从数据学策略的框架,绕开中间的 IRL 步骤。
Then, we instantiate our framework in Sections 4 and 5 with a new model-free imitation learning algorithm. We show that our resulting algorithm is intimately connected to generative adversarial networks [9], a technique from the deep learning community that has led to recent successes in modeling distributions of natural images: our algorithm harnesses generative adversarial training to fit distributions of states and actions defining expert behavior. We test our algorithm in Section 6, where we find that it outperforms competing methods by a wide margin in training policies for complex, high-dimensional physics-based control tasks over various amounts of expert data.
随后在第 4、5 节把该框架实例化成一种新的无模型模仿学习算法。我们证明所得算法与生成对抗网络 [9] 密切相关——后者是深度学习社区用来建模自然图像分布、并带来近期成功的技术:我们的算法借助生成对抗训练,去拟合刻画专家行为的状态–动作分布。第 6 节的实验表明,在多种专家数据量下,它为复杂、高维、基于物理的控制任务训练策略时,大幅优于对照方法。
2 Background
2 背景
Preliminaries
will denote the extended real numbers . Section 3 will work with finite state and action spaces and to avoid technical machinery out of the scope of this paper (concerning compactness of certain sets of functions), but our algorithms and experiments later in the paper will run in high-dimensional continuous environments. is the set of all stationary stochastic policies that take actions in given states in ; successor states are drawn from the dynamics model . We work in the -discounted infinite horizon setting, and we will use an expectation with respect a policy to denote an expectation with respect to the trajectory it generates: , where , , and for . We will use to denote empirical expectation with respect to trajectory samples , and we will always refer to the expert policy as .
预备
表示扩展实数 。第 3 节为避开超出本文范围的技术细节(某些函数集的紧性),只讨论有限状态与动作空间 、;后文算法与实验则会在高维连续环境中运行。 是给定 中状态、在 中取动作的全体平稳随机策略;下一状态由动力学模型 抽样。我们工作在 -折扣无限时域设定下,对策略 的期望表示对其生成轨迹的期望:,其中 ,,()。 表示对轨迹样本 的经验期望;专家策略一律记为 。
Inverse reinforcement learning
Suppose we are given an expert policy that we wish to rationalize with IRL. For the remainder of this paper, we will adopt maximum causal entropy IRL [31, 32], which fits a cost function from a family of functions with the optimization problem
逆强化学习
假设给定专家策略 ,要用 IRL 加以合理化。本文后文一律采用最大因果熵 IRL [31, 32],它从函数族 中拟合代价函数,优化问题为
where is the -discounted causal entropy [3] of the policy . In practice, will only be provided as a set of trajectories sampled by executing in the environment, so the expected cost of in Eq. 1 is estimated using these samples. Maximum causal entropy IRL looks for a cost function that assigns low cost to the expert policy and high cost to other policies, thereby allowing the expert policy to be found via a certain reinforcement learning procedure:
其中 是策略 的 -折扣因果熵 [3]。实践中 只以在环境中执行 得到的轨迹集合形式给出,因而式 (1) 中 的期望代价要用这些样本估计。最大因果熵 IRL 寻找 ,给专家策略低代价、给其他策略高代价,从而专家策略可通过下述强化学习过程找回:
which maps a cost function to high-entropy policies that minimize the expected cumulative cost.
它把代价函数映射到期望累积代价最小的高熵策略。
3 Characterizing the induced optimal policy
3 刻画诱导出的最优策略
To begin our search for an imitation learning algorithm that both bypasses an intermediate IRL step and is suitable for large environments, we will study policies found by reinforcement learning on costs learned by IRL on the largest possible set of cost functions in Eq. 1: all functions . Using expressive cost function classes, like Gaussian processes [15] and neural networks [7], is crucial to properly explain complex expert behavior without meticulously hand-crafted features. Here, we investigate the best IRL can do with respect to expressiveness, by examining its capabilities with .
为寻找既绕开中间 IRL、又适合大环境的模仿学习算法,我们先研究:在式 (1) 最大可能的代价函数类 ——即全体函数 ——上做 IRL,再对学到的代价跑强化学习,会得到什么策略。要用高斯过程 [15]、神经网络 [7] 这类有表达力的代价类,才能在不精心手工特征的情况下解释复杂专家行为。这里我们考察 IRL 在表达力上的「最好能做什么」,即取 。
Of course, with such a large , IRL can easily overfit when provided a finite dataset. Therefore, we will incorporate a (closed, proper) convex cost function regularizer into our study. Note that convexity is a not particularly restrictive requirement: must be convex as a function defined on all of , not as a function defined on a small parameter space; indeed, the cost regularizers of Finn et al. 2016, effective for a range of robotic manipulation tasks, satisfy this requirement. Interestingly, will in fact find that plays a central role in our discussion, not a nuisance in our analysis.
当然,如此大的 在有限数据上很容易过拟合。因此我们引入一个(闭的、固有的)凸代价正则项 。凸性并不是特别苛刻的要求: 须作为定义在整个 上的函数是凸的,而不是定义在小小参数空间上的函数;Finn 等人 2016 年对一系列机器人操作任务有效的代价正则项就满足这一点。有意思的是, 在后文讨论中会扮演中心角色,而不是分析里的累赘。
Now, let us define an IRL primitive procedure, which finds a cost function such that the expert performs better than all other policies, with the cost regularized by :
现在定义一个 IRL 原语:在 正则下,寻找使专家优于所有其他策略的代价函数:
Now let . We are interested in a policy given by —this is the policy given by running reinforcement learning on the output of IRL.
令 。我们关心的是 给出的策略——也就是对 IRL 输出再跑强化学习得到的策略。
To characterize , it will be useful to transform optimization problems over policies into convex problems. For a policy , define its occupancy measure as . The occupancy measure can be interpreted as the distribution of state-action pairs that an agent encounters when navigating the environment with policy , and it allows us to write for any cost function . A basic result [21] is that the set of valid occupancy measures can be written as a feasible set of affine constraints: if is the distribution of starting states and is the dynamics model, then . Furthermore, there is a one-to-one correspondence between and :
为刻画 ,把策略上的优化问题改写成凸问题会很方便。对 ,定义占用测度 为 。占用测度可理解为智能体用策略 在环境中游走时遇到的状态–动作对分布,并让我们把任意代价 写成 。一个基本结果 [21] 是:合法占用测度集合 可写成仿射约束的可行集:若 是起始状态分布、 是动力学,则 。此外 与 一一对应:
Proposition 3.1(Theorem 2 of Syed et al. 2008).
If , then is the occupancy measure for , and is the only policy whose occupancy measure is .
命题 3.1(Syed 等人 2008 定理 2)。
若 ,则 是 的占用测度,且 是唯一以 为占用测度的策略。
We are therefore justified in writing to denote the unique policy for an occupancy measure . We will need one more tool: for a function , its convex conjugate is given by .
因此我们可以写 表示占用测度 对应的唯一策略。还需要一个工具:对 ,其凸共轭 定义为 。
Now, we are ready to characterize , the policy learned by RL on the cost recovered by IRL:
现在可以刻画 ,即对 IRL 恢复的代价再跑 RL 学到的策略:
Proposition 3.2.
命题 3.2。
The proof of Proposition 3.2 is in Section A.1. The proof relies on the observation that the optimal cost function and policy form a saddle point of a certain function. IRL finds one coordinate of this saddle point, and running reinforcement learning on the output of IRL reveals the other coordinate.
命题 3.2 的证明见第 A.1 节。证明依赖一个观察:最优代价与策略构成某函数的鞍点。IRL 找到鞍点的一个坐标,对 IRL 输出再跑强化学习则揭示另一个坐标。
Proposition 3.2 tells us that -regularized inverse reinforcement learning, implicitly, seeks a policy whose occupancy measure is close to the expert’s, as measured by the convex function . Enticingly, this suggests that various settings of lead to various imitation learning algorithms that directly solve the optimization problem given by Proposition 3.2. We explore such algorithms in Sections 4 and 5, where we show that certain settings of lead to both existing algorithms and a novel one.
命题 3.2 告诉我们:-正则的逆强化学习,隐含地在寻找占用测度按凸函数 度量、接近专家的策略。这很诱人:它暗示不同的 设置会直接对应命题 3.2 所给优化问题的不同模仿学习算法。第 4、5 节将探索这类算法,并证明某些 既覆盖已有算法,也给出新算法。
The special case when is a constant function is particularly illuminating, so we state and show it directly using concepts from convex optimization.
为常函数的特例特别有启发性,我们直接用凸优化概念陈述并证明。
Corollary 3.2.1.
If is a constant function, , and , then .
推论 3.2.1。
若 为常函数,,且 ,则 。
In other words, if there were no cost regularization at all, then the recovered policy will exactly match the expert’s occupancy measure. To show this, we will need a lemma that lets us speak about causal entropies of occupancy measures:
换言之,若完全没有代价正则,恢复出的策略会精确匹配专家的占用测度。为此需要一个引理,使我们能谈论占用测度上的因果熵:
Lemma 3.1.
Let . Then, is strictly concave, and for all and , we have and .
引理 3.1。
令 。则 严格凹,且对所有 、,有 以及 。
The proof of this lemma is in Section A.1. Proposition 3.1 and Lemma 3.1 together allow us to freely switch between policies and occupancy measures when considering functions involving causal entropy and expected costs, as in the following lemma:
该引理证明见第 A.1 节。命题 3.1 与引理 3.1 合在一起,让我们在涉及因果熵与期望代价的函数上可以在策略与占用测度之间自由切换,如下述引理:
Lemma 3.2.
If and , then, for all cost functions , for all policies , and for all occupancy measures .
引理 3.2。
若 且 ,则对一切代价 :对所有 有 ;对所有 有 。
Now, we are ready to give a direct proof of Corollary 3.2.1.
现在可以直接证明推论 3.2.1。
Proof of Corollary 3.2.1.
Define . Given that is a constant function, we have the following, due to Lemma 3.2:
推论 3.2.1 的证明。
定义 。鉴于 为常函数,由引理 3.2 有:
This is the dual of the optimization problem
这是优化问题
with Lagrangian , for which the costs serve as dual variables for equality constraints. Thus, is a dual optimum for 7. Because is a convex set and is convex, strong duality holds; moreover, Lemma 3.1 guarantees that is in fact strictly convex, so the primal optimum can be uniquely recovered from the dual optimum [4, Section 5.5.5] via where the first equality indicates that is the unique minimizer of , and the third follows from the constraints in the primal problem 7. But if , then, by Lemma 3.2, its occupancy measure satisfies . ∎
的对偶,拉格朗日量为 ,代价 充当等式约束的对偶变量。于是 是 (7) 的对偶最优。因为 凸且 凸,强对偶成立;再由引理 3.1, 实际严格凸,故可从对偶最优唯一恢复原问题最优 [4, 第 5.5.5 节]:,其中第一个等号表明 是 的唯一极小点,第三个等号来自原问题 (7) 的约束。但若 ,则由引理 3.2,其占用测度满足 。∎
From this argument, we can deduce the following:
由此论证可推出:
IRL is a dual of an occupancy measure matching problem, and the recovered cost function is the dual optimum. Classic IRL algorithms that solve reinforcement learning repeatedly in an inner loop, such as the algorithm of Ziebart et al. 2008 that runs a variant of value iteration in an inner loop, can be interpreted as a form of dual ascent, in which one repeatedly solves the primal problem (reinforcement learning) with fixed dual values (costs). Dual ascent is effective if solving the unconstrained primal is efficient, but in the case of IRL, it amounts to reinforcement learning!
IRL 是占用测度匹配问题的对偶,恢复出的代价函数是对偶最优。那些在内环反复求解强化学习的经典 IRL 算法——例如 Ziebart 等人 2008 在内环跑一种值迭代变体——可解释为对偶上升:反复用固定对偶变量(代价)求解原问题(强化学习)。若无约束原问题求解高效,对偶上升就有效;但在 IRL 里,这恰恰等于强化学习!
The induced optimal policy is the primal optimum. The induced optimal policy is obtained by running RL after IRL, which is exactly the act of recovering the primal optimum from the dual optimum; that is, optimizing the Lagrangian with the dual variables fixed at the dual optimum values. Strong duality implies that this induced optimal policy is indeed the primal optimum, and therefore matches occupancy measures with the expert. IRL is traditionally defined as the act of finding a cost function such that the expert policy is uniquely optimal, but now, we can alternatively view IRL as a procedure that tries to induce a policy that matches the expert’s occupancy measure.
诱导出的最优策略是原问题最优。 诱导最优策略由 IRL 之后再跑 RL 得到,正好是从对偶最优恢复原问题最优;也就是把对偶变量固定在对偶最优值上优化拉格朗日量。强对偶意味着该诱导最优策略确为原问题最优,因而与专家占用测度匹配。IRL 传统上定义为寻找使专家策略唯一最优的代价;现在也可把 IRL 看成试图诱导出与专家占用测度匹配的策略的过程。
4 Practical occupancy measure matching
4 实用的占用测度匹配
We saw in Corollary 3.2.1 that if is constant, the resulting primal problem 7 simply matches occupancy measures with expert at all states and actions. Such an algorithm, however, is not practically useful. In reality, the expert trajectory distribution will be provided only as a finite set of samples, so in large environments, most of the expert’s occupancy measure values will be exactly zero, and exact occupancy measure matching will force the learned policy to never visit these unseen state-action pairs simply due to lack of data. Furthermore, with large environments, we would like to use function approximation to learn a parameterized policy . The resulting optimization problem of finding the appropriate would have as many constraints as points in , leading to an intractably large problem and defeating the very purpose of function approximation.
推论 3.2.1 表明:若 为常数,所得原问题 (7) 只是在所有状态与动作上匹配专家占用测度。但这样的算法并不实用。现实中专家轨迹分布只以有限样本给出,在大环境里专家占用测度的多数取值会精确为 0,精确匹配会迫使学到的策略永远不去那些未见过的状态–动作对,仅仅因为缺数据。再者,大环境中我们希望用函数逼近来学参数化策略 。找合适 的优化问题会有与 点数一样多的约束,既不可行又违背函数逼近的初衷。
Keeping in mind that we wish to eventually develop an imitation learning algorithm suitable for large environments, we would like to relax Eq. 7 into the following form, motivated by Proposition 3.2:
既然最终目标是适合大环境的模仿学习算法,我们希望把式 (7) 松弛成由命题 3.2 启发的如下形式:
by modifying the IRL regularizer so that smoothly penalizes violations in difference between the occupancy measures.
做法是修改 IRL 正则项 ,使 平滑地惩罚占用测度之差的违背。
Entropy-regularized apprenticeship learning
It turns out that with certain settings of , Eq. 8 takes on the form of regularized variants of existing apprenticeship learning algorithms, which indeed do scale to large environments with parameterized policies [11]. For a class of cost functions , an apprenticeship learning algorithm finds a policy that performs better than the expert across , by optimizing the objective
熵正则的学徒学习
事实证明,对某些 ,式 (8) 会变成已有学徒学习(apprenticeship learning)算法的正则化变体,而这类算法确可用参数化策略扩到大环境 [11]。对代价类 ,学徒学习寻找在整个 上优于专家的策略,目标为
Classic apprenticeship learning algorithms restrict to convex sets given by linear combinations of basis functions , which give rise a feature vector for each state-action pair. Abbeel and Ng 2004 and Syed et al. 2008 use, respectively,
经典学徒学习把 限制为由基函数 的线性组合给出的凸集,从而每个状态–动作对有特征向量 。Abbeel 与 Ng 2004 以及 Syed 等人 2008 分别使用
leads to feature expectation matching [1], which minimizes distance between expected feature vectors: . Meanwhile, leads to MWAL [28] and LPAL [29], which minimize worst-case excess cost among the individual basis functions, as .
导致特征期望匹配 [1],最小化期望特征向量之间的 距离:。而 导致 MWAL [28] 与 LPAL [29],最小化各基函数上的最坏超额代价,因为 。
We now show how Eq. 9 is a special case of Eq. 8 with a certain setting of . With the indicator function , defined by if and otherwise, we can write the apprenticeship learning objective 9 as
下面说明式 (9) 是式 (8) 在某一 下的特例。用示性函数 ( 时为 0,否则 ),可把学徒学习目标 (9) 写成
Therefore, we see that entropy-regularized apprenticeship learning
因此,熵正则学徒学习
is equivalent to performing RL following IRL with cost regularizer , which forces the implicit IRL procedure to recover a cost function lying in . Note that we can scale the policy’s entropy regularization strength in Eq. 11 by scaling by a constant as , recovering the original apprenticeship objective 9 by taking .
等价于用代价正则项 做 IRL 后再跑 RL,从而迫使隐含 IRL 恢复落在 中的代价。注意:用常数 缩放 为 ,可缩放式 (11) 中策略熵正则强度;令 即恢复原学徒目标 (9)。
Cons of apprenticeship learning
It is known that apprenticeship learning algorithms generally do not recover expert-like policies if is too restrictive [29, Section 1]—which is often the case for the linear subspaces used by feature expectation matching, MWAL, and LPAL, unless the basis functions are very carefully designed. Intuitively, unless the true expert cost function (assuming it exists) lies in , there is no guarantee that if performs better than on all of , then equals . With the aforementioned insight based on Proposition 3.2 that apprenticeship learning is equivalent to RL following IRL, we can understand exactly why apprenticeship learning may fail to imitate: it forces to be encoded as an element of . If does not include a cost function that explains expert behavior well, then attempting to recover a policy from such an encoding will not succeed.
学徒学习的缺点
已知若 过于受限,学徒学习一般无法恢复像专家的策略 [29, 第 1 节]——特征期望匹配、MWAL、LPAL 所用的线性子空间往往正是如此,除非基函数 设计得极仔细。直观上,除非真正的专家代价(假定存在)落在 中,否则即使 在整个 上优于 ,也不能保证 等于 。借助命题 3.2「学徒学习等价于 IRL 后接 RL」的洞见,可以精确理解学徒学习为何可能失败:它强迫把 编码成 中的一个元素。若 里没有能很好解释专家行为的代价,从这个编码恢复策略就不会成功。
Pros of apprenticeship learning
While restrictive cost classes may not lead to exact imitation, apprenticeship learning with such can scale to large state and action spaces with policy function approximation. Ho et al. 2016 rely on the following policy gradient formula for the apprenticeship objective 9 for a parameterized policy :
学徒学习的优点
尽管受限的 未必带来精确模仿,带这种 的学徒学习却能借助策略函数逼近扩到大状态与动作空间。Ho 等人 2016 依赖参数化策略 上学徒目标 (9) 的如下策略梯度公式:
$$\displaystyle\begin{split}&\nabla_{\theta}\max_{c\in\mathcal{C}}\mathbb{E}{\pi{\theta}}[c(s,a)]-\mathbb{E}{\pi{E}}[c(s,a)]=\nabla_{\theta}\mathbb{E}{\pi{\theta}}[c^{}(s,a)]=\mathbb{E}{\pi{\theta}}\left[\nabla_{\theta}\log\pi_{\theta}(a|s)Q_{c^{}}(s,a)\right]\
&\text{where}\ c^{}!=\argmax_{c\in\mathcal{C}}\mathbb{E}{\pi{\theta}}[c(s,a)]-\mathbb{E}{\pi{E}}[c(s,a)],\ Q_{c^{}}(\bar{s},\bar{a})=\mathbb{E}{\pi{\theta}}[c^{*}(\bar{s},\bar{a}),|,s_{0}=\bar{s},a_{0}=\bar{a}]\end{split} \tag{12}$$
Observing that Eq. 12 is the policy gradient for a reinforcement learning objective with cost , Ho et al. 2016 propose an algorithm that alternates between two steps:
观察到式 (12) 正是代价为 的强化学习目标的策略梯度,Ho 等人 2016 提出在两步之间交替的算法:
- Sample trajectories of the current policy by simulating in the environment, and fit a cost function , as defined in Eq. 12. For the cost classes and 10, this cost fitting amounts to evaluating simple analytical expressions [11].
- 在环境中仿真,采样当前策略 的轨迹,并按式 (12) 拟合代价 。对代价类 与 (式 10),这一拟合就是计算简单的解析表达式 [11]。
- Form a gradient estimate with Eq. 12 with and the sampled trajectories, and take a trust region policy optimization (TRPO) [26] step to produce .
- 用 与采样轨迹按式 (12) 形成梯度估计,再走一步信任域策略优化(TRPO)[26],得到 。
This algorithm relies crucially on the TRPO policy step, which is a natural gradient step constrained to ensure that does not stray too far , as measured by KL divergence between the two policies averaged over the states in the sampled trajectories. This carefully constructed step scheme ensures that divergence does not occur due to high noise in estimating the gradient 12. We refer the reader to Schulman et al. 2015a for more details on TRPO.
该算法关键依赖 TRPO 策略步:这是带约束的自然梯度步,保证 相对 不会偏离太远,度量是采样轨迹状态上两策略 KL 散度的平均。这种仔细构造的步进方案避免了因估计梯度 (12) 噪声过大而发散。细节见 Schulman 等人 2015a。
With the TRPO step scheme, Ho et al. 2016 were able train large neural network policies for apprenticeship learning with linear cost function classes 10 in environments with hundreds of observation dimensions. Their use of these linear cost function classes, however, limits their approach to settings in which expert behavior is well-described by such classes. We will draw upon their algorithm to develop an imitation learning method that both scales to large environments and imitates arbitrarily complex expert behavior. To do so, we first turn to proposing a new regularizer that wields more expressive power than the regularizers corresponding to and 10.
借助 TRPO 步进,Ho 等人 2016 能在有数百维观测的环境中,用线性代价类(式 10)训练大学习网络策略做学徒学习。但线性代价类限制了方法:只有专家行为能被这类函数很好描述时才适用。我们将借用他们的算法,发展一种既能扩到大环境、又能模仿任意复杂专家行为的方法。为此先提出新的正则项 ,其表达力超过对应 与 (式 10)的正则项。
5 Generative adversarial imitation learning
5 生成对抗模仿学习
As discussed in Section 4, the constant regularizer leads to an imitation learning algorithm that exactly matches occupancy measures, but is intractable in large environments. The indicator regularizers for the linear cost function classes 10, on the other hand, lead to algorithms incapable of exactly matching occupancy measures without careful tuning, but are tractable in large environments. We propose the following new cost regularizer that combines the best of both worlds, as we will show in the coming sections:
如第 4 节所论,常正则项带来精确匹配占用测度的算法,但在大环境中不可行;线性代价类(式 10)的示性正则项则带来不经仔细调参就无法精确匹配、却能在大环境中运行的算法。我们提出如下新代价正则项,后文将说明它兼顾两者之长:
$\displaystyle\psi_{\text{GA}}(c)\triangleq\begin{cases}\mathbb{E}_{\pi_{E}}[g(c(s,a))]&ifc<0$\
+\infty&otherwise\end{cases}\ \text{where}\ g(x)=\begin{cases}-x-\log(1-e^{x})&if \
+\infty&otherwise\end{cases} \tag{13}$$
This regularizer places low penalty on cost functions that assign an amount of negative cost to expert state-action pairs; if , however, assigns large costs (close to zero, which is the upper bound for costs feasible for ) to the expert, then will heavily penalize . An interesting property of is that it is an average over expert data, and therefore can adjust to arbitrary expert datasets. The indicator regularizers , used by the linear apprenticeship learning algorithms described in Section 4, are always fixed, and cannot adapt to data as can. Perhaps the most important difference between and , however, is that forces costs to lie in a small subspace spanned by finitely many basis functions, whereas allows for any cost function, as long as it is negative everywhere.
该正则项对给专家状态–动作对赋一定负代价的 惩罚较低;若 给专家赋接近 0 的大代价(这是 可行代价的上界),则会重罚。 的一个有趣性质是它在专家数据上取平均,因而能适应任意专家数据集。第 4 节线性学徒算法用的示性正则 始终固定,不能像 那样随数据调整。 与 最重要的差别或许是:后者强迫代价落在有限个基函数张成的小子空间,而前者只要代价处处为负,就允许任意代价函数。
Our choice of is motivated by the following fact, shown in the appendix (Corollary A.1.1):
选择 的动机是下述事实(附录推论 A.1.1):
where the maximum ranges over discriminative classifiers . Equation 14 is the optimal negative log loss of the binary classification problem of distinguishing between state-action pairs of and . It turns out that this optimal loss is (up to a constant shift) the Jensen-Shannon divergence , which is a squared metric between distributions [9, 19]. Treating the causal entropy as a policy regularizer, controlled by , we obtain a new imitation learning algorithm:
其中最大值取遍判别分类器 。式 (14) 是区分 与 状态–动作对的二分类问题的最优负对数损失。该最优损失(差一个常数平移)正是 Jensen–Shannon 散度 ,它是分布之间的平方度量 [9, 19]。把因果熵 当作由 控制的策略正则,便得到新的模仿学习算法:
which finds a policy whose occupancy measure minimizes Jensen-Shannon divergence to the expert’s. Equation 15 minimizes a true metric between occupancy measures, so, unlike linear apprenticeship learning algorithms, it can imitate expert policies exactly.
它寻找占用测度与专家的 Jensen–Shannon 散度最小的策略。式 (15) 最小化占用测度之间的真度量,因此与线性学徒算法不同,它可以精确模仿专家策略。
Algorithm
Equation 15 draws a connection between imitation learning and generative adversarial networks [9], which train a generative model by having it confuse a discriminative classifier . The job of is to distinguish between the distribution of data generated by and the true data distribution. When cannot distinguish data generated by from the true data, then has successfully matched the true data. In our setting, the learner’s occupancy measure is analogous to the data distribution generated by , and the expert’s occupancy measure is analogous to the true data distribution.
算法
式 (15) 把模仿学习与生成对抗网络 [9] 联系起来:后者训练生成模型 ,使其迷惑判别分类器 。 的任务是区分 生成的数据分布与真实数据分布;当 分不清二者时, 就成功匹配了真实数据。在我们的设定里,学习者占用测度 类比 生成的数据分布,专家占用测度 类比真实数据分布。
Now, we present a practical algorithm, which we call generative adversarial imitation learning (Algorithm 1), for solving Eq. 15 for model-free imitation in large environments. Explicitly, we wish to find a saddle point of the expression
下面给出求解式 (15)、面向大环境无模型模仿的实用算法,称为生成对抗模仿学习(算法 1)。明确地说,我们要找表达式
To do so, we first introduce function approximation for and : we will fit a parameterized policy , with weights , and a discriminator network , with weights . Then, we alternate between an Adam [12] gradient step on to increase Eq. 16 with respect to , and a TRPO step on to decrease Eq. 16 with respect to . The TRPO step serves the same purpose as it does with the apprenticeship learning algorithm of Ho et al. 2016: it prevents the policy from changing too much due to noise in the policy gradient. The discriminator network can be interpreted as a local cost function providing learning signal to the policy—specifically, taking a policy step that decreases expected cost with respect to the cost function will move toward expert-like regions of state-action space, as classified by the discriminator. (We derive an estimator for the causal entropy gradient in Section A.2.)
的鞍点 。为此先对 与 做函数逼近:拟合带权 的参数化策略 ,以及带权 、映射 的判别网络 。然后交替:用 Adam [12] 对 做梯度步以相对 增大式 (16);用 TRPO 对 做一步以相对 减小式 (16)。TRPO 步与 Ho 等人 2016 的学徒算法作用相同:防止策略因策略梯度噪声而变化过大。判别网络可解释为给策略提供学习信号的局部代价——具体地,相对代价 走一步降低期望代价,就会移向判别器判定为「像专家」的状态–动作区域。(因果熵梯度 的估计器推导见第 A.2 节。)
1: Input: Expert trajectories , initial policy and discriminator parameters
2: for do
3: Sample trajectories
4: Update the discriminator parameters from to with the gradient (17)
5: Take a policy step from to , using the TRPO rule with cost function . Specifically, take a KL-constrained natural gradient step with \displaystyle\begin{split}&\hat{}\mathbb{E}_{\tau_{i}}\left[\nabla_{\theta}\log\pi_{\theta}(a|s)Q(s,a)\right]-\lambda\nabla_{\theta}H(\pi_{\theta}),\\ &\text{where}\ Q(\bar{s},\bar{a})=\hat{}\mathbb{E}_{\tau_{i}}[\log(D_{w_{i+1}}(s,a))\,|\,s_{0}=\bar{s},a_{0}=\bar{a}]\end{split} (18)
6: end for
Algorithm 1 Generative adversarial imitation learning
1: 输入: 专家轨迹 ,策略与判别器初值
2: for do
3: 采样轨迹
4: 用梯度 把判别器参数从 更新到 (17)
5: 以代价 按 TRPO 规则,从 走到 。具体地,取 KL 约束自然梯度步 \displaystyle\begin{split}&\hat{}\mathbb{E}_{\tau_{i}}\left[\nabla_{\theta}\log\pi_{\theta}(a|s)Q(s,a)\right]-\lambda\nabla_{\theta}H(\pi_{\theta}),\\ &\text{where}\ Q(\bar{s},\bar{a})=\hat{}\mathbb{E}_{\tau_{i}}[\log(D_{w_{i+1}}(s,a))\,|\,s_{0}=\bar{s},a_{0}=\bar{a}]\end{split}(18)
6: end for
算法 1 生成对抗模仿学习
6 Experiments
6 实验
We evaluated Algorithm 1 against baselines on 9 physics-based control tasks, ranging from low-dimensional control tasks from the classic RL literature—the cartpole [2], acrobot [8], and mountain car [17]—to difficult high-dimensional tasks such as a 3D humanoid locomotion, solved only recently by model-free reinforcement learning [27, 26]. All environments, other than the classic control tasks, were simulated with MuJoCo [30]. See Appendix B for a complete description of all the tasks.
我们在 9 个基于物理的控制任务上对照基线评估算法 1,范围从经典强化学习文献中的低维任务——cartpole [2]、acrobot [8]、mountain car [17]——到近期才被无模型强化学习解决的困难高维任务,如三维人形行走 [27, 26]。除经典控制任务外,其余环境均用 MuJoCo [30] 仿真。任务完整描述见附录 B。
Each task comes with a true cost function, defined in the OpenAI Gym [5]. We first generated expert behavior for these tasks by running TRPO [26] on these true cost functions to create expert policies. Then, to evaluate imitation performance with respect to sample complexity of expert data, we sampled datasets of varying trajectory counts from the expert policies. The trajectories constituting each dataset each consisted of about 50 state-action pairs. We tested Algorithm 1 against three baselines:
每个任务都有 OpenAI Gym [5] 定义的真实代价。我们先在这些真实代价上跑 TRPO [26] 生成专家策略。然后,为评估模仿性能相对专家数据样本量的关系,从专家策略采样不同轨迹条数的数据集;每条轨迹大约含 50 个状态–动作对。算法 1 对照三条基线:
- Behavioral cloning: a given dataset of state-action pairs is split into 70% training data and 30% validation data. The policy is trained with supervised learning, using Adam [12] with minibatches of 128 examples, until validation error stops decreasing.
- 行为克隆:把给定状态–动作对数据集按 70%/30% 划分训练/验证。用 Adam [12]、每批 128 例做监督学习,直到验证误差不再下降。
- Feature expectation matching (FEM): the algorithm of Ho et al. 2016 using the cost function class 10 of Abbeel and Ng 2004
- 特征期望匹配(FEM):Ho 等人 2016 的算法,代价类取 Abbeel 与 Ng 2004 的 (式 10)
- Game-theoretic apprenticeship learning (GTAL): the algorithm of Ho et al. 2016 using the cost function class 10 of Syed and Schapire 2007
- 博弈论学徒学习(GTAL):Ho 等人 2016 的算法,代价类取 Syed 与 Schapire 2007 的 (式 10)
We used all algorithms to train policies of the same neural network architecture for all tasks: two hidden layers of 100 units each, with nonlinearities in between. The discriminator networks for Algorithm 1 also used the same architecture. All networks were always initialized randomly at the start of each trial. For each task, we gave FEM, GTAL, and Algorithm 1 exactly the same amount of environment interaction for training.
所有算法在全部任务上训练同一架构的策略网络:两层各 100 隐单元,中间为 非线性。算法 1 的判别网络亦用同一架构。每次试验网络均随机初始化。对每个任务,FEM、GTAL 与算法 1 的环境交互量完全相同。
Figure 1 depicts the results, and the tables in Appendix B provide exact performance numbers. We found that on the classic control tasks (cartpole, acrobot, and mountain car), behavioral cloning suffered in expert data efficiency compared to FEM and GTAL, which for the most part were able produce policies with near-expert performance with a wide range of dataset sizes. On these tasks, our generative adversarial algorithm always produced policies performing better than behavioral cloning, FEM, and GTAL. However, behavioral cloning performed excellently on the Reacher task, on which it was more sample efficient than our algorithm. We were able to slightly improve our algorithm’s performance on Reacher using causal entropy regularization—in the 4-trajectory setting, the improvement from to was statistically significant over training reruns, according to a one-sided Wilcoxon rank-sum test with . We used no causal entropy regularization for all other tasks.
图 1 给出结果,附录 B 的表格提供精确性能数字。在经典控制任务(cartpole、acrobot、mountain car)上,行为克隆相对 FEM、GTAL 在专家数据效率上吃亏,后两者大体上能在多种数据集规模下得到接近专家的策略。这些任务上,我们的生成对抗算法始终优于行为克隆、FEM 与 GTAL。但行为克隆在 Reacher 上表现优异,样本效率高于我们的算法。用因果熵正则可略微改善我们在 Reacher 上的表现——在 4 条轨迹设定下, 到 的提升在多次重训上按单侧 Wilcoxon 秩和检验达到 显著。其余任务未使用因果熵正则。
图 1:各任务、各专家数据集规模下模仿学习算法的性能。(a)文中报告的经典控制与 MuJoCo 结果。
On the other MuJoCo environments, we saw a large performance boost for our algorithm over the baselines. Our algorithm almost always achieved at least 70% of expert performance for all dataset sizes we tested, nearly always dominating all the baselines. FEM and GTAL performed poorly for Ant, producing policies consistently worse than a policy that chooses actions uniformly at random. Behavioral cloning was able to reach satisfactory performance with enough data on HalfCheetah, Hopper, Walker, and Ant; but was unable to achieve more than 60% for Humanoid, on which our algorithm achieved exact expert performance for all tested dataset sizes.
在其余 MuJoCo 环境中,我们的算法相对基线有大幅提升。几乎对所有测试的数据集规模,它都能达到至少 70% 的专家性能,并几乎总是压过全部基线。FEM 与 GTAL 在 Ant 上很差,策略甚至持续差于均匀随机动作。行为克隆在 HalfCheetah、Hopper、Walker、Ant 上数据足够时可达到尚可的表现,但在 Humanoid 上无法超过 60%;而我们的算法在所有测试数据集规模上都达到了精确的专家性能。
7 Discussion and outlook
7 讨论与展望
As we demonstrated, our method is generally quite sample efficient in terms of expert data. However, it is not particularly sample efficient in terms of environment interaction during training. The number of such samples required to estimate the imitation objective gradient 18 was comparable to the number needed for TRPO to train the expert policies from reinforcement signals. We believe that we could significantly improve learning speed for our algorithm by initializing policy parameters with behavioral cloning, which requires no environment interaction at all.
如实验所示,我们的方法在专家数据上一般相当样本高效,但在训练期的环境交互上并不特别高效。估计模仿目标梯度 (18) 所需样本量,与用 TRPO 从强化信号训练专家策略所需量相当。我们相信:用行为克隆初始化策略参数(完全不需要环境交互)可以显著加快学习。
Fundamentally, our method is model free, so it will generally need more environment interaction than model-based methods. Guided cost learning [7], for instance, builds upon guided policy search [13] and inherits its sample efficiency, but also inherits its requirement that the model is well-approximated by iteratively fitted time-varying linear dynamics. Interestingly, both our Algorithm 1 and guided cost learning alternate between policy optimization steps and cost fitting (which we called discriminator fitting), even though the two algorithms are derived completely differently.
从根本上说,我们的方法是无模型的,因此一般会比基于模型的方法需要更多环境交互。例如 guided cost learning [7] 建立在 guided policy search [13] 之上,继承了其样本效率,也继承了「模型须被迭代拟合的时变线性动力学很好近似」的要求。有意思的是,算法 1 与 guided cost learning 都在策略优化与代价拟合(我们称作判别器拟合)之间交替,尽管两者推导路径完全不同。
Our approach builds upon a vast line of work on IRL [31, 1, 29, 28], and hence, just like IRL, our approach does not interact with the expert during training. Our method explores randomly to determine which actions bring a policy’s occupancy measure closer to the expert’s, whereas methods that do interact with the expert, like DAgger [24], can simply ask the expert for such actions. Ultimately, we believe that a method that combines well-chosen environment models with expert interaction will win in terms of sample complexity of both expert data and environment interaction.
我们的方法建立在漫长的 IRL 工作线之上 [31, 1, 29, 28],因而也像 IRL 一样,训练时不与专家交互。我们的方法靠随机探索来判断哪些动作能让策略占用测度更接近专家;而像 DAgger [24] 这类会与专家交互的方法,可以直接向专家要这些动作。最终我们相信:把选得好的环境模型与专家交互结合起来的方法,会在专家数据与环境交互两方面的样本复杂度上胜出。
Acknowledgments
We thank Jayesh K. Gupta and John Schulman for assistance and advice. This work was supported by the SAIL-Toyota Center for AI Research, and by a NSF Graduate Research Fellowship (grant no. DGE-114747).
致谢
感谢 Jayesh K. Gupta 与 John Schulman 的协助与建议。本工作得到 SAIL-Toyota AI 研究中心以及 NSF 研究生研究奖学金(编号 DGE-114747)支持。
References
参考文献
Abbeel and Ng [2004] P. Abbeel and A. Y. Ng. Apprenticeship learning via inverse reinforcement learning. In Proceedings of the 21st International Conference on Machine Learning , 2004.
Barto et al. [1983] A. G. Barto, R. S. Sutton, and C. W. Anderson. Neuronlike adaptive elements that can solve difficult learning control problems. Systems, Man and Cybernetics, IEEE Transactions on , (5):834–846, 1983.
Bloem and Bambos [2014] M. Bloem and N. Bambos. Infinite time horizon maximum causal entropy inverse reinforcement learning. In Decision and Control (CDC), 2014 IEEE 53rd Annual Conference on , pages 4911–4916. IEEE, 2014.
Boyd and Vandenberghe [2004] S. Boyd and L. Vandenberghe. Convex optimization . Cambridge university press, 2004.
Brockman et al. [2016] G. Brockman, V. Cheung, L. Pettersson, J. Schneider, J. Schulman, J. Tang, and W. Zaremba. OpenAI Gym. arXiv preprint arXiv:1606.01540 , 2016.
Cover and Thomas [2012] T. M. Cover and J. A. Thomas. Elements of information theory . John Wiley & Sons, 2012.
Finn et al. [2016] C. Finn, S. Levine, and P. Abbeel. Guided cost learning: Deep inverse optimal control via policy optimization. In Proceedings of the 33rd International Conference on Machine Learning , 2016.
Geramifard et al. [2015] A. Geramifard, C. Dann, R. H. Klein, W. Dabney, and J. P. How. Rlpy: A value-function-based reinforcement learning framework for education and research. JMLR , 2015.
Goodfellow et al. [2014] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio. Generative adversarial nets. In NIPS , pages 2672–2680, 2014.
Hiriart-Urruty and Lemaréchal [1996] J.-B. Hiriart-Urruty and C. Lemaréchal. Convex Analysis and Minimization Algorithms , volume 305. Springer, 1996.
Ho et al. [2016] J. Ho, J. K. Gupta, and S. Ermon. Model-free imitation learning with policy optimization. In Proceedings of the 33rd International Conference on Machine Learning , 2016.
Kingma and Ba [2014] D. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980 , 2014.
Levine and Abbeel [2014] S. Levine and P. Abbeel. Learning neural network policies with guided policy search under unknown dynamics. In Advances in Neural Information Processing Systems , pages 1071–1079, 2014.
Levine and Koltun [2012] S. Levine and V. Koltun. Continuous inverse optimal control with locally optimal examples. In Proceedings of the 29th International Conference on Machine Learning , pages 41–48, 2012.
Levine et al. [2011] S. Levine, Z. Popovic, and V. Koltun. Nonlinear inverse reinforcement learning with gaussian processes. In Advances in Neural Information Processing Systems , pages 19–27, 2011.
Millar [1983] P. W. Millar. The minimax principle in asymptotic statistical theory. In Ecole d’Eté de Probabilités de Saint-Flour XI—1981 , pages 75–265. Springer, 1983.
Moore and Hall [1990] A. W. Moore and T. Hall. Efficient memory-based learning for robot control. 1990.
Ng and Russell [2000] A. Y. Ng and S. Russell. Algorithms for inverse reinforcement learning. In ICML , 2000.
Nguyen et al. [2009] X. Nguyen, M. J. Wainwright, and M. I. Jordan. On surrogate loss functions and f-divergences. The Annals of Statistics , pages 876–904, 2009.
Pomerleau [1991] D. A. Pomerleau. Efficient training of artificial neural networks for autonomous navigation. Neural Computation , 3(1):88–97, 1991.
Puterman [2014] M. L. Puterman. Markov decision processes: discrete stochastic dynamic programming . John Wiley & Sons, 2014.
Ratliff et al. [2009] N. D. Ratliff, D. Silver, and J. A. Bagnell. Learning to search: Functional gradient techniques for imitation learning. Autonomous Robots , 27(1):25–53, 2009.
Ross and Bagnell [2010] S. Ross and D. Bagnell. Efficient reductions for imitation learning. In AISTATS , pages 661–668, 2010.
Ross et al. [2011] S. Ross, G. J. Gordon, and D. Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In AISTATS , pages 627–635, 2011.
Russell [1998] S. Russell. Learning agents for uncertain environments. In Proceedings of the Eleventh Annual Conference on Computational Learning Theory , pages 101–103. ACM, 1998.
Schulman et al. [2015a] J. Schulman, S. Levine, P. Abbeel, M. Jordan, and P. Moritz. Trust region policy optimization. In Proceedings of The 32nd International Conference on Machine Learning , pages 1889–1897, 2015a.
Schulman et al. [2015b] J. Schulman, P. Moritz, S. Levine, M. Jordan, and P. Abbeel. High-dimensional continuous control using generalized advantage estimation. arXiv preprint arXiv:1506.02438 , 2015b.
Syed and Schapire [2007] U. Syed and R. E. Schapire. A game-theoretic approach to apprenticeship learning. In Advances in Neural Information Processing Systems , pages 1449–1456, 2007.
Syed et al. [2008] U. Syed, M. Bowling, and R. E. Schapire. Apprenticeship learning using linear programming. In Proceedings of the 25th International Conference on Machine Learning , pages 1032–1039, 2008.
Todorov et al. [2012] E. Todorov, T. Erez, and Y. Tassa. Mujoco: A physics engine for model-based control. In Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Conference on , pages 5026–5033. IEEE, 2012.
Ziebart et al. [2008] B. D. Ziebart, A. Maas, J. A. Bagnell, and A. K. Dey. Maximum entropy inverse reinforcement learning. In AAAI , AAAI’08, 2008.
Ziebart et al. [2010] B. D. Ziebart, J. A. Bagnell, and A. K. Dey. Modeling interaction via the principle of maximum causal entropy. In ICML , pages 1255–1262, 2010.
Appendix A Proofs
附录 A 证明
A.1 Proofs for Section 3
A.1 第 3 节的证明
Proof of Lemma 3.1.
First, we show strict concavity of . Let and be occupancy measures, and suppose . For all and , the log-sum inequality [6] implies:
引理 3.1 的证明。
先证 的严格凹性。令 、 为占用测度,。对所有 、,对数和不等式 [6] 给出:
with equality if and only if . Summing both sides over all and shows that with equality if and only if . Applying Proposition 3.1 shows that equality in fact holds if and only if , so is strictly concave.
当且仅当 时等号成立。两边对所有 、 求和得 ,等号当且仅当 。再由命题 3.1,等号实际当且仅当 ,故 严格凹。
Now, we turn to verifying the last two statements, which also follow from Proposition 3.1 and the definition of occupancy measures. First,
再验证后两句,它们同样由命题 3.1 与占用测度定义推出。首先,
∎
Proof of Proposition 3.2.
This proof relies on properties of saddle points. For a reference, we refer the reader to Hiriart-Urruty and Lemaréchal 1996.
命题 3.2 的证明。
本证明依赖鞍点性质。参考文献见 Hiriart-Urruty 与 Lemaréchal 1996。
Let , , and
令 ,,以及
We wish to show that . To do this, let be the occupancy measure of , let be the occupancy measure of , and define by
我们要证 。为此令 为 的占用测度, 为 的占用测度,并定义 为
The following relationships then hold, due to Proposition 3.1:
由命题 3.1,有如下关系:
Now is compact and convex and is convex; furthermore, due to convexity of and , we also have that is convex for all , and that is concave for all . Therefore, we can use minimax duality [16]:
现 紧且凸, 凸;又因 与 凸, 对一切 凸, 对一切 凹。因此可用极小极大对偶 [16]:
Hence, from Eqs. 34 and 35, is a saddle point of , which implies that
于是由式 (34)(35), 是 的鞍点,从而
Because is strictly convex for all (Lemma 3.1), Eqs. 38 and 36 imply . Since policies corresponding to occupancy measures are unique (Proposition 3.1), we get . ∎
因为对一切 , 严格凸(引理 3.1),式 (38) 与 (36) 推出 。占用测度对应的策略唯一(命题 3.1),故 。∎
A.2 Proofs for Section 5
A.2 第 5 节的证明
In Eq. 13 of Section 5, we described a cost regularizer , which leads to an imitation learning algorithm 15 that minimizes Jensen-Shannon divergence between occupancy measures. To justify our choice of , we show how to convert certain surrogate loss functions , for binary classification of state-action pairs drawn from the occupancy measures and , into cost function regularizers , for which is the minimum expected risk for :
第 5 节式 (13) 给出代价正则项 ,它导致最小化占用测度间 Jensen–Shannon 散度的模仿学习算法 (15)。为说明这一选择,我们展示如何把某些替代损失 (用于对来自占用测度 与 的状态–动作对做二分类)转换成代价正则项 ,使得 恰为 的最小期望风险 :
Specifically, we will restrict ourselves to strictly decreasing convex loss functions. Nguyen et al. 2009 show a correspondence between minimum expected risks and -divergences, of which Jensen-Shannon divergence is a special case. Our following construction, therefore, can generate any imitation learning algorithm that minimizes an -divergence between occupancy measures, as long as that -divergence is induced by a strictly decreasing convex surrogate .
具体地,我们限制在严格递减的凸损失函数。Nguyen 等人 2009 给出了最小期望风险 与 -散度(Jensen–Shannon 是其特例)之间的对应。因此,只要 -散度由严格递减凸替代 诱导,下述构造就能生成最小化占用测度间该 -散度的任意模仿学习算法。
Proposition A.1.
Suppose is a strictly decreasing convex function. Let be the range of , and define and by:
命题 A.1。
设 严格递减且凸。令 为 的值域,并定义 与 为:
$\displaystyle\begin{split}g_{\phi}(x)&=\begin{cases}-x+\phi(-\phi^{-1}(-x))&ifx\in T$\
+\infty&otherwise\end{cases}\
\psi_{\phi}(c)&=\begin{cases}\sum_{s,a}\rho_{\pi_{E}}(s,a)g_{\phi}(c(s,a))&if for all \
+\infty&otherwise\end{cases}\end{split} \tag{40}$$
Then, is closed, proper, and convex, and .
则 闭、固有且凸,且 。
Proof.
To verify the first claim, it suffices to check that is closed, proper, and convex. Convexity follows from the fact that is convex, because it is a concave function followed by a nonincreasing convex function. Furthermore, because is nonempty, is proper. To show that is closed, note that because is strictly decreasing and convex, the range of is either all of or an open interval for some . If the range of is , then is finite everywhere and is therefore closed. On the other hand, if the range of is , then as , and as . Thus, as , , so too, implying that as , which means is closed.
证明。
验证第一句只需检查 闭、固有且凸。凸性来自 是凸函数:它是凹函数后再接非增凸函数。又因 非空, 固有。证明闭性:因 严格递减且凸,其值域要么是全体 ,要么是某开区间 ()。若值域为 ,则 处处有限因而闭。若值域为 ,则 时 , 时 。于是 时 ,从而 ,即 ,故 闭。
Now, we verify the second claim. By Proposition 3.2, all we need to check is that :
再验证第二句。由命题 3.2,只需检查 :
where we made the change of variables , justified because is the range of . ∎
其中做了变量替换 ,因 是 的值域。∎
Having showed how to construct a cost function regularizer from , we obtain, as a corollary, a cost function regularizer for the logistic loss, whose optimal expected risk is, up to a constant, the Jensen-Shannon divergence.
既已说明如何从 构造代价正则 ,作为推论,我们得到 logistic 损失对应的代价正则;其最优期望风险(差一个常数)正是 Jensen–Shannon 散度。
Corollary A.1.1.
The cost regularizer 13
推论 A.1.1。
代价正则项 (13)
$\displaystyle\psi_{\text{GA}}(c)\triangleq\begin{cases}\mathbb{E}_{\pi_{E}}[g(c(s,a))]&ifc<0$\
+\infty&otherwise\end{cases}\quad\text{where}\quad g(x)=\begin{cases}-x-\log(1-e^{x})&if \
+\infty&otherwise\end{cases}$$
satisfies
满足
Proof.
Using the logistic loss , we see that Eq. 40 reduces to the claimed . Applying Proposition A.1, we get
证明。
取 logistic 损失 ,式 (40) 即化为所述 。应用命题 A.1 得
which is the desired expression. ∎
此即所需表达式。∎
We conclude with a policy gradient formula for causal entropy.
最后给出因果熵的策略梯度公式。
Lemma A.1.
The causal entropy gradient is given by
引理 A.1。
因果熵梯度为
$$\displaystyle\begin{split}\nabla_{\theta}\mathbb{E}{\pi{\theta}}[-\log\pi_{\theta}(a|s)]&=\mathbb{E}{\pi{\theta}}\left[\nabla_{\theta}\log\pi_{\theta}(a|s)Q_{\mathrm{log}}(s,a)\right],\
\text{where}\quad Q_{\mathrm{log}}(\bar{s},\bar{a})&=\mathbb{E}{\pi{\theta}}[-\log\pi_{\theta}(a|s),|,s_{0}=\bar{s},a_{0}=\bar{a}].\end{split} \tag{54}$$
Proof.
For an occupancy measure , define . Next,
证明。
对占用测度 ,定义 。接着,
The second term vanishes, because . We are left with
第二项消失,因为 。剩下
which is the policy gradient for RL with the fixed cost function . The resulting formula is given by the standard policy gradient formula for . ∎
这正是固定代价 下强化学习的策略梯度。所得公式即 的标准策略梯度公式。∎
Appendix B Environments and detailed results
附录 B 环境与详细结果
The environments we used for our experiments are from the OpenAI Gym [5]. The names and version numbers of these environments are listed in Table 1, which also lists dimension or cardinality of their observation and action spaces (numbers marked “continuous” indicate dimension for a continuous space, and numbers marked “discrete” indicate cardinality for a finite space).
实验所用环境来自 OpenAI Gym [5]。名称与版本见表 1,同时列出观测与动作空间的维数或基数(标「continuous」的是连续空间维数,标「discrete」的是有限空间基数)。
Task Observation space Action space Random policy performance Expert performance Cartpole-v0 4 (continuous) 2 (discrete) Acrobot-v0 4 (continuous) 3 (discrete) Mountain Car-v0 2 (continuous) 3 (discrete) Reacher-v1 11 (continuous) 2 (continuous) HalfCheetah-v1 17 (continuous) 6 (continuous) Hopper-v1 11 (continuous) 3 (continuous) Walker-v1 17 (continuous) 6 (continuous) Ant-v1 111 (continuous) 8 (continuous) Humanoid-v1 376 (continuous) 17 (continuous)
Task Observation space Action space Random policy performance Expert performance Cartpole-v0 4 (continuous) 2 (discrete) Acrobot-v0 4 (continuous) 3 (discrete) Mountain Car-v0 2 (continuous) 3 (discrete) Reacher-v1 11 (continuous) 2 (continuous) HalfCheetah-v1 17 (continuous) 6 (continuous) Hopper-v1 11 (continuous) 3 (continuous) Walker-v1 17 (continuous) 6 (continuous) Ant-v1 111 (continuous) 8 (continuous) Humanoid-v1 376 (continuous) 17 (continuous)
Table 1: Environments
任务 观测空间 动作空间 随机策略性能 专家性能 Cartpole-v0 4(连续) 2(离散) Acrobot-v0 4(连续) 3(离散) Mountain Car-v0 2(连续) 3(离散) Reacher-v1 11(连续) 2(连续) HalfCheetah-v1 17(连续) 6(连续) Hopper-v1 11(连续) 3(连续) Walker-v1 17(连续) 6(连续) Ant-v1 111(连续) 8(连续) Humanoid-v1 376(连续) 17(连续)
表 1:环境
The amount of environment interaction used for FEM, GTAL, and our algorithm is shown in Table 2. To reduce gradient variance for these three algorithms, we also fit value functions, with the same neural network architecture as the policies, and employed generalized advantage estimation [27] (with and ). The exact experimental results are listed in Table 3. Means and standard deviations are computed over 50 trajectories. For the cartpole, mountain car, acrobot, and reacher, these statistics are further computed over 7 policies learned from random initializations.
FEM、GTAL 与我们的算法所用的环境交互量见表 2。为降低这三种算法的梯度方差,我们还用与策略相同架构的网络拟合值函数,并采用广义优势估计 [27](,)。精确实验结果见表 3。均值与标准差在 50 条轨迹上计算;对 cartpole、mountain car、acrobot 与 reacher,这些统计量还在 7 个随机初始化学到的策略上进一步汇总。
Task Training iterations State-action pairs per iteration Cartpole 300 5000 Mountain Car 300 5000 Acrobot 300 5000 Reacher 200 50000 HalfCheetah 500 50000 Hopper 500 50000 Walker 500 50000 Ant 500 50000 Humanoid 1500 50000
Task Training iterations State-action pairs per iteration Cartpole 300 5000 Mountain Car 300 5000 Acrobot 300 5000 Reacher 200 50000 HalfCheetah 500 50000 Hopper 500 50000 Walker 500 50000 Ant 500 50000 Humanoid 1500 50000
Table 2: Parameters for FEM, GTAL, and Algorithm 1
任务 训练迭代次数 每次迭代状态–动作对数 Cartpole 300 5000 Mountain Car 300 5000 Acrobot 300 5000 Reacher 200 50000 HalfCheetah 500 50000 Hopper 500 50000 Walker 500 50000 Ant 500 50000 Humanoid 1500 50000
表 2:FEM、GTAL 与算法 1 的参数
Task Dataset size Behavioral cloning FEM GTAL Ours Cartpole 1 4 7 10 Acrobot 1 4 7 10 Mountain Car 1 4 7 10 HalfCheetah 4 11 18 25 Hopper 4 11 18 25 Walker 4 11 18 25 Ant 4 11 18 25 Humanoid 80 160 240 Task Dataset size Behavioral cloning Ours () Ours () Ours () Reacher 4 11 18
Task Dataset size Behavioral cloning FEM GTAL Ours Cartpole 1 4 7 10 Acrobot 1 4 7 10 Mountain Car 1 4 7 10 HalfCheetah 4 11 18 25 Hopper 4 11 18 25 Walker 4 11 18 25 Ant 4 11 18 25 Humanoid 80 160 240 Task Dataset size Behavioral cloning Ours () Ours () Ours () Reacher 4 11 18
Table 3: Learned policy performance
任务 数据集大小 行为克隆 FEM GTAL 本文 Cartpole 1 4 7 10 Acrobot 1 4 7 10 Mountain Car 1 4 7 10 HalfCheetah 4 11 18 25 Hopper 4 11 18 25 Walker 4 11 18 25 Ant 4 11 18 25 Humanoid 80 160 240 任务 数据集大小 行为克隆 本文() 本文() 本文() Reacher 4 11 18
表 3:学到策略的性能
