Meta-Learning with Implicit Gradients.

Aravind Rajeswaran, Chelsea Finn, Sham M. Kakade, Sergey Levine

Abstract

A core capability of intelligent systems is the ability to quickly learn new tasks by drawing on prior experience. Gradient (or optimization) based meta-learning has recently emerged as an effective approach for few-shot learning. In this formulation, meta-parameters are learned in the outer loop, while task-specific models are learned in the inner-loop, by using only a small amount of data from the current task. A key challenge in scaling these approaches is the need to differentiate through the inner loop learning process, which can impose considerable computational and memory burdens. By drawing upon implicit differentiation, we develop the implicit MAML algorithm, which depends only on the solution to the inner level optimization and not the path taken by the inner loop optimizer. This effectively decouples the meta-gradient computation from the choice of inner loop optimizer. As a result, our approach is agnostic to the choice of inner loop optimizer and can gracefully handle many gradient steps without vanishing gradients or memory constraints. Theoretically, we prove that implicit MAML can compute accurate meta-gradients with a memory footprint that is, up to small constant factors, no more than that which is required to compute a single inner loop gradient and at no overall increase in the total computational cost. Experimentally, we show that these benefits of implicit MAML translate into empirical gains on few-shot image recognition benchmarks.

Introduction

Optimization-based meta-learning, specifically Model-Agnostic Meta-Learning (MAML), has emerged as a powerful framework for few-shot learning. In this setup, meta-parameters are learned in an outer loop, while task-specific models are adapted in an inner loop using limited data. However, MAML faces significant scaling challenges. To update the outer loop, one must traditionally backpropagate through the entire inner loop optimization trajectory. This "unrolling" leads to two primary bottlenecks:

  1. Memory Consumption: Storing the history of weights for every step scales linearly with the number of adaptation steps, often leading to out-of-memory errors on modern GPUs.
  2. Vanishing/Exploding Gradients: Differentiating through long chains of operations can make training unstable and gradients unreliable.

Consequently, most MAML applications are restricted to very few adaptation steps (typically 1–5), which limits their effectiveness on complex tasks that require more extensive fine-tuning.

The Implicit MAML Algorithm

The authors propose Implicit MAML (iMAML) to overcome these limitations by leveraging the Implicit Function Theorem. Unlike standard MAML, which differentiates through the optimization path, iMAML differentiates through the solution of the inner-loop optimization.

Conceptual comparison of MAML, first-order MAML, and implicit MAML. Standard MAML backpropagates through the entire path, while iMAML depends only on the final solution.

Key Methodological Innovations

  • Proximal Regularization: The inner loop objective is modified with a regularization term that keeps task-specific parameters ($\phi$) close to the meta-parameters ($\theta$). This ensures the inner optimization is well-behaved and strongly convex.
  • Implicit Differentiation: By focusing on the optimality conditions of the inner loop, iMAML derives an analytical expression for the meta-gradient that depends only on the final adapted weights.
  • Efficient Computation: To avoid inverting large Hessian matrices, iMAML employs a Conjugate Gradient (CG) solver to compute Hessian-vector products. This keeps the memory cost constant $O(1)$ relative to the number of inner loop steps.

Experimental Evaluation

The researchers evaluated iMAML on standard few-shot benchmarks including Omniglot (1,623 handwritten characters), Mini-ImageNet (a 100-class subset of ImageNet), and synthetic regression tasks to verify gradient accuracy.

Key Results and Insights

iMAML successfully decouples meta-gradient computation from the choice of the inner-loop optimizer. This allows for the use of sophisticated second-order optimizers during task adaptation without increasing meta-learning complexity.

Analysis of gradient error, memory usage, and compute time. iMAML maintains constant memory usage regardless of the number of gradient steps, unlike standard MAML.
  • Memory Efficiency: While standard MAML hits a "memory wall" as adaptation steps increase, iMAML's memory footprint remains flat. This enables hundreds of adaptation steps on a single GPU where MAML would otherwise crash.
  • Accuracy and Stability: On Omniglot (20-way, 5-shot), iMAML achieved 99.14% accuracy, outperforming both standard MAML (98.9%) and first-order MAML (97.9%). It proved particularly effective for "medium-shot" problems requiring more than five adaptation steps to reach a good solution.

Limitations and Future Work

Implicit differentiation assumes the inner loop reaches a near-optimal solution; premature termination can lead to inaccurate gradients. Additionally, the regularization strength ($\lambda$) is a critical hyperparameter that requires careful tuning. Future work may explore applying iMAML to Reinforcement Learning with long horizons or GAN training, where unrolling optimization is currently computationally prohibitive.

Summary updated

BibTeX
@inproceedings{rajeswaran2019meta,
  author = {Aravind Rajeswaran and Chelsea Finn and Sham M. Kakade and Sergey Levine},
  title = {{Meta-Learning with Implicit Gradients.}},
  booktitle = {NeurIPS},
  year = {2019},
  url = {https://openreview.net/forum?id=xLIumnqjBF-},
}
Figure