Course contentsShow
← Machine Learning and Deep Learning
Lesson 2591 of 3,53856. Few-Shot and Meta-LearningFree lesson

Prototype Networks

Using class prototypes (mean embeddings) to classify query examples by nearest prototype.

Prototype Networks

What you'll learn: How to classify few-shot examples by computing class prototypes and measuring distance to the nearest one.

The Core Idea

Instead of comparing each query example to every support example individually (like k-NN), Prototype Networks create a single representative "prototype" for each class by averaging all support embeddings from that class. Classification then becomes finding which prototype is closest to your query embedding.

Think of it like this: if you've seen a few photos of three dog breeds (support set), you mentally form an "average Labrador look," an "average Poodle look," and an "average Beagle look." When shown a new dog photo (query), you compare it to these mental prototypes, not to each individual training photo.

How It Works

  1. Embed all support examples using a neural network encoder (same one used during meta-training)
  2. Compute class prototypes: For each class, take the mean of all support embeddings belonging to that class
  3. Embed the query example using the same encoder
  4. Measure distances from the query embedding to each class prototype (typically Euclidean distance)
  5. Classify by assigning the query to the nearest prototype's class

The beauty: you get one compact representation per class, making classification efficient and interpretable even with very few examples.

Mathematical Simplicity

If class c has support embeddings {e₁, e₂, ..., eₖ}, the prototype is simply:

prototype_c = mean(e₁, e₂, ..., eₖ)

Distance-based classification uses the embedding space learned during meta-training to make this averaging meaningful.

Key Takeaway: Prototype Networks simplify few-shot classification by representing each class as a single prototype (mean embedding), then classifying queries by nearest-prototype distance—elegant, efficient, and surprisingly effective.