Prototypical Networks
What you'll learn: How Prototypical Networks classify new examples by computing class prototypes from support examples and using nearest-centroid decisions.
The Core Idea
Prototypical Networks solve few-shot classification by creating a prototype (representative point) for each class in an embedding space. Given a support set with labeled examples, the network:
- Embeds all support examples using a learned embedding function
- Computes the mean embedding (centroid) for each class — this is the prototype
- Classifies query examples by finding which prototype they're nearest to
Think of it like this: if you see 5 photos of cats and 5 of dogs, you mentally create an "average cat" and "average dog" concept. When shown a new animal, you decide which average it's closer to.
How It Works
For each class c, the prototype is simply:
prototype_c = mean(embeddings of all support examples in class c)
To classify a query example q:
- Embed it:
embedding_q = f(q) - Compute distances to all prototypes (typically Euclidean distance)
- Assign the class of the nearest prototype
The model is trained end-to-end by minimizing classification loss, which encourages the embedding function to create spaces where same-class examples cluster together.
Why This Matters
Unlike Siamese or Relation Networks that compare pairs, Prototypical Networks are efficient: you only compute N prototypes for N classes, not pairwise comparisons. The nearest-centroid rule is simple yet powerful, making the approach both interpretable and scalable.
Key Takeaway: Prototypical Networks classify by computing class prototypes as mean embeddings of support examples, then assigning queries to the nearest prototype — a simple, elegant approach to few-shot learning.