# 行为克隆

行为克隆（Behavioral cloning，BC）是一种模仿学习方法，它通过监督学习训练智能体模仿专家：将策略 \( \pi_{\theta}(a \mid s) \) 拟合到专家状态-动作对的数据集上，把每个观测映射为专家所采取的动作。由于拟合使用的是普通监督损失，BC 在训练时既不需要奖励函数，也不需要转移模型，更不需要与环境交互；学习到的策略随后离线部署。<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup><sup> • </sup><sup>[2](https://rlbook.adzc.ai/imitation_learning.html)</sup> 输出的策略形式由实践者自行选择，从情境-动作规则集合<sup>[3](https://cgi.cse.unsw.edu.au/%7Eclaude/papers/MI15.pdf)</sup>到权重为 \( \theta \) 的神经网络<sup>[4](https://link.springer.com/article/10.1007/s10514-025-10237-0)</sup>皆可。

| 关键事实 | 详情 |
|---|---|
| BC 产出什么 | 一个策略 \( \pi_{\theta}(a \mid s) \)，通常是神经网络，或基于规则的情境-动作对<sup>[4](https://link.springer.com/article/10.1007/s10514-025-10237-0)</sup><sup> • </sup><sup>[3](https://cgi.cse.unsw.edu.au/%7Eclaude/papers/MI15.pdf)</sup> |
| 训练损失 | \( L_{\mathrm{BC}}(\theta) = -\mathbb{E}_{(s,a) \sim \mathcal{D}_{\mathrm{expert}}} [\log \pi_{\theta}(a \mid s)] \)；离散动作用交叉熵，连续动作用均方误差<sup>[5](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> |
| 所需数据 | 仅需专家状态-动作对；无需奖励、无需转移模型、无需环境交互<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> |
| 主要弱点 | 误差累积：在时域 \( T \) 内，单步误差为 \( \varepsilon \) 时，回报缺口为 \( \Theta(\varepsilon T^{2}) \)<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> |
| 交互式修正 | DAgger 将界改进至 \( O(T\varepsilon) \)，代价是反复在线查询专家<sup>[5](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> |
| 说明性差距 | FrozenLake：在 96 个示范对上零错误的克隆策略成功率为 17.5%，而专家为 73.4%<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> |
| 当今规模 | 开放遥操作数据集如 ABC-130K 涵盖 3,500 小时、195 个任务、超过 130,000 个回合<sup>[6](https://ar5iv.labs.arxiv.org/html/2606.27375)</sup> |

## 工作原理

BC 将模仿视为预测问题而非控制问题。以 \( \theta \) 参数化的随机策略 \( \pi_{\theta} \) 经过训练，以最大化状态-动作对数据集 \( \mathcal{D} \) 中专家动作的似然。<sup>[7](https://algorithmsbook.com/files/chapter-18.pdf)</sup> 目标函数为

\[ L_{\mathrm{BC}}(\theta) = -\mathbb{E}_{(s,a) \sim \mathcal{D}_{\mathrm{expert}}} \left[ \log \pi_{\theta}(a \mid s) \right], \]

离散动作用交叉熵，连续动作用均方误差或负对数似然。<sup>[5](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> 最大化 \( \sum_{i} \log \pi_{\theta}(a_{i} \mid s_{i}) \) 等同于最小化交叉熵<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup>，同一目标也可写为最小化专家策略与学习策略在专家访问状态处的 KL 散度。<sup>[8](https://ar5iv.labs.arxiv.org/html/1911.07027)</sup> 一般形式为 \( \hat{\pi}^{*} = \arg\min_{\pi} \sum_{\xi} L(\pi(x), \pi^{*}(x)) \)，其中 \( L \) 是 p-范数或 KL 等 f-散度之类的代价。<sup>[9](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)</sup> 对于具有全状态反馈的确定性策略，BC 就是普通回归，

\[ \pi^{\mathrm{BC}}(s) = \arg\min_{\pi} \mathbb{E}_{s_{t}, a_{t} \sim \mathcal{D}} \left[ (\pi(s_{t}) - a_{t})^{2} \right]. \]

BC 仅使用访问过的状态和专家动作，因此既不需要记录的奖励，也不需要转移模型<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup>，并且受益于平稳数据分布上的固定目标。<sup>[10](https://proceedings.mlr.press/v222/arulkumaran24a/arulkumaran24a.pdf)</sup>

## 实施方法

流程分两步。首先，从专家策略收集轨迹数据集 \( \mathcal{D} = (s^{n}, a^{n})_{n=1}^{N} \)；对于 \( M \) 条时域为 \( H \) 的轨迹，这产生 \( N = M \cdot H \) 个状态-动作对。其次，通过经验风险最小化拟合策略，\( \widetilde{\pi} = \arg\min_{\pi} \sum_{n=0}^{N-1} \mathrm{loss}(\pi(s^{n}), a^{n}) \)，等价于最小化负对数似然。<sup>[2](https://rlbook.adzc.ai/imitation_learning.html)</sup> 对于神经网络等可微策略，似然通过梯度上升优化，使用步长 \( \alpha \)、迭代次数 \( k_{\mathrm{max}} \) 和梯度 \( \nabla \log \pi \)<sup>[7](https://algorithmsbook.com/files/chapter-18.pdf)</sup>；策略实例化为权重为 \( \theta \) 的神经网络。<sup>[4](https://link.springer.com/article/10.1007/s10514-025-10237-0)</sup> 纯 BC 是离线的：完全不需要在环境中行动。<sup>[2](https://rlbook.adzc.ai/imitation_learning.html)</sup> [数据质量](https://www.edgepedia.org/zh/data-quality)很重要，因为示范者并不总是按其意图行事；在一项人机交互研究中，被要求在仿真中示范良好驾驶的人事后评判自己的行为过于激进。<sup>[9](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)</sup>

## 起源

该方法的名字在一篇综述中归功于贝恩和萨穆特，1996 年<sup>[11](https://arxiv.org/pdf/1811.06711)</sup>，而其他来源则归功于波默洛的自主导航工作。<sup>[7](https://algorithmsbook.com/files/chapter-18.pdf)</sup><sup> • </sup><sup>[12](https://link.springer.com/article/10.1007/s10994-023-06392-z)</sup> 开创性论文《自主导航中人工神经网络的高效训练》（“Efficient Training of Artificial Neural Networks for Autonomous Navigation”）由迪恩·A·波默洛发表于 1991 年的《神经计算》（Neural Computation）。<sup>[13](https://doi.org/10.1162/neco.1991.3.1.88)</sup> 最早的克隆是基于规则的：对熟练人类操作员表现的轨迹运行归纳算法，生成将过程当前状态映射到动作的情境-动作规则，这种方法在多个领域构建了控制系统。<sup>[3](https://cgi.cse.unsw.edu.au/%7Eclaude/papers/MI15.pdf)</sup> 兴趣的驱动力来自自动驾驶，那里专家驾驶数据丰富，而“良好驾驶”的奖励函数难以表达。<sup>[2](https://rlbook.adzc.ai/imitation_learning.html)</sup>

## 变体

人类示范通常不唯一：同一状态下多个动作可能都合理，因此 BC 受益于建模完整的动作条件分布而非单一输出。<sup>[14](https://underactuated.mit.edu/imitation.html)</sup> MSE 回归学习动作分布的“平均”，这会使估计偏向频繁动作，或在模态之间产生分布外动作。<sup>[15](https://doi.org/10.48550/arxiv.2301.10677)</sup> 变体通过混合密度网络、条件变分自编码器和扩散模型来解决这个问题。<sup>[14](https://underactuated.mit.edu/imitation.html)</sup> 《用扩散模型模仿人类行为》（“Imitating Human Behaviour with Diffusion Models”，皮尔斯等人，2023 年，arXiv）使用去噪扩散概率模型表示 \( p(a \mid o) \)，在模拟机器人基准上优于行为 Transformer（Behaviour Transformers），并扩展到人类《[反恐精英：全球攻势](https://www.edgepedia.org/zh/counter-strike-global-offensive)》（Counter-Strike: Global Offensive）游戏玩法。<sup>[15](https://doi.org/10.48550/arxiv.2301.10677)</sup> 《[扩散策略](https://www.edgepedia.org/zh/diffusion-policy)》（“Diffusion Policy”）由程驰等人于 2024 年发表在《国际机器人研究杂志》（The International Journal of Robotics Research），将动作扩散应用于视觉运动策略学习<sup>[16](https://doi.org/10.1177/02783649241273668)</sup>，而《扩散模型增强的行为克隆》（“Diffusion Model-Augmented Behavioral Cloning”）建模联合分布 \( p(s, a) \) 而非条件分布。<sup>[17](https://proceedings.mlr.press/v235/chen24as.html)</sup> 2024 年 NeurIPS 的一项分析表明，对数损失 BC（LogLossBC）在密集奖励、受控的 \( \log \lvert \Pi \rvert \) 和可实现性条件下，对确定性专家可以实现时域线性 \( O(H) \) 的样本复杂度，这与传统的 \( O(T^{2}\varepsilon) \) 认识相反；若不对策略类做进一步假设，DAgger 等在线模仿学习无法超越离线 LogLossBC。<sup>[18](https://proceedings.neurips.cc/paper_files/paper/2024/file/da84e39ae51fd26bb5110d9659c06e13-Paper-Conference.pdf)</sup> BC 也已扩展到通过潜在表示从视频中学习，放宽了必须记录动作的要求。<sup>[19](https://proceedings.neurips.cc/paper_files/paper/2025/file/e67a667df97d44fa43ffe8d179b44dd8-Paper-Conference.pdf)</sup> 在最大规模上，包括 RT-2、Octo、\( \pi_{0} \) 和 OpenVLA 在内的机器人基础模型被描述为大规模 BC 系统，拥有数百万示范和预训练视觉-语言骨干；\( \pi_{0} \) 和 Octo 使用扩散或流匹配动作头，而 RT-2 和 OpenVLA 自回归地生成标记化动作。<sup>[20](https://www.engineeringmaxxing.com/micro/lessons/imitation-learning.html)</sup> 大语言模型的[监督微调](https://www.edgepedia.org/zh/supervised-fine-tuning)使用相同的条件似然目标，以下一个标记为动作。<sup>[5](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup>

## 应用

[卡内基梅隆大学](https://www.edgepedia.org/zh/carnegie-mellon-university)（Carnegie Mellon University）的早期自动驾驶网络 ALVINN 将 30×32 的输入图像通过一个含五个单元的隐藏层映射到 30 个输出；然而，著名的横贯全国驾驶是由 [Navlab](https://www.edgepedia.org/zh/navlab) 5 使用 RALPH 系统完成的，该系统在大部分（虽非全部）路线上自主转向。<sup>[11](https://arxiv.org/pdf/1811.06711)</sup> 后来的应用包括四旋翼飞行器飞行、[自动驾驶汽车](https://www.edgepedia.org/zh/self-driving-car)和游戏<sup>[12](https://link.springer.com/article/10.1007/s10994-023-06392-z)</sup>、打乒乓球的机器人，以及下围棋的程序——其中通过行为克隆策略进行模仿先于强化学习微调。<sup>[21](https://rl.aalto.fi/publication/2018algorithmic/2018algorithmic.pdf)</sup> 模仿也可能比试错便宜得多：一项被引用的结果证明，通过模仿而非强化学习来学习任务，样本复杂度可能呈指数级下降。<sup>[21](https://rl.aalto.fi/publication/2018algorithmic/2018algorithmic.pdf)</sup> 在操作领域，ABC-130K 语料库是最大的开放遥操作数据集，涵盖 195 个任务的拾取放置、交接、工具使用、装配和灵巧行为，包含 3,500 小时的真实世界交互和超过 130,000 个回合。<sup>[6](https://ar5iv.labs.arxiv.org/html/2606.27375)</sup>

## 局限性与替代方案

BC 在专家访问的状态上训练，但在测试时作用于自身策略访问的状态。小的不准确在推演过程中累积，导致训练数据中代表性不足的状态，从而产生更差的决策，最终进入无效或未见过的情况。<sup>[7](https://algorithmsbook.com/files/chapter-18.pdf)</sup><sup> • </sup><sup>[9](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)</sup> DAgger 论文量化了这一效应：在专家状态分布下错误概率为 \( \varepsilon \) 的分类器，在其自身诱导的分布下，\( T \) 步内的期望错误可达 \( O(\varepsilon T^{2}) \)<sup>[22](https://users.cs.utah.edu/~dsbrown/readings/dagger.pdf)</sup>，克隆策略的期望回报可能比专家低 \( \Theta(\varepsilon T^{2}) \)；在学习者自身分布下测量，界为 \( O(\varepsilon T) \)。<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> 在 FrozenLake 上，在其 96 个示范对上零错误的克隆策略仅以 17.5% 的回合成功率达到目标，而专家为 73.4%。<sup>[1](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> BC 的已知失败模式包括泛化差和从错误中恢复差<sup>[23](https://imitation.readthedocs.io/en/stable/algorithms/bc.html)</sup>、示范数量少时过拟合、在非专家数据上次优，以及训练与测试条件之间的状态分布偏移。<sup>[12](https://link.springer.com/article/10.1007/s10994-023-06392-z)</sup> 多模态动作分布是另一种失败模式：MSE 最优策略预测各模态的平均值，这可能是无效动作。<sup>[15](https://doi.org/10.48550/arxiv.2301.10677)</sup>

DAgger（数据集聚合）通过在学习者自身分布上收集数据来应对协变量偏移（训练和测试数据来自不同分布）。每次迭代推演当前策略，向专家查询其在那些访问状态上会采取的动作，将新的状态-动作对聚合到数据集中并重新训练。<sup>[9](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)</sup> 这需要对任意状态查询专家，以及用于推演的环境访问，使 DAgger 成为在线算法，不同于离线 BC；其性能保证在 \( \widetilde{O}(H^{2}) \) 次迭代内将价值差距界定为 \( H\varepsilon \)。<sup>[2](https://rlbook.adzc.ai/imitation_learning.html)</sup> 累积代价从 BC 的 \( O(T^{2}\varepsilon) \) 改善到 \( O(T\varepsilon) \)，代价是训练期间必须反复查询专家。<sup>[5](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> 推演策略通常是混合的，\( \pi_{i} = \beta_{i} \pi^{*} + (1 - \beta_{i}) \hat{\pi}_{i} \)，其中 \( \beta_{i} = p^{i-1} \) 呈指数衰减。<sup>[22](https://users.cs.utah.edu/~dsbrown/readings/dagger.pdf)</sup> 主要替代方案以不同方式权衡数据需求<sup>[5](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup>：

| 方法 | 使用的数据 | 解决分布偏移 | 需要在线专家 |
|---|---|---|---|
| BC | 仅离线专家数据 | 否 | 否 |
| DAgger | 专家数据加策略访问状态 | 是 | 是（关键限制） |
| GAIL | 专家数据加策略推演 | 隐式 | 否（仅需状态-动作对） |

逆强化学习采取另一主要模仿途径：不直接复制行为，而是学习专家的隐藏目标，历史上被表述为逆最优控制或逆强化学习，具有最大间隔、贝叶斯和最大熵假设族。<sup>[21](https://rl.aalto.fi/publication/2018algorithmic/2018algorithmic.pdf)</sup><sup> • </sup><sup>[2](https://rlbook.adzc.ai/imitation_learning.html)</sup> [离线强化学习](https://www.edgepedia.org/zh/offline-reinforcement-learning)则从另一方向相关：许多离线 RL 算法将学习策略偏向行为克隆策略。<sup>[12](https://link.springer.com/article/10.1007/s10994-023-06392-z)</sup> 有了足够的轨迹，BC 成为有竞争力的基线，交互式变体 AdRIL 表现与 GAIL 相似，同时实现和调参更简单。<sup>[10](https://proceedings.mlr.press/v222/arulkumaran24a/arulkumaran24a.pdf)</sup>

## References

1. [Learning from Demonstrations – Dive into Deep Learning](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)
2. [Imitation Learning – An Introduction to Reinforcement Learning](https://rlbook.adzc.ai/imitation_learning.html)
3. [A Framework for Behavioural Cloning (Sammut et al.)](https://cgi.cse.unsw.edu.au/%7Eclaude/papers/MI15.pdf)
4. [Towards balanced behavior cloning from imbalanced datasets (Autonomous Robots, 2025)](https://link.springer.com/article/10.1007/s10514-025-10237-0)
5. [Behavior Cloning and Interactive Imitation Learning | Hands-on Modern RL](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)
6. [Scalable Behavior Cloning with Open Data, Training, and Evaluation](https://ar5iv.labs.arxiv.org/html/2606.27375)
7. [Algorithms for Decision Making, Chapter 18: Imitation Learning](https://algorithmsbook.com/files/chapter-18.pdf)
8. [On Value Discrepancy of Imitation Learning (arXiv:1911.07027)](https://ar5iv.labs.arxiv.org/html/1911.07027)
9. [Stanford CS237B Lecture 12: Imitation Learning](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)
10. [A Pragmatic Look at Deep Imitation Learning (PMLR v222)](https://proceedings.mlr.press/v222/arulkumaran24a/arulkumaran24a.pdf)
11. [A Survey on Imitation Learning (Zhu et al., arXiv:1811.06711)](https://arxiv.org/pdf/1811.06711)
12. [Model-based trajectory stitching for improved behavioural cloning and its applications (Machine Learning, Springer)](https://link.springer.com/article/10.1007/s10994-023-06392-z)
13. [Dean A. Pomerleau (1991). Efficient Training of Artificial Neural Networks for Autonomous Navigation. Neural Computation.](https://doi.org/10.1162/neco.1991.3.1.88)
14. [Ch. 21 - Imitation Learning (Underactuated Robotics, MIT)](https://underactuated.mit.edu/imitation.html)
15. [Pearce, Tim and colleagues (2023). Imitating Human Behaviour with Diffusion Models. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2301.10677)
16. [Cheng Chi and colleagues (2024). Diffusion policy: Visuomotor policy learning via action diffusion. The International Journal of Robotics Research.](https://doi.org/10.1177/02783649241273668)
17. [Diffusion Model-Augmented Behavioral Cloning (DBC, PMLR v235, 2024)](https://proceedings.mlr.press/v235/chen24as.html)
18. [Is Behavior Cloning All You Need? Understanding Horizon in Imitation Learning (NeurIPS 2024)](https://proceedings.neurips.cc/paper_files/paper/2024/file/da84e39ae51fd26bb5110d9659c06e13-Paper-Conference.pdf)
19. [Videos are Sample-Efficient Supervisions: Behavior Cloning from Videos via Latent Representations (NeurIPS 2025)](https://proceedings.neurips.cc/paper_files/paper/2025/file/e67a667df97d44fa43ffe8d179b44dd8-Paper-Conference.pdf)
20. [CS224R, Imitation Learning: The Complete Guide](https://www.engineeringmaxxing.com/micro/lessons/imitation-learning.html)
21. [An Algorithmic Perspective on Imitation Learning](https://rl.aalto.fi/publication/2018algorithmic/2018algorithmic.pdf)
22. [A Reduction of Imitation Learning and Structured Prediction to No-Regret Online Learning (DAgger, Ross, Gordon & Bagnell)](https://users.cs.utah.edu/~dsbrown/readings/dagger.pdf)
23. [BC, imitation library documentation](https://imitation.readthedocs.io/en/stable/algorithms/bc.html)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/behavioral-cloning

English original: https://www.edgepedia.org/behavioral-cloning
