# 模型无关元学习

模型无关元学习（Model-agnostic meta-learning，MAML）是一种元学习算法，它训练模型的初始参数，使得在新任务的小量数据上经过几步梯度下降，模型就能快速适应该任务。实际上，它训练模型使其易于微调，并且适用于任何通过梯度下降训练的模型，包括监督学习或强化学习损失下的全连接网络、卷积网络和循环网络。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup>

| 关键事实 | 详情 |
|---|---|
| 训练的输出 | 一组初始参数θ，从该参数出发经过一步或几步梯度更新即可达到良好的任务特定性能<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> |
| 提出者 | 切尔西·芬恩、彼得·阿贝尔和谢尔盖·莱文，ICML 2017（第70卷，第1126–1135页）<sup>[2](https://dl.acm.org/doi/10.5555/3305381.3305498)</sup> |
| 核心更新 | 内循环 θ′ᵢ = θ − α∇θL_Tᵢ(f_θ)；外循环 θ ← θ − β∇θ Σ L_Tᵢ(f_θ′ᵢ)<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> |
| MiniImageNet 5-way | 48.70 ± 1.84%（1-shot）和 63.11 ± 0.92%（5-shot）<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> |
| 一阶变体 | FOMAML 去掉了 Hessian 向量积，速度约提升33%，精度几乎相同<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> |
| 内存限制 | MAML 的内存随内梯度步数线性增长，在 20-way 5-shot Omniglot 上约16步即填满12 GB GPU<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)</sup> |
| 现状 | 在少样本基准上已不再是最优方法，被 LEO 和 MetaOptNet 超越<sup>[4](https://link.springer.com/article/10.1007/s10994-022-06210-y)</sup> |

## 工作原理

MAML 由两个嵌套阶段组成。内循环在采样任务的小数据集上执行几步梯度更新，产生适应后的参数；外循环更新初始化，使得在每个任务上测得的适应后性能较高。在单步形式下，元目标为 \( \min_{\theta} \; F(\theta) := \mathbb{E}_{i}[ f_{i}(\theta - \alpha \nabla f_{i}(\theta)) ] \)，即寻找一个初始化，使得在新任务上经过一步梯度更新后表现良好。<sup>[5](https://proceedings.mlr.press/v108/fallah20a/fallah20a.pdf)</sup>

由于外目标依赖于内梯度步，元梯度是“梯度的梯度”。计算它需要对模型额外进行一次反向传播以获得 Hessian 向量积，[TensorFlow](https://www.edgepedia.org/zh/tensorflow) 等标准深度学习库支持这一操作。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> Reptile 论文的泰勒级数分析解释了这类初始化为何有效：SGD 本身产生一个二阶项，调整初始权重以最大化同一任务不同小批量梯度之间的点积，促使梯度在任务数据上具有泛化性。<sup>[6](https://arxiv.org/pdf/1803.02999)</sup>

## 实施方法

每次元迭代采样一批任务。对每个任务，内阶段从当前初始化θ出发，以预定义的步长α运行几步（随机）梯度下降；外阶段则利用适应后的参数，以元学习率β在所有采样任务上更新θ。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup><sup> • </sup><sup>[7](https://par.nsf.gov/servlets/purl/10339904)</sup> 两个学习率角色不同：α控制任务特定的适应，β控制跨任务的元学习。<sup>[8](https://www.arxiv.org/pdf/2602.19837)</sup>

已报告的设置展示了所涉及的范围。Omniglot 5-way 模型使用一步梯度更新，\( \alpha = 0.4 \)，元批量大小为32个任务；MiniImageNet 模型使用5步训练，\( \alpha = 0.01 \)，10步评估，在单块 NVIDIA Pascal Titan X GPU 上迭代60000次。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> 收敛理论增加了一个约束：对于具有 N 步内循环更新的多步 MAML，为保证在一般非凸设定下的收敛性，内步长必须选择为与 N 成反比（量级为 \( 1/(NL) \)）。<sup>[7](https://par.nsf.gov/servlets/purl/10339904)</sup> 性能和稳定性高度依赖于α和β，实践中通常需要穷举网格搜索。<sup>[9](https://arxiv.org/abs/1905.07435)</sup>

## 起源

MAML 由[切尔西·芬恩](https://www.edgepedia.org/zh/chelsea-finn)、彼得·阿贝尔和[谢尔盖·莱文](https://www.edgepedia.org/zh/sergey-levine)在《用于深度网络快速适应的模型无关元学习》一文中提出，该文于2017年3月发布到 arXiv，并在 ICML 2017 会议论文集第70卷第1126–1135页发表。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup><sup> • </sup><sup>[2](https://dl.acm.org/doi/10.5555/3305381.3305498)</sup> 该论文建立在其引用的早期工作之上，包括 马尔钦·安德里霍维奇及其同事的《通过梯度下降学会用梯度下降学习》（2016），以及 奥里奥尔·维尼亚尔斯及其同事的匹配网络（2016）。<sup>[10](https://doi.org/10.48550/arxiv.1606.04474)</sup><sup> • </sup><sup>[11](https://doi.org/10.48550/arxiv.1606.04080)</sup>

## 变体

**一阶近似**去掉了二阶导数。FOMAML 与 MAML 一同提出，通过忽略二阶导数项，去掉了 Hessian 向量积，在网络计算中带来约33%的加速。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup><sup> • </sup><sup>[6](https://arxiv.org/pdf/1803.02999)</sup> 它假设二阶梯度因子为单位矩阵，这在时间和内存上提高了效率，性能与二阶 MAML 大致相同，但由于忽略了雅可比矩阵，它并未计算精确的元梯度。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)</sup><sup> • </sup><sup>[12](https://link.springer.com/article/10.1007/s10994-023-06387-w)</sup> Reptile 反复采样一个任务，在其上训练，并通过 \( \phi \leftarrow \phi + \epsilon (W - \phi) \) 将初始化移向训练后的权重，不通过优化过程进行微分。<sup>[6](https://arxiv.org/pdf/1803.02999)</sup> 在 Omniglot 和 Mini-ImageNet 上，MAML、FOMAML 和 Reptile 表现非常相似，Reptile 在 Mini-ImageNet 上略好（5-way 1-shot 为 49.97 ± 0.32% 对 48.70 ± 1.84%），在 Omniglot 上略差。<sup>[6](https://arxiv.org/pdf/1803.02999)</sup><sup> • </sup><sup>[3](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)</sup>

**无 Hessian 和隐式方法**在避免二阶计算的同时保持精度。HF-MAML 在每次迭代 O(d) 的成本下，无需二阶信息即可恢复 MAML 的收敛界，而 FO-MAML 具有相同的 O(d) 成本但无法达到任意小的优化误差。<sup>[5](https://proceedings.mlr.press/v108/fallah20a/fallah20a.pdf)</sup> iMAML 通过隐式微分计算元梯度，仅依赖于内循环的解而非优化路径，内存占用不超过单次内循环梯度。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)</sup> ES-MAML 提供了另一种无 Hessian 的方法。<sup>[13](https://doi.org/10.48550/arxiv.1910.01215)</sup>

**概率和自适应变体**重新解释或扩展了目标。LLAMA 将 MAML 重新表述为分层贝叶斯模型中的概率推断，将初始化解释为任务特定参数先验的参数，将适应解释为 MAP 推断，并用拉普拉斯近似替代点估计。<sup>[14](https://cocosci.princeton.edu/papers/gradient-based_meta-learning.pdf)</sup> BMAML 将基于梯度的元学习与多粒子上的 Stein 变分梯度下降相结合，当使用单个粒子时退化为 MAML；其追逐者损失是一种一阶元更新，用于防止元级过拟合。<sup>[15](https://proceedings.neurips.cc/paper/2018/file/e1021d43911ca2c1845910d84f40aeae-Paper.pdf)</sup> PLATIPUS（芬恩、徐和莱文，2018）对 MAML 本身增加了概率处理。<sup>[16](https://doi.org/10.48550/arxiv.1806.02817)</sup> Alpha MAML 通过超梯度下降在线调整α和β，几乎不增加额外梯度计算；在标准 MAML 于400次迭代内未能达到损失阈值的案例中，它通常能在不到50次迭代内达到阈值。Sharp-MAML（莫明·阿巴斯及其同事，2022）在元目标中加入了锐度感知。<sup>[17](https://doi.org/10.48550/arxiv.2206.03996)</sup> 多步变体包括 ANIL 和 BOIL。<sup>[7](https://par.nsf.gov/servlets/purl/10339904)</sup>

## 应用

原始论文展示了三种设定。在少样本分类上，MAML 在 5-way MiniImageNet 上达到 48.70 ± 1.84%（1-shot）和 63.11 ± 0.92%（5-shot），而匹配网络为 43.56 ± 0.84% 和 55.31 ± 0.73%，元学习器 LSTM 为 43.44 ± 0.77% 和 60.60 ± 0.71%。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> 在 5-shot 正弦回归上，MAML 经过一步梯度更新后达到均方误差0.67，而在所有任务上预训练为2.41。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup> 在强化学习中，一个具有两个100单元隐藏层的策略使用 [REINFORCE](https://www.edgepedia.org/zh/reinforce) 计算适应梯度，以 TRPO 作为元优化器，在两到三步梯度更新内适应新的目标速度和方向，远快于预训练或随机初始化。<sup>[1](https://doi.org/10.48550/arxiv.1703.03400)</sup>

## 局限与替代方法

**成本与内存。** 精确的元梯度需要 Hessian 向量积，这使得实现成本高昂。<sup>[5](https://proceedings.mlr.press/v108/fallah20a/fallah20a.pdf)</sup> 内存随内梯度步数线性增长，在 20-way 5-shot Omniglot 上约16步即达到12 GB GPU 的容量。<sup>[3](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)</sup> 一阶近似省去了这一成本，但 FO-MAML 无法达到任意小的优化误差，而 HF-MAML 和 iMAML 无需二阶信息即可恢复精度。<sup>[5](https://proceedings.mlr.press/v108/fallah20a/fallah20a.pdf)</sup><sup> • </sup><sup>[3](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)</sup>

**元过拟合与强化学习性能。** 在强化学习中，MAML 可能落后于基于记忆的元学习器：在 MuJoCo 的 HalfCheetahVel 任务上，它达到平均奖励−150，而 VariBAD、TrMRL 和 RL² 从第一回合起就达到约−25，这促使了 Robust MAML 和 XB-MAML 等扩展的出现。<sup>[8](https://www.arxiv.org/pdf/2602.19837)</sup> BMAML 的追逐者损失正是为防止元级过拟合而提出的。<sup>[15](https://proceedings.neurips.cc/paper/2018/file/e1021d43911ca2c1845910d84f40aeae-Paper.pdf)</sup>

**与微调和度量方法的比较。** 当评估任务来自与训练不同的数据分布时，简单微调预训练网络可能比 MAML 更有效；当分布相似时，MAML 和 Reptile 往往优于微调，因为它们专注于低数据条件下的快速适应。微调基线的预训练特征比 MAML 和 Reptile 学到的特征更多样、更具判别性，这解释了为何无法泛化到分布之外。<sup>[12](https://link.springer.com/article/10.1007/s10994-023-06387-w)</sup> 在少样本分类基准上，MAML 已不再产生最优性能，被潜在嵌入优化（latent embedding optimization，LEO）和 MetaOptNet 超越，前者在低维潜在空间中优化初始权重，后者在元学习的特征提取器上堆叠凸模型。<sup>[4](https://link.springer.com/article/10.1007/s10994-022-06210-y)</sup> MetaICL（徐元敏及其同事，2021）通过上下文学习将元学习应用于语言模型，无需 MAML 的两步优化。<sup>[18](https://doi.org/10.48550/arxiv.2110.15943)</sup> 2023年之后，MAML 风格的优化与大型基础模型中的上下文学习在细节上如何比较，在已发表的比较中尚未有定论。

## References

1. [Finn, Chelsea, Abbeel, Pieter, Levine, Sergey (2017). Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1703.03400)
2. [Model-agnostic meta-learning for fast adaptation of deep networks | Proceedings of the 34th ICML (ACM DL record)](https://dl.acm.org/doi/10.5555/3305381.3305498)
3. [Meta-Learning with Implicit Gradients (iMAML, NeurIPS 2019)](https://proceedings.neurips.cc/paper_files/paper/2019/file/072b030ba126b2f4b2374f342be9ed44-Paper.pdf)
4. [Stateless neural meta-learning using second-order gradients (TURTLE; Machine Learning journal, 2022)](https://link.springer.com/article/10.1007/s10994-022-06210-y)
5. [On the Convergence Theory of Gradient-Based Model-Agnostic Meta-Learning Algorithms (Fallah, Mokhtari, Ozdaglar, AISTATS 2020)](https://proceedings.mlr.press/v108/fallah20a/fallah20a.pdf)
6. [Reptile: a Scalable Metalearning Algorithm / On First-Order Meta-Learning Algorithms](https://arxiv.org/pdf/1803.02999)
7. [On the Convergence of Multi-Step MAML (NSF PAR copy)](https://par.nsf.gov/servlets/purl/10339904)
8. [Survey of meta-learning landmarks (arXiv, 2026)](https://www.arxiv.org/pdf/2602.19837)
9. [Alpha MAML: Adaptive Model-Agnostic Meta-Learning (alphaXiv overview)](https://arxiv.org/abs/1905.07435)
10. [Andrychowicz, Marcin and colleagues (2016). Learning to learn by gradient descent by gradient descent. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1606.04474)
11. [Vinyals, Oriol and colleagues (2016). Matching Networks for One Shot Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1606.04080)
12. [Understanding transfer learning and gradient-based meta-learning techniques (Machine Learning journal, 2023)](https://link.springer.com/article/10.1007/s10994-023-06387-w)
13. [Song, Xingyou and colleagues (2019). ES-MAML: Simple Hessian-Free Meta Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1910.01215)
14. [Grant et al., Gradient-Based Meta-Learning as Hierarchical Bayesian Inference (LLAMA)](https://cocosci.princeton.edu/papers/gradient-based_meta-learning.pdf)
15. [Bayesian Model-Agnostic Meta-Learning (BMAML, NeurIPS 2018)](https://proceedings.neurips.cc/paper/2018/file/e1021d43911ca2c1845910d84f40aeae-Paper.pdf)
16. [Finn, Chelsea, Xu, Kelvin, Levine, Sergey (2018). Probabilistic Model-Agnostic Meta-Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1806.02817)
17. [Abbas, Momin and colleagues (2022). Sharp-MAML: Sharpness-Aware Model-Agnostic Meta Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2206.03996)
18. [Min, Sewon and colleagues (2021). MetaICL: Learning to Learn In Context. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2110.15943)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Oct 15, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Ensemble, boosting, and transfer methods › Transfer learning and domain adaptation

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/model-agnostic-meta-learning

English original: https://www.edgepedia.org/model-agnostic-meta-learning
