🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
Search courses…
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Meta-Learning — Learning to Learn

Expert TopicsMeta-Learning🟢 Free Lesson

Advertisement

Advanced Topics

Meta-Learning — Learning to Learn from Few Examples

Discover meta-learning algorithms that enable models to learn new tasks quickly with minimal data. The key to few-shot learning and rapid adaptation.

  • MAML — Model-Agnostic Meta-Learning for fast adaptation
  • Prototypical Networks — Learning metric spaces for classification
  • Reinforcement Learning — Meta-learning with reward signals

"The most important skill is learning how to learn."

Meta-Learning — Learning to Learn

Meta-learning trains models to learn new tasks quickly from few examples.


Meta-Learning Concept

Standard ML vs Meta-LearningStandard MLLearn ONE task from MANY examplesCat Images10,000 samplesDog Images10,000 samplesBird Images10,000 samplesTraining: 30,000 labeled images→ Trained ClassifierTask-specific, large data requiredCannot adapt to new classes without retrainingMeta-LearningLearn MANY tasks from FEW examples eachTask: Cat vs Dog5 shotsTask: Red vs Blue5 shotsTask: Hot vs Cold5 shotsMeta-training: ~100 tasks × 5 examples each→ Meta-Learner (fast adapter)Task-agnostic, learns to adapt quicklyNew task: 5 examples → fast adaptationvs

The Formal Framework

DfMeta-Learning

Meta-learning, or "learning to learn," trains a model across a distribution of tasks Tp(T)\mathcal{T} \sim p(\mathcal{T}) to acquire the ability to quickly adapt to new tasks with minimal data via a small number of gradient steps.

Bi-Level Optimization

The meta-learning objective is a bi-level optimization problem:

Outer loop (meta-update):

θ=argminθTip(T)LTi(ϕi)\theta^* = \arg\min_\theta \sum_{\mathcal{T}_i \sim p(\mathcal{T})} \mathcal{L}_{\mathcal{T}_i}(\phi_i)

Inner loop (task adaptation):

ϕi=θαθLTi(θ)\phi_i = \theta - \alpha \nabla_\theta \mathcal{L}_{\mathcal{T}_i}(\theta)

where θ\theta is the meta-learned initialization and ϕi\phi_i is the adapted model for task ii.


MAML Algorithm

MAML: Model-Agnostic Meta-LearningOuter Loop: Meta-Updateθ ← θ − β∇θ Σ_i ℒ{T_i}(φ_i)Meta-Initialize θLearned across all tasksTask 1: Cat vs DogSupport Set (5-shot):5 labeled examples per classInner Loop (1-5 steps):φᵢ = θ − α∇_θ ℒ_{T_i}(θ)Adapt to task iQuery Set:Unseen examples for meta-lossTask 2: Hot vs ColdSupport Set (5-shot):5 labeled examples per classInner Loop (1-5 steps):φᵢ = θ − α∇_θ ℒ_{T_i}(θ)Adapt to task iQuery Set:Unseen examples for meta-lossTask 3: Red vs BlueSupport Set (5-shot):5 labeled examples per classInner Loop (1-5 steps):φᵢ = θ − α∇_θ ℒ_{T_i}(θ)Adapt to task iQuery Set:Unseen examples for meta-lossTask K: ...Support Set (5-shot):5 labeled examples per classInner Loop (1-5 steps):φᵢ = θ − α∇_θ ℒ_{T_i}(θ)Adapt to task iQuery Set:Unseen examples for meta-lossMeta-loss = Σ_i ℒ_{T_i}(φ_i) → Update θ via β

MAML Algorithm Details

DfMAML (Model-Agnostic Meta-Learning)

An optimization-based meta-learning algorithm that finds a model initialization θ\theta that can be rapidly adapted to new tasks with a few gradient steps.

MAML Pseudocode

Architecture Diagram
Algorithm: MAML
Input: Task distribution p(T), step sizes α (inner), β (outer)
Output: Meta-learned initialization θ

1: Randomly initialize θ
2: for each meta-training iteration do
3:   Sample batch of tasks Tᵢ ~ p(T)
4:   for each task Tᵢ do
5:     Sample support set Sᵢ = {(xₐ, yₐ)} from Tᵢ
6:     Compute gradient: gᵢ = ∇_θ ℒ_{Tᵢ}(θ; Sᵢ)
7:     Adapt: φᵢ = θ − α · gᵢ              // Inner loop
8:   end for
9:   Sample query sets Qᵢ from each Tᵢ
10:  Compute meta-gradient: ∇_θ Σᵢ ℒ_{Tᵢ}(φᵢ; Qᵢ)
11:  Update: θ ← θ − β · ∇_θ Σᵢ ℒ_{Tᵢ}(φᵢ; Qᵢ)  // Outer loop
12: end for

MAML Variants

  • First-Order MAML (FOMAML): Approximate meta-gradient by ignoring second-order terms — faster, nearly as good
  • Reptile: Simply average multiple SGD runs across tasks — no second-order gradients needed
  • MAML++: Uses learned inner loop learning rates, more inner steps, and data augmentation
  • ANIL (Almost No Inner Loop): Only the head (last layer) is adapted in the inner loop — challenges necessity of full MAML

Prototypical Networks

Prototypical Networks: Metric-Based Meta-LearningSupport SetClass AClass BClass CEncodef_θ(x)Embedding Spacec_Ac_Bc_CQuery xd(x,c_A)Classification Rulep(y=k|x) =exp(−d(x, cₖ))Σ_j exp(−d(x, cⱼ))d = Euclidean distancePrototype = Mean Embeddingcₖ = (1/|Sₖ|) Σ_{x∈Sₖ} f_θ(x)

Few-Shot Learning Scenarios

DfN-way K-shot Classification

In N-way K-shot classification, the model must distinguish between NN classes using only KK labeled examples per class. This is the standard evaluation protocol for meta-learning.

Learning Scenarios

Few-Shot Learning (N-way, K-shot):

  • NN classes, KK support examples per class (K5K \leq 5 typically)
  • Query set: unlabeled examples to classify
  • K=1K=1: One-shot learning, K=5K=5: 5-shot learning

Zero-Shot Learning:

  • Classes never seen during training
  • Requires semantic descriptions or attributes
  • Example: "zebra" described as "horse with stripes"

Few-Shot with Side Information:

  • Use text descriptions, attributes, or images of similar classes
  • Multimodal meta-learning

Key Takeaways

Summary: Meta-Learning

  • Meta-learning enables few-shot learning — adapt to new tasks with 5 examples
  • MAML finds initialization θ\theta for fast gradient-based adaptation
  • Prototypical Networks learn metric spaces — classify by nearest prototype
  • Episodic training simulates few-shot scenarios: support + query sets
  • Bi-level optimization: Outer loop optimizes initialization, inner loop adapts to task
  • Applications: robotics, personalization, drug discovery, NLP
  • Transfer learning is simpler but less flexible
  • Neural architecture search is meta-learning for architectures
  • FOMAML, Reptile, ANIL are practical alternatives to full MAML

What to Learn Next

-> Self-Supervised Learning — Pre-training Revolution Learn about self-supervised learning — pre-training revolution.

-> Transfer Learning — Pre-trained Models Complete Guide Learn about transfer learning — pre-trained models complete guide.

-> Neural Networks Fundamentals — Perceptrons to Deep Learning Learn about neural networks fundamentals — perceptrons to deep learning.

-> Model Evaluation — Metrics, Cross-Validation and Selection Learn about model evaluation — metrics, cross-validation and selection.

-> AutoML — Automated Machine Learning Learn about automl — automated machine learning.

-> ML System Design — Architecture and Production Patterns Learn about ml system design — architecture and production patterns.

Premium Content

Meta-Learning — Learning to Learn

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
💼Interview Prep
📜Certificates
🤝Community Access

Already a member? Log in

Need Expert Machine Learning Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement