ProtoNet
Few-shot image classifier that labels a query by its distance to each class's mean embedding.
Image classification · 34 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Image classification
- Parameters
- 111.9K
- Operations
- 34
- Framework
- PyTorch
- Recurrent
- No
- Published
- NeurIPS 2017
- Cited by
- 5,863 (as of 17 October 2026)
- Authors
- Jake Snell, Kevin Swersky, Richard S. Zemel
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m2291
- Graph hash
- a37f1cba62c72b49e9f63100f4fbb6c24c3aee15f2e74a1ee02b67e186655d74
- Skeleton hash
- 4229d9968bb5584390a7c00e079abccdd4fd5e57254effc572897d4acea8b6f6
- Architecture hash
- f88f907f9dab8e17fb830e7fe35fd57dea48d6afb1e249cabb970a5fafb858e2
- Diagram SHA-256
- fa0d6470b9e2b378dafa1b54f48e5da6096f8c8b8488a5d9c765e52ab248f045
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
Prototypical networks tackle few-shot classification, where a classifier must generalize to new classes not seen in the training set, given only a small number of examples of each new class. The idea is disarmingly simple: learn an embedding in which points cluster around a single prototype representation for each class, take each class's prototype to be the mean of its support set, and classify a query by finding the nearest prototype. Formally, embedded query points are classified via a softmax over distances to class prototypes.
The captured member is the paper's Omniglot embedding network: four convolutional blocks, each comprising a 64-filter 3 × 3 convolution, batch normalization, a ReLU nonlinearity and a 2 × 2 max-pooling layer. On 28 × 28 Omniglot images this architecture results in a 64-dimensional output space, and the same encoder embeds both support and query points. The trace runs a single 5-way, 5-shot episode with 15 query points per class, mirroring the paper's practice of matching train shot to test shot.
Two design choices did most of the work: squared Euclidean distance instead of the cosine distance used by matching networks, and training with more classes per episode than will be used at test time. The authors conjecture the distance effect arises because cosine distance is not a Bregman divergence, which breaks the model's equivalence to mixture density estimation with class means as optimal cluster centres. On miniImageNet the paper calls its results state-of-the-art by a wide margin. The same machinery stretches to zero-shot learning by embedding class meta-data vectors as prototypes, and the paper reports state-of-the-art results on the CU-Birds dataset.
Key idea. Prototypical networks learn a metric space in which classification can be performed by computing distances to prototype representations of each class, with each prototype simply the mean of its embedded support points.
- ProtoNet
- Prototypical Networks
- prototypical network
- few-shot learning
- few-shot classification
- one-shot learning
- metric learning
- Omniglot
- miniImageNet
- episodic training
- zero-shot learning
- class prototype
- Snell
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{snell2017prototypicalnetworksfewshotlearning,
title={Prototypical Networks for Few-shot Learning},
author={Jake Snell and Kevin Swersky and Richard S. Zemel},
year={2017},
eprint={1703.05175},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1703.05175},
}