Barlow Twins Identity Target
Line up two views of one photo feature by feature, keep matching slots near one, and push different slots toward zero. Redundancy falls and useful factors stay.
Why Does This Exist?
Contrast can keep redundant features because any correlated pair still matches. Barlow Twins asks for more: each feature slot should match itself across views and ignore other slots. That cuts redundancy directly. Readers who know siamese networks get the twin shape; the new part is the matrix target, not a pair list.
This page covers the correlation loss only. Pair losses live in contrastive loss.
The one idea you need first.
Cross-correlation is a matrix over a batch: is the correlation of slot in view A with slot in view B. Identity means ones on the diagonal and zeros elsewhere.
Think of It Like This
Two choirs singing the same score in tune
Two choirs sing one score in separate rooms. Matching voice parts should agree note for note, while soprano should not copy bass. A judge scores tuning within parts and leakage across parts.
Diagonal ones are in-tune parts, off-diagonal zeros are no leakage, and weight sets how harshly leakage counts. Where it stops: choirs hear each other, while the two views train from separate crops.
How It Actually Works
Normalize projector outputs and over the batch to zero mean and unit variance per slot. Form for batch size . Loss is with and width .
In plain words: averages over the batch, is the wide projector, and trades invariance against decorrelation.
Worked example
Say and measured . Diagonal terms give . Off-diagonal give , times is . Total . Training pushes diagonals to and wipes the leak, which is exactly redundancy leaving the code.
Watch Out For
Small projector that hides the gain
A 256-dim head cannot hold 8192 decorrelated slots, so off-diagonal pressure does little. The symptom is weak transfer despite low loss. Use a wide projector near 8192 and batch-norm on its output beforeStats.
The Quick Version
- Barlow Twins matches two views by driving cross-correlation toward identity.
- Diagonal ones demand view invariance per slot.
- Off-diagonal zeros with weight 0.005 cut redundancy.
- Wide projectors near 8192 dims matter.
- No negatives, queues, or cluster passes are used.