Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Train on a task, then step toward where you ended up
Reptile is meta-learning without the hard mathematics. Take the shared starting weights, train a copy on one task for a few steps, and look at where the copy ended up. Then move the shared weights a little in that direction. After many tasks, the shared weights settle in a spot from which every task is only a few steps away. The number of inner steps turns out to matter a great deal. The demo’s MAML panel shows the kind of starting point both methods look for.
Reptile needs only ordinary training code (no second derivatives, no special data splits), so it is easy to add to existing pipelines for robots or controllers that must adapt quickly.
- 1. Reptile moves the shared weights toward…
- 2. Reptile needs second derivatives?
- 3. The number of inner steps…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Algorithm:
- Sample a task.
- From θ, run k SGD steps to get θ̃.
- Update θ ← θ + ε(θ̃ − θ).
- With θ = 0, θ̃ = 2 and ε = 0.25, θ becomes 0.5.
- Inner steps on a quadratic: k SGD steps on (θ − c)² from 0 with rate 0.25 leave the gap c(1 − 0.5)^k. For c = 4, that is 2 after one step and 1 after two (θ = 2, then 3).
- One inner step: (θ − θ̃)/α = ∇L_T(θ), so Reptile is plain SGD on the expected task loss: joint training, no meta-learning.
- Taylor analysis (Nichol and colleagues): for k ≥ 2, the expected update also contains a term like ∇(g₁ · g₂). It increases the inner product of gradients from different batches of the same task, so one task’s steps generalise within that task.
- Cost: k gradient evaluations per task (20,000 for 2000 tasks with k = 10), with no Hessians.
- 1. Reptile update for θ = 0, θ̃ = 2, ε = 0.25:
- 2. With k = 1, Reptile equals…
- 3. Gap after 2 steps on (θ − 4)² from 0, rate 0.25:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Reptile in code
Exercise 1.
- The Reptile update moved halfway with ε = 0.5.
- Two SGD steps reached the expected point.
- The one-step Reptile direction equalled the task gradient exactly.
Practice.
- Use any optimiser in the inner loop (SGD or Adam). For the outer step, either interpolate with ε annealed toward 0, or feed (θ − θ̃) to Adam as a gradient.
- Use several inner steps (5–50) and batch several tasks per outer step by averaging their θ̃.
- At test time, fine-tune from θ with the same inner optimiser.
for it in range(iters):
task = sample_task()
fast = copy.deepcopy(model)
opt_in = torch.optim.SGD(fast.parameters(), lr=inner_lr)
for _ in range(k): # ordinary training on one task
opt_in.zero_grad(); task.loss(fast).backward(); opt_in.step()
with torch.no_grad():
for p, q in zip(model.parameters(), fast.parameters()):
p += eps * (q - p) # move toward the adapted weights- 1. Typical inner steps for Reptile:
- 2. The outer step size ε is often…
- 3. Reptile needs a support/query split?
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why one step is not enough.
- With k = 1, θ − θ̃ = α∇L_T(θ), so averaging over tasks gives the gradient of the average loss: Reptile is ordinary joint training and finds the average model.
- The meta-learning signal appears only from the second step on, through the interaction of successive gradients on the same task.
What the extra term does.
- Expanding to second order, the expected Reptile update contains a term proportional to −∇_θ E[g₁ · g₂], the inner product of gradients from two batches of the same task (Nichol and colleagues).
- Following it makes those gradients agree, so a step on a few examples also improves the rest of the task. This is the same effect MAML’s second-order term produces, which explains why Reptile, FOMAML and MAML behave similarly.
Another view. Reptile moves θ toward a point close to the solution manifolds of all tasks (in Euclidean distance), so every task’s solution lies nearby.
- 1. The meta-learning signal appears from…
- 2. The extra term increases…
- 3. Reptile seeks a point close to…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How many inner steps does Reptile need?
History.
- A. Nichol, J. Achiam and J. Schulman, “On first-order meta-learning algorithms” (2018), introduced Reptile and its Taylor analysis.
- Reptile performed comparably to MAML and FOMAML on Omniglot and miniImageNet with much simpler code.
Exercise 2.
- Benchmark: the sinusoid regression from the MAML page, with a 1–40–40–1 ReLU MLP.
- Training: Reptile with k = 1, 5 or 10 inner SGD steps (rate 0.01) on 10 points per task. The outer update is Adam on (θ − θ̃)/(kα), for 2000 tasks.
- Test: error on new tasks after 1 and 10 adaptation steps.
| inner steps k | error after 1 step | after 10 steps |
|---|---|---|
| 1 (= joint training) | 3.54 | 3.49 |
| 5 | 2.46 | 1.83 |
| 10 | 1.73 | 1.08 |
- k = 1 is not meta-learning: with one inner step, Reptile is joint training and barely adapts (3.54 → 3.49), the same failure as plain pretraining on the MAML page.
- More inner steps, better meta-learning: k = 5 halves the 10-step error and k = 10 cuts it by a factor of 3.2, exactly as the Taylor analysis predicts (the useful term needs k ≥ 2 and grows with k).
- Close to first-order MAML: k = 10 reached 1.08 against 0.72 for first-order MAML on the MAML page, which saw 6 times as many tasks (4 per step for 3000 steps).
- Seeds: seeds 1 and 2 gave 3.35/1.70/1.22 and 3.63/1.95/1.33 for k = 1/5/10.
Reptile in AI, robotics and aerospace
- Simple adaptive controllers: meta-training policies or dynamics models across simulated variations with standard training code.
- Personalisation: quickly adapting perception or prediction models to a new site, vehicle or user.
- Design lesson: if your meta-learner uses one inner step, it is probably just multi-task training. Use several inner steps to get a true meta-learning signal.
References
- A. Nichol, J. Achiam and J. Schulman (2018). “On first-order meta-learning algorithms.” arXiv:1803.02999.
- C. Finn, P. Abbeel and S. Levine (2017). “Model-agnostic meta-learning for fast adaptation of deep networks.” Proc. ICML.