SwAV Clustered Contrast
Group photos into a few thousand clusters online, then ask two views of one photo to agree on the group. No pair list and no giant batch needed.
Why Does This Exist?
Pairwise contrast needs many negatives per query, which costs memory. SwAV replaces pairs with groups: learn prototype vectors through , assign each view a soft cluster code, and force the two views of one photo to predict each other codes. The batch only needs to fill the clusters, so image classification backbones train on modest hardware.
This page covers swapped cluster prediction only. Plain pair losses live in contrastive loss.
The one idea you need first.
A prototype is a learned cluster center. The code for view is a distribution over prototypes, computed with a Sinkhorn pass that keeps every prototype used about equally. Balanced use stops collapse to one group.
Think of It Like This
Two librarians shelving one book twice
Two librarians each receive a different photocopy of one book cover. Each must pick the shelf it belongs on from 3000 shelves, then they swap slips and check they chose the same shelf. To agree, both must read the cover rather than the copy marks.
Prototypes are shelves, codes are slips, and swapping is the check. Where it stops: library shelves are fixed, while SwAV prototypes move as training proceeds.
How It Actually Works
Encode views to and . Score each against prototypes by where holds the centers. Turn scores into codes and with Sinkhorn balancing over the batch. Train view to predict and view to predict with cross entropy, keeping learned by gradient.
In plain words: is the shelf set, is the balanced assignment, and the swap forces view-invariant groups.
Worked example
Take prototypes and scores for view . Exponentials are , summing to . Code is . View of the same photo scores , giving after the same step. Predicting from view needs the log loss on that slot, which falls only when both views land in the same group.
Watch Out For
Cluster collapse without balancing
Without Sinkhorn or an even-use rule, all views pile into three or four prototypes and accuracy flatlines. The symptom is a few huge clusters plus hundreds empty. Keep the balancing pass and check prototype usage every epoch.
The Quick Version
- SwAV learns 3000 prototypes and assigns each view a balanced cluster code.
- Two views of one photo predict each other codes after a swap.
- Sinkhorn balancing stops collapse to a few groups.
- Multi-crop adds small views that sharpen the assignment.
- No pairwise negatives and no momentum queue are needed.