"This looks like that": prototype networks
ProtoPNet classifies an image by how closely its parts match learned prototype patches, so the evidence is part of the computation. Learn the similarity score, the projection step, and why a readable prototype can still be a shortcut.
What runs in CodeSplash
- EXP012ProtoPNet: prototypical part network Explained here
You will be able to
- Describe ProtoPNet's patch distances, similarity scores and evidence layer
- Explain prototype projection and why it makes prototypes viewable
- Contrast interpretable-by-design models with post hoc explanations
- Name the checks a prototype explanation still needs
Explanation as part of the model
ReadEvery explainer so far looks at a finished model from outside. ProtoPNetProtoPNetAn image classifier that scores how closely parts of an image match learned prototype patches, then adds up that evidence. (prototypical part network) builds the explanation into the classifier: it learns a set of prototypes, small patches in the network's feature space, and classifies an image by how strongly parts of it resemble each prototype. Its answer comes with its reasons: "this region looks like that prototype, which counts toward this class".
It is a trained architecture, not a tool you can apply to an existing model.
Reference · EXP012 · Explained hereProtoPNet: prototypical part networkClassify an image using similarities between its latent patches and learned prototypes, making part-based evidence an explicit part of the computation.How it scores an image
ReadA convolutional encoder turns the image into a grid of latent patches. For each prototype , take the closest patch and turn its distance into a similarity:
A small distance gives a large similarity, and a final layer adds up the evidence per class. In the reference's example two prototypes match patches at squared distances 0.02 and 0.04, giving similarities 3.93 and 3.26.
Projection makes prototypes visible
ReadAfter training, each prototype is projected onto the nearest latent patch of an actual training image of its class. From then on, "prototype 7" is a piece of a real image you can show. Training also uses terms that pull prototypes toward patches of their own class and away from others.
That is what makes ProtoPNet readable: each piece of evidence points at a training-image patch. But the picture you see is the image region behind a latent patch, and the receptive field of that patch can be far larger than the highlighted box.
Predict: a readable shortcut
PredictPredict first
A bird classifier's most-used prototype for "waterbird" projects onto a patch of a real waterbird photo. Does that show the model recognizes waterbirds?
Reveal
No. The patch may be mostly water. If waterbirds were photographed over water, a background prototype classifies them well and fails on a waterbird on land. A readable prototype makes such a shortcut easier to spot, not impossible. Test on counterexamples.
Checks a prototype model still needs
Read- Report accuracy and prototype quality separately. A model can be accurate with unhelpful prototypes, or interpretable and less accurate.
- Inspect what each prototype matches across many images, not only its projected patch.
- Watch negative weights. Evidence against a class, and prototypes reused across classes, complicate the "this looks like that" story.
- Test localization and counterexamples, as with any saliency map.
Where it stands in CodeSplash
ReadCheck your understanding
CheckpointCheck yourself
How does ProtoPNet decide a class?
Show the answer
Answer: b
The evidence is part of the forward pass: distances to prototypes, similarities, then a linear evidence layer.
Check yourself
A colleague wants to use ProtoPNet to explain their already-trained ResNet. What's the issue?
Show the answer
Answer: b
Interpretable-by-design models explain themselves. For an existing model, use post hoc tools (Grad-CAM, attributions) and their checks.
Check yourself
Which check best tests whether a prototype is a background shortcut?
Show the answer
Answer: b
Counterexamples separate object evidence from context. One projected patch can't.
Recap
Recap- ProtoPNet classifies by similarity to learned prototype patches; the evidence is the computation.
- Projection ties each prototype to a real training patch you can view.
- It is trained, not post hoc, and a readable prototype can still be a shortcut.
- Explained here; CodeSplash's image classifier uses Grad-CAM instead.
Concepts in this lesson