Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Learn a starting point that adapts fast
Instead of learning one model for one job, MAML learns a starting point that can be fine-tuned to any new job in a few steps. During training it repeatedly takes a task, adapts a copy of the model with a small gradient step, checks how well the adapted copy does, and nudges the shared starting point so that future adaptations go better. The demo shows how the after-adaptation objective can prefer a different starting point than the plain average loss.
Robots meeting new payloads, terrains or wear, and controllers facing new aircraft configurations, need to adapt from little data. Meta-learned initialisations make that adaptation fast and data-efficient.
- 1. MAML learns…
- 2. Its training objective is the loss…
- 3. MAML works with…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Inner loop (per task T_i): θ’i = θ − α ∇L(T_i)^support(θ). For θ = 1, gradient 4 and α = 0.25, θ’ = 0.
- Outer loop: θ ← θ − β ∇θ Σ_i L(T_i)^query(θ’_i).
- Meta-gradient: ∇_θ L^q(θ’) = (I − α ∇²L^s(θ)) ∇L^q(θ’). For quadratic losses with Hessian H_s, the Jacobian is (I − αH_s).
- First-order MAML drops it and uses ∇L^q(θ’) directly.
- 1-D example: L(θ) = a(θ − c)². After one step the loss is a(1 − 2αa)²(θ − c)², with gradient 2a(1 − 2αa)²(θ − c).
- If α = 1/(2a), one step solves the task and the meta-gradient is 0.
- Benchmark (Finn and colleagues):
- sinusoids A sin(x + φ) with A ∈ [0.1, 5], φ ∈ [0, π], 10 points per task;
- a 1–40–40–1 ReLU network (1761 parameters) with α = 0.01.
- 1. θ' for θ = 1, gradient 4, α = 0.25:
- 2. First-order MAML drops…
- 3. Parameters of a 1–40–40–1 network:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.MAML in code
Exercise 1.
- The exact MAML meta-gradient for quadratic losses matched finite differences.
- It equalled (I − αH_s) times the first-order gradient.
Practice.
- Use
higher,learn2learnortorch.functo differentiate through inner steps. For large models, use first-order MAML or implicit gradients (iMAML). - Tune the inner learning rate (or learn it: Meta-SGD, MAML++), and use several inner steps at test time.
- MAML training can be unstable; MAML++ adds per-step batch-norm statistics, multi-step losses and annealing.
for tasks in meta_loader:
meta_loss = 0
for (xs, ys, xq, yq) in tasks:
fast = {n: p for n, p in model.named_parameters()}
g = torch.autograd.grad(loss_fn(fmodel(fast, xs), ys), fast.values(), create_graph=True)
fast = {n: p - alpha * gi for (n, p), gi in zip(fast.items(), g)} # differentiable inner step
meta_loss = meta_loss + loss_fn(fmodel(fast, xq), yq)
meta_opt.zero_grad(); meta_loss.backward(); meta_opt.step()- 1. Differentiating through inner steps needs…
- 2. MAML++ improves…
- 3. iMAML uses…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
What MAML optimises.
- The outer objective rewards parameters from which one step lands near each task’s optimum. Tasks that one step fixes easily (high curvature) are discounted, and the initialisation moves to where gradient steps are most effective.
- With a learnable network, MAML also shapes the features so that task-specific changes are easy to make with few steps.
Rapid learning or feature reuse?
- Raghu and colleagues (ICLR 2020) found that after MAML training, adapting only the last layer (ANIL) works as well as adapting everything: most of the benefit comes from learning reusable features, not from rapid change of the whole network.
- A corollary: with fixed features, MAML can only change the starting point. With a linear model and quadratic losses, its optimum is close to plain multi-task pretraining.
First-order versus exact. The second-order term (I − α∇²L) matters most when the inner step is large relative to curvature. For small α it is near the identity, which is why FOMAML (and Reptile, next page) work well in practice.
- 1. Raghu et al. found MAML's benefit mostly comes from…
- 2. With fixed features, MAML can only change…
- 3. FOMAML is accurate when α is…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.When does meta-learning an initialisation help?
History.
- C. Finn, P. Abbeel and S. Levine, “Model-agnostic meta-learning for fast adaptation of deep networks” (ICML 2017).
- A. Antoniou, H. Edwards and A. Storkey, “How to train your MAML” (ICLR 2019).
- A. Raghu, M. Raghu, S. Bengio and O. Vinyals, “Rapid learning or feature reuse? Towards understanding the effectiveness of MAML” (ICLR 2020).
Exercise 2.
- Tasks: sinusoid regression A sin(x + φ), with 10 support points per task and evaluation on 100 points of new tasks after adaptation.
- Linear model: 20 fixed Gaussian RBF features plus a bias. Exact (second-order) MAML with α = 0.3 is compared with plain pretraining, 1000 meta-iterations.
- MLP: 1–40–40–1 ReLU. First-order MAML with α = 0.01 is compared with pretraining, 3000 meta-iterations.
| model | method | error after 1 step | after 5 (linear) or 10 (MLP) steps |
|---|---|---|---|
| linear, fixed features | pretraining | 2.33 | 0.920 |
| linear, fixed features | exact MAML | 2.34 | 0.925 |
| MLP | pretraining | 2.73 | 2.11 |
| MLP | first-order MAML | 1.38 | 0.72 |
- With fixed features, MAML brings nothing: it can only choose the starting weights, and the best start is essentially the multi-task average, as the feature-reuse view predicts.
- With learnable features, MAML helps a lot: after one step its error is half of pretraining’s, and after 10 steps about a third (0.72 vs 2.11).
- Pretraining adapts poorly: its starting point fits the average task (near zero), and its features are not shaped for fast adaptation. One step can even make it worse on some seeds.
- Seeds: seeds 1 and 2 gave 10-step errors of 1.02 and 1.14 (first-order MAML) against 2.59 and 2.61 (pretraining).
MAML in AI, robotics and aerospace
- Robot adaptation: policies that adapt to new payloads, terrains or damage from a few trials.
- Flight control: controllers adapting quickly to changed dynamics (icing, damage, new configurations).
- Design lesson: meta-learning pays when the model can learn features that make adaptation easy. Compare against multi-task pretraining with fine-tuning, which is often competitive.
References
- C. Finn, P. Abbeel and S. Levine (2017). “Model-agnostic meta-learning for fast adaptation of deep networks.” Proc. ICML.
- A. Antoniou, H. Edwards and A. Storkey (2019). “How to train your MAML.” ICLR.
- A. Raghu, M. Raghu, S. Bengio and O. Vinyals (2020). “Rapid learning or feature reuse? Towards understanding the effectiveness of MAML.” ICLR.
- A. Rajeswaran, C. Finn, S. Kakade and S. Levine (2019). “Meta-learning with implicit gradients.” NeurIPS.