Deep learning models are famously data-hungry. Training a state-of-the-art image classifier often requires millions of labeled examples. Humans, on the other hand—even young children—can recognize a new object after seeing just one or two examples. This remarkable ability to generalize from so little data represents one of the biggest challenges in artificial intelligence: few-shot learning.
Standard deep learning struggles in this regime. Optimization algorithms like SGD or Adam were designed to refine network parameters slowly over countless updates. When given only a handful of examples, they tend to overfit or never reach a meaningful solution. Moreover, each new few-shot task typically starts from a random initialization—a terrible starting point when there’s little room for iteration.
What if we could design an optimization algorithm tailor-made for the few-shot scenario? Even better: what if we could learn one? That’s the central idea behind Optimization as a Model for Few-Shot Learning by Sachin Ravi and Hugo Larochelle. Their approach uses one neural network—an LSTM—to learn how to train another neural network (the “learner”), empowering it to master new tasks in just a few steps. This meta-learner discovers not only an efficient update rule but also a powerful initialization, creating a form of learned transfer learning.
The Meta-Learning Framework: Training to Learn New Tasks
Before exploring the model, let’s unpack the setup. Few-shot learning is usually framed as a meta-learning problem: instead of training a single model to solve a single task, we train a model that can learn new tasks efficiently.
Imagine building a model to classify new animal species from just five pictures—known as a 5-shot learning problem. Instead of one massive dataset, you’d create a meta-dataset containing many smaller datasets, or episodes. Each episode mimics a true few-shot learning scenario, allowing the model to practice learning from limited data.
Each episode consists of:
- A training set (
D_train), also called the support set. For a 5-shot, 5-class task, this contains five examples from each of five classes (25 images total). - A test set (
D_test), the query set, containing new examples from those same classes that the model must classify.

Figure 1: Example of meta-learning setup showing the meta-train and meta-test structure. Each episode has a support set (
D_train) and a query set (D_test) drawn from distinct classes, encouraging broad generalization.
Importantly, classes used in meta-training (e.g., cats, dogs, cars) are entirely different from those used in meta-testing (e.g., airplanes, flowers, chairs). This forces the model to learn a general learning strategy rather than memorizing class-specific information. The goal is to train a meta-learner that can rapidly adapt to any new support set and achieve high accuracy on its query set.
The Core Idea: An LSTM as an Optimizer
The heart of this paper rests on a clever observation: the gradient descent update rule looks a lot like the LSTM’s cell state update.
Gradient descent updates a model’s parameters \( \theta \) at each step \( t \) by moving in the opposite direction of the gradient of the loss \( \mathcal{L}_t \):

The standard gradient descent update rule adjusts parameters using the gradient and learning rate.
Here, \( \alpha_t \) is the learning rate—a fixed scalar controlling update size.
Now, consider the LSTM’s cell state equation:

The LSTM cell state update combines previous state and new information using input and forget gates.
If we reinterpret the components as follows:
- Cell state \( c_t \) → learner’s parameters \( \theta_t \)
- Forget gate \( f_t \) → constant 1 (keep prior parameters)
- Input gate \( i_t \) → learning rate \( \alpha_t \)
- Candidate state \( \tilde{c}_t \) → negative gradient \( -\nabla_{\theta_{t-1}} \mathcal{L}_t \)
…then the LSTM update becomes mathematically equivalent to gradient descent.
This insight sparked the idea: treat an LSTM as a learnable optimizer that updates network parameters intelligently instead of using hand-crafted rules.
Building the Meta-Learner
The model consists of two cooperating networks:
1. The Learner: A standard convolutional neural network that performs classification for each few-shot task. Its parameters \(\theta\) adapt during each episode.
2. The Meta-Learner: A two-layer LSTM responsible for updating the learner’s parameters. Its cell state \( c_t \) directly represents the learner’s parameters \( \theta_t \).
During each step within an episode:
- The learner computes its loss \( \mathcal{L}_t \) and gradient \( \nabla_{\theta_{t-1}} \mathcal{L}_t \) on
D_train. - These quantities are fed to the meta-learner.
- The LSTM outputs updated parameters \( \theta_t \) for the learner.
Unlike gradient descent’s fixed learning rate and static forget behavior, the LSTM dynamically determines them for each parameter dimension.
Dynamic Input Gate (i_t):
Acts as a learned, adaptive learning rate, computed as a function of the current gradient, loss, parameter value, and previous input gate.

The input gate equation: the meta-learner determines learning rates adaptively from gradients, losses, and parameter history.
Dynamic Forget Gate (f_t):
Allows selective forgetting of previous parameter information—useful for escaping poor local minima or applying weight decay when gradients are small.

The forget gate equation: enables learned parameter shrinkage when appropriate for escaping undesirable optima.
Why This Matters
This architecture provides two major benefits beyond standard fine-tuning:
Learned Initialization: The initial LSTM cell state \( c_0 \) is trainable. Since it represents the learner’s parameters, the LSTM learns an optimal starting point \( \theta_0 \) for new tasks—a “smart” initialization that replaces random parameters with informed ones.
Learned Update Rule: Rather than a hand-coded optimizer, the LSTM learns the update procedure. It can model momentum-like effects, adaptive learning rates, or even novel strategies suited specifically to few-shot learning.
Practical Engineering Challenges
Training an LSTM to update a CNN with tens of thousands of parameters is computationally demanding. The paper addresses this through several clever strategies:
Parameter Sharing: Instead of maintaining separate meta-learner weights for every CNN parameter, the same LSTM weights are reused (“coordinate-wise” sharing) across all parameters. Each parameter retains its own hidden state history, but the update rule itself is universal.
Input Preprocessing: Gradients and losses can vary wildly in magnitude. The authors normalize them by separating logarithmic magnitude and sign, stabilizing the learning process.

Gradient and loss preprocessing splits sign and magnitude to help the LSTM handle diverse scales effectively.
Training the Meta-Learner: Learning from Learning
To train the meta-learner, the key objective is simple: after a fixed number of updates on an episode’s support set, the final learner should perform well on its query set.
This process “unrolls” the optimization steps like a sequence. Each unrolled step is differentiable, allowing the meta-learner’s parameters to be updated with backpropagation through time.

Figure 2: Computational graph showing how the meta-learner updates the learner over several steps. The test loss acts as feedback for improving the meta-learner.
To make training tractable, the authors make a practical assumption: ignore second-order gradients. In other words, they don’t backpropagate through the learner’s gradient calculations. Despite simplifying the math, the model still learns effective optimization behavior.
Experiments: Does It Work?
The approach was tested on Mini-ImageNet, a compact benchmark derived from ImageNet. It contains 100 classes (64 for training, 16 for validation, 20 for testing). Each few-shot task involves 1-shot or 5-shot classification across five classes.
Baseline comparisons include:
- Fine-tuning baseline: A conventional pre-trained network fine-tuned on each new task.
- Nearest-neighbor baseline: A simple embedding-based classifier using learned representations.
- Matching Networks: A leading metric-learning approach for few-shot learning.

Table 1: Average classification accuracies on Mini-ImageNet. The Meta-Learner LSTM outperforms strong baselines, notably in the 5-shot setting.
Results:
- 5-shot, 5-class: Meta-Learner LSTM achieved 60.60% accuracy—substantially higher than other methods.
- 1-shot, 5-class: It reached 43.44%, comparable to Matching Networks.
- Baselines: The fine-tuning model lagged behind with only 28.86% on the 1-shot task, confirming that traditional optimization suffers without a solid initialization or adaptive rule.
These findings validate the idea: learning the optimizer itself can yield much stronger results than manually designed approaches.
Understanding What the Meta-Learner Learned
To peek inside the optimizer’s “thought process,” the authors visualized the learned input and forget gates across training steps.

Figure 3: Gate activations across time. Distinct behaviors between 1-shot and 5-shot learning reveal adaptive strategies.
Key observations:
- Forget gate values hover slightly below 1, acting like learned weight decay—a stabilizing mechanism.
- Input gate values vary widely across episodes, showing that the learning rate adapts dynamically per task.
- Differences between 1-shot and 5-shot settings confirm that the meta-learner has learned distinct optimization behaviors depending on data volume.
Conclusion: Learning to Learn
Optimization as a Model for Few-Shot Learning introduces an elegant concept: rather than handcrafting optimization algorithms, we can teach a neural network to design its own.
By framing parameter updates as LSTM state transitions, Ravi and Larochelle created a meta-learner that discovers both an effective initialization and a context-sensitive update mechanism—learning how to learn. Their work shows that:
- Optimization rules can themselves be learned. Algorithms like SGD are not immutable; they can be replaced by data-driven strategies developed by neural networks.
- Initialization matters. Learning the starting parameters \( \theta_0 \) dramatically improves the ability to generalize with few examples.
- Meta-learning is a stepping stone to flexible AI. Training on a distribution of tasks enables systems to internalize the process of learning itself.
This research opened a fresh direction in meta-learning and inspired a wave of subsequent work on learned optimizers. As the field progresses, the boundary between model and optimizer continues to blur—suggesting that perhaps, the most powerful thing a neural network can learn is how to learn itself.
