# 行为克隆

行为克隆（BC）是一种模仿学习方法，它通过在专家状态-动作对数据集上进行监督学习来训练智能体的策略，使智能体复制专家在每种情境下的行为，而不需要任何奖励信号或环境交互。这是从演示中学习的最简单方法，应用于机器人操作、自动驾驶、游戏以及语言模型的监督微调。其输出是一个策略，通常是一个带有权重 \(\theta\) 的神经网络 \(\pi_{\theta}(a \mid s)\)，将观测映射到动作；理想情况下，它与专家的策略 \(\pi_{h}(a \mid s)\) 相匹配。<sup>[1](https://raw.githubusercontent.com/mlresearch/v235/main/assets/chen24as/chen24as.pdf)</sup><sup> • </sup><sup>[2](https://link.springer.com/article/10.1007/s10514-025-10237-0)</sup>

| 关键事实 | 详情 |
|---|---|
| 产出什么 | 一个策略 \(\pi_{\theta}(a \mid s)\)，通常是神经网络，通过在专家数据对上进行监督回归或分类训练<sup>[1](https://raw.githubusercontent.com/mlresearch/v235/main/assets/chen24as/chen24as.pdf)</sup> |
| 损失函数 | 离散动作使用负对数似然或交叉熵；连续动作使用均方误差<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> |
| 核心弱点 | 分布偏移导致的复合误差；时域 \(T\) 内的累积代价上界为 \(O(T^{2}\epsilon)\)<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup><sup> • </sup><sup>[4](https://people.cs.umass.edu/~sniekum/classes/LFH-S2/lectures/limitbc.pdf)</sup> |
| 主要交互式补救方法 | DAgger，以在线查询专家为代价将上界降至 \(O(T\epsilon)\)<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> |
| 典型机器人结果 | BC-RNN 在真实机器人 Lift 任务上达到 96.7% 成功率，Can 任务上达到 73.3%；原始 BC 比 BC-RNN 低约 5%–55%<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> |
| 数据规模 | 经验法则：简单任务 10–50 条演示，复杂移动操作最多 2,000–10,000 条<sup>[6](https://docs.signalbotics.com/robotics/il/bc/)</sup> |
| 语言模型案例 | 对大型语言模型进行监督微调即是行为克隆的一个实例，以上下文为状态、下一词元为动作<sup>[7](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> |

## 工作原理

行为克隆将模仿学习归约为监督学习：给定专家数据对 \((s^{*}_{i}, a^{*}_{i})\)，它求解 \(\hat{\pi} = \arg\min_{\pi \in \Pi} \sum_{i} \ell(\pi, s^{*}_{i}, a^{*}_{i})\)，常用选择为负对数似然 \(\ell = -\ln \pi(a^{*} \mid s^{*})\) 或平方损失 \(\ell = \|\pi(s) - a^{*}\|^{2}_{2}\)。<sup>[8](https://wensun.github.io/CS4789_data/Imitation_Learning_April_8_annotated.pdf)</sup> 等价地，目标函数为 \(L_{\mathrm{BC}}(\theta) = -\mathbb{E}_{(s,a) \sim D_{\mathrm{expert}}} [\log \pi_{\theta}(a \mid s)]\)，对离散动作实现为交叉熵，对连续动作实现为均方误差或负对数似然。<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> 一般形式写作 \(L_{\mathrm{BC}} = \mathbb{E}_{(s,a) \sim D,\, \hat{a} \sim \pi(s)} [d(a, \hat{a})]\)，其中 \(d\) 为距离函数如均方误差；p-范数或 f-散度（如 KL 散度）是取决于策略形式的替代选择。<sup>[1](https://raw.githubusercontent.com/mlresearch/v235/main/assets/chen24as/chen24as.pdf)</sup><sup> • </sup><sup>[9](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)</sup> 由于损失定义在演示数据上，行为克隆不需要指定奖励，也不需要与环境交互，这与逆强化学习和对抗模仿学习不同。<sup>[1](https://raw.githubusercontent.com/mlresearch/v235/main/assets/chen24as/chen24as.pdf)</sup>

问题在于，学习到的策略访问的是来自自身分布的状态，而非专家的分布。微小的不精确在推演过程中会累积，导致进入训练数据中代表性不足的状态，产生更差的决策，最终导致无效情境。<sup>[10](https://algorithmsbook.com/files/chapter-18.pdf)</sup> 在每步不一致率 \(\epsilon\) 下，累积任务代价为 \(O(T^{2}\epsilon)\)，且该二次上界是紧的：某些问题确实会产生二次遗憾。<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup><sup> • </sup><sup>[4](https://people.cs.umass.edu/~sniekum/classes/LFH-S2/lectures/limitbc.pdf)</sup> 一个相关的性能定理给出 \(V_{\pi^{*}} - V_{\hat{\pi}} \le \frac{2}{(1-\gamma)^{2}} \cdot \epsilon\)，即监督误差的二次放大。<sup>[8](https://wensun.github.io/CS4789_data/Imitation_Learning_April_8_annotated.pdf)</sup>

## 实施方法

演示数据来自遥操作或预训练专家策略。[Robomimic](https://www.edgepedia.org/zh/robomimic) 的协议说明了规模与评估方式：熟练人类数据集包含来自一名经验丰富遥操作员的 200 条演示，多人类数据集包含来自六名不同熟练度遥操作员的 300 条演示，每人 50 条。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> 低维智能体训练 \(N=2000\) 个轮次、每轮 \(M=100\) 个梯度步，图像智能体训练 \(N=600\) 个轮次、每轮 \(M=500\) 个梯度步，并用 50 次推演进行评估。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> 实际陷阱很具体：移除像素偏移随机化后，真实世界 Can 任务成功率从 73.3% 降至 26.7%，移除腕部摄像头后降至 43.3%。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> 作为粗略的数据预算，简单任务预计需要 10–50 条演示，抓取放置等操作任务需要 100–500 条，运动任务需要 500–2,000 条，复杂移动操作需要 2,000–10,000 条。<sup>[6](https://docs.signalbotics.com/robotics/il/bc/)</sup>

## 起源

一个有影响力的早期应用是 Dean Pomerleau（迪恩·波默洛）1991 年发表在《神经计算》上的论文，关于高效训练神经网络进行自主导航，开创了模仿驾驶领域的重要研究方向。<sup>[11](https://doi.org/10.1162/neco.1991.3.1.88)</sup> 他的 ALVINN 系统是一个反向传播网络，使用摄像机和成像激光测距仪驾驶 CMU Navlab（卡内基梅隆大学导航实验室）——一辆改装的雪佛兰厢式车——通过观察人类驾驶员来学习。<sup>[11](https://doi.org/10.1162/neco.1991.3.1.88)</sup><sup> • </sup><sup>[12](https://publications.ri.cmu.edu/storage/publications/pub_files/pub2/pomerleau_dean_1995_1/pomerleau_dean_1995_1.pdf)</sup> 在线训练的 ALVINN 网络后来在无人干预下以最高每小时 55 英里的速度行驶了最长 22 英里，每秒处理 15 帧图像。<sup>[12](https://publications.ri.cmu.edu/storage/publications/pub_files/pub2/pomerleau_dean_1995_1/pomerleau_dean_1995_1.pdf)</sup> 理论分析表明，朴素行为克隆会以随时域二次增长的遗憾上界累积误差，并提出将学习器策略从专家策略缓慢修改为学习策略的算法。<sup>[13](https://proceedings.mlr.press/v9/ross10a)</sup>

## 变体

**DAgger**（数据集聚合）是一种迭代的无遗憾算法，训练一个平稳确定性策略：它推演当前策略，让专家对访问到的状态进行标注，聚合新数据并重新训练。<sup>[14](https://proceedings.mlr.press/v15/ross11a)</sup><sup> • </sup><sup>[10](https://algorithmsbook.com/files/chapter-18.pdf)</sup> 这将累积代价从 \(O(T^{2}\epsilon)\) 改善为 \(O(T\epsilon)\)，代价是训练过程中需要反复查询专家。<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup>

**数据侧和目标侧的修正**包括噪声注入，即在数据收集时执行专家动作的过程中添加噪声，2025 年的一项分析表明这是在不太良性的环境中避免复合误差的实用工具；而动作分块——预测并开环执行动作序列——在良性环境中可证明地缓解复合误差，且无需修改专家数据。<sup>[15](https://arxiv.org/html/2507.09061v5)</sup> 在离线强化学习中，TD3+BC 简单地在 TD3 的策略更新中加入一个行为克隆项，使用归一化状态和一个超参数 \(\lambda\)，在大多数 [D4RL](https://www.edgepedia.org/zh/d4rl) 任务上匹配或超越 CQL 和 Fisher-BRC，计算成本不到它们的一半。<sup>[16](https://proceedings.neurips.cc/paper/2021/file/a8166da05c5a094f7dc03724b41886e5-Paper.pdf)</sup>

**序列建模策略**解决多模态性和长时域问题。BC-RNN 使用循环策略，在 Robomimic 数据集上全面超越原始 BC，增益随任务时域和数据异质性增长。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> 行为变换器（BeT）由 Shafiullah（沙菲乌拉）及其同事于 2022 年提出，通过 k 均值聚类将连续动作聚类为离散桶并同时学习一个残差动作校正器，从分布多模态数据中学习，同时仍遵循行为克隆的建模范式——对专家推演建模而不使用奖励。<sup>[17](https://papers.nips.cc/paper_files/paper/2022/file/90d17e882adbdda42349db6f50123817-Paper-Conference.pdf)</sup><sup> • </sup><sup>[18](https://doi.org/10.48550/arxiv.2206.11251)</sup> 隐式行为克隆训练一个能量函数 \(E(s,a)\) 并通过最小化它来寻找动作，对多模态分布具有鲁棒性但推理成本更高。<sup>[19](https://www.roboticscenter.ai/learn/robotics-library/imitation-learning-fundamentals)</sup><sup> • </sup><sup>[20](https://doi.org/10.48550/arxiv.2109.00137)</sup> [扩散策略](https://www.edgepedia.org/zh/diffusion-policy)由 Chi（奇）及其同事于 2023 年提出，通过动作空间上的条件去噪扩散过程生成行为，在 K 次去噪迭代中以视觉观测为条件推断动作得分梯度，而非直接输出动作。<sup>[21](https://doi.org/10.48550/arxiv.2303.04137)</sup>

## 应用

Robomimic 在六个任务套件（Lift、Can、Square、Transport、ToolHang、NutAssembly）的五个仿真和三个真实世界多阶段操作任务上评估了六种离线算法（BC、BC-RNN、HBC、BCQ、CQL、IRIS），每个任务包含 200 条熟练人类、300 条多人类和 1,000 条机器生成的演示数据。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup><sup> • </sup><sup>[22](https://www.roboticscenter.ai/datasets/robomimic)</sup> 在熟练人类数据上，BC-RNN 在每个任务上匹配或超越了所有测试的离线强化学习方法；只有在机器生成数据上 CQL 和 IRIS 才胜出。<sup>[22](https://www.roboticscenter.ai/datasets/robomimic)</sup> 使用 BC-RNN 训练且未经超参数调优的真实世界 Franka 策略在 30 次推演中于 Lift 任务达到 96.7% 成功率、Can 任务 73.3%、Tool Hang 任务 3.3%。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> BC-RNN 与 BC 之间的差距随时域增长，[Transport](https://www.edgepedia.org/zh/transport)（PH）上约 55% 而 Square（PH）上约 5%；也随数据异质性增长，Square（MH）上约 25% 而 Square（PH）上约 5%。<sup>[5](https://ar5iv.labs.arxiv.org/html/2108.03298)</sup> 在 D4RL 上，其归一化分数将 0 映射为随机智能体回报、100 映射为专家性能，Adroit 人类数据集每个任务包含 25 条轨迹。<sup>[23](https://doi.org/10.48550/arxiv.2004.07219)</sup> 在机器人之外，语言模型的监督微调本质上就是行为克隆：上下文是状态，下一词元是动作，精选回复是演示，因此分布偏移可能在长文本生成中累积。<sup>[7](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup>

## 局限性与替代方案

行为克隆的失败模式已被充分刻画。纯反应式情境-动作克隆缺乏鲁棒性，在训练数据经验范围之外的情境中可能完全失败。<sup>[24](https://cgi.cse.unsw.edu.au/%7Eclaude/papers/MI15.pdf)</sup> 在多模态演示下，单个行为克隆网络会平均有效模态并预测出无效结果，扩散策略和 IBC 通过表示动作上的分布来避免这一问题。<sup>[19](https://www.roboticscenter.ai/learn/robotics-library/imitation-learning-fundamentals)</sup><sup> • </sup><sup>[7](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> 因果混淆是一种反直觉的失败模式，即获取更多信息（如观测中的前一动作）反而导致更差的性能。<sup>[25](https://proceedings.neurips.cc/paper/2019/file/947018640bf36a2bb609d3557a285329-Paper.pdf)</sup> 次优或有限的专家限制了性能上限，行为克隆在少量演示下也容易过拟合。

在概念上，行为克隆直接拟合策略；逆强化学习则推断一个使演示近似最优的奖励函数，GAIL 训练一个判别器区分学习者和专家轨迹，并用其输出作为强化学习的奖励。<sup>[26](https://underactuated.mit.edu/imitation.html)</sup><sup> • </sup><sup>[7](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)</sup> 一张对比表将行为克隆描述为仅使用离线专家数据且不处理分布偏移，DAgger 需要在线专家标注，GAIL 隐式处理分布偏移且不需要在线标注。<sup>[3](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/bc-dagger)</sup> 与离线强化学习相比，选择并不显然：理论和实验表明，在噪声足够大的次优数据上训练的离线强化学习可以超越在专家数据上训练的行为克隆，尤其是在长时域问题上，保守离线强化学习在覆盖条件下达到 \(\tilde{O}(\sqrt{H})\) 次优性，且经验差距随时域增长。<sup>[27](https://ar5iv.labs.arxiv.org/html/2204.05618)</sup> 实用建议是：在拥有大规模多样化专家数据集、短时域任务、确定性专家或安全关键的离线学习场景中优先使用行为克隆；而在长时域任务、数据有限或随机任务中避免使用。<sup>[6](https://docs.signalbotics.com/robotics/il/bc/)</sup>

## References

1. [Diffusion Model-Augmented Behavioral Cloning](https://raw.githubusercontent.com/mlresearch/v235/main/assets/chen24as/chen24as.pdf)
2. [Towards balanced behavior cloning from imbalanced datasets](https://link.springer.com/article/10.1007/s10514-025-10237-0)
3. [11.1 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)
4. [Limitations of Behavior Cloning (lecture notes)](https://people.cs.umass.edu/~sniekum/classes/LFH-S2/lectures/limitbc.pdf)
5. [What Matters in Learning from Offline Human Demonstrations for Robot Manipulation (Robomimic)](https://ar5iv.labs.arxiv.org/html/2108.03298)
6. [Behavioral Cloning - Signalbotics Documentation](https://docs.signalbotics.com/robotics/il/bc/)
7. [Learning from Demonstrations – Dive into Deep Learning](https://d2l.smola.org/chapter_reinforcement-learning/imitation.html)
8. [Introduction to Imitation Learning & the Behavior Cloning Algorithm (Wen Sun, Cornell CS4789 lecture notes)](https://wensun.github.io/CS4789_data/Imitation_Learning_April_8_annotated.pdf)
9. [Imitation Learning (Stanford CS237B lecture 12)](https://web.stanford.edu/class/cs237b/pdfs/lecture/cs237b_lecture_12.pdf)
10. [Imitation Learning, chapter 18 (Algorithms for Decision Making, Kochenderfer, Wheeler & Wray)](https://algorithmsbook.com/files/chapter-18.pdf)
11. [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)
12. [Neural Network Vision for Robot Driving](https://publications.ri.cmu.edu/storage/publications/pub_files/pub2/pomerleau_dean_1995_1/pomerleau_dean_1995_1.pdf)
13. [Efficient Reductions for Imitation Learning](https://proceedings.mlr.press/v9/ross10a)
14. [A Reduction of Imitation Learning and Structured Prediction to No-Regret Online Learning](https://proceedings.mlr.press/v15/ross11a)
15. [Action Chunking and Exploratory Data Collection Yield Exponential Improvements in Behavior Cloning for Continuous Control](https://arxiv.org/html/2507.09061v5)
16. [A Minimalist Approach to Offline Reinforcement Learning (TD3+BC)](https://proceedings.neurips.cc/paper/2021/file/a8166da05c5a094f7dc03724b41886e5-Paper.pdf)
17. [Behavior Transformers: Cloning modes with one stone (BeT, NeurIPS 2022)](https://papers.nips.cc/paper_files/paper/2022/file/90d17e882adbdda42349db6f50123817-Paper-Conference.pdf)
18. [Shafiullah, Nur Muhammad Mahi and colleagues (2022). Behavior Transformers: Cloning $k$ modes with one stone. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2206.11251)
19. [Imitation Learning for Robots: From Behavior Cloning to Diffusion Policies (SVRC)](https://www.roboticscenter.ai/learn/robotics-library/imitation-learning-fundamentals)
20. [Florence, Pete and colleagues (2021). Implicit Behavioral Cloning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2109.00137)
21. [Chi, Cheng and colleagues (2023). Diffusion Policy: Visuomotor Policy Learning via Action Diffusion. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2303.04137)
22. [Robomimic: Canonical Imitation Learning Benchmark (practitioner guide)](https://www.roboticscenter.ai/datasets/robomimic)
23. [Fu, Justin and colleagues (2020). D4RL: Datasets for Deep Data-Driven Reinforcement Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2004.07219)
24. [A Framework for Behavioural Cloning](https://cgi.cse.unsw.edu.au/%7Eclaude/papers/MI15.pdf)
25. [Causal Confusion in Imitation Learning](https://proceedings.neurips.cc/paper/2019/file/947018640bf36a2bb609d3557a285329-Paper.pdf)
26. [Ch. 21 - Imitation Learning (Russ Tedrake, Underactuated Robotics)](https://underactuated.mit.edu/imitation.html)
27. [When Should We Prefer Offline Reinforcement Learning Over Behavioral Cloning?](https://ar5iv.labs.arxiv.org/html/2204.05618)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026; Oct 25, 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/behavior-cloning

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