tezvyn:

Prototypical Networks: Learning from a Handful of Examples

AI-drafted, machine-checkedSource: arXivintermediate

Prototypical Networks classify new categories from few examples by finding the average representation, or 'prototype,' for each class. This is key for few-shot image recognition where you have only 1-5 examples.

WHY IT EXISTS: Standard deep learning models need thousands of examples per class. But what if you only have a handful of images for a new category? Few-shot learning addresses this, and Prototypical Networks are a simple, effective solution. They aim to generalize from a small 'support set' of examples to new, unseen classes.

THE MENTAL MODEL: Imagine plotting points on a map where each city represents a class (e.g., 'cat,' 'dog'). A Prototypical Network learns to draw a map (the embedding space) where examples of the same class are tightly clustered. The 'prototype' is the geometric center of a class's cluster. To classify a new image, you plot it on the map and see which city center it's closest to.

HOW IT WORKS: The network learns an embedding function that maps an input, like an image, to a vector in a high-dimensional space. During a few-shot task, you provide a small 'support set' of examples for each new class. The network embeds each of these examples. The 'prototype' for that class is simply the mean of these embedding vectors. To classify a new 'query' image, it's also embedded, and its distance (usually Euclidean) to each class prototype is calculated. The class with the minimum distance is the predicted label.

WHEN TO USE IT: Use Prototypical Networks when you need to classify new categories with very few labeled examples (e.g., 1-shot or 5-shot learning). They are effective in image recognition, character recognition, and other domains where you can't afford to collect large datasets for every new class you might encounter. Their simplicity makes them a strong baseline.

WHEN NOT TO USE IT: They may be less effective when a class has high variance, meaning its examples don't form a single, tight cluster in the embedding space. More complex models might handle such distributions better. If you have abundant data for all classes, standard supervised classification is usually more powerful and appropriate.

ONE CANONICAL EXAMPLE: In a 5-shot bird classification task, you're given 5 images of a 'Blue Jay' and 5 of a 'Cardinal'—classes the model has never seen. The network embeds all 10 images. The 'Blue Jay prototype' is the average of the 5 Blue Jay embedding vectors. The 'Cardinal prototype' is the average of the 5 Cardinal vectors. Given a new, unlabeled image of a Blue Jay, it's embedded, and its distance to the Blue Jay prototype will be smaller than to the Cardinal prototype, leading to a correct classification.

Read the original → arxiv.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.