Self-supervised learning that decorrelates instead of contrasting
A PyTorch implementation of Barlow Twins, which learns image representations by reducing redundancy between twin networks rather than pushing negatives apart.

What it does
Barlow Twins trains a ResNet-50 to produce useful image representations without labeled data. It takes two augmented views of the same image, feeds them through identical networks, and shapes the output so that corresponding features correlate while everything else decorrelates. The repo includes training code, a pretrained model, and evaluation scripts for linear probing and semi-supervised finetuning on ImageNet.
The interesting bit
The method sidesteps the negative-sample mining that tripped up earlier contrastive approaches. Instead of pushing dissimilar pairs apart, Barlow Twins uses a cross-correlation matrix and an off-diagonal loss term to simply make the twin outputs less redundant. It’s a different lever for the same problem, and the paper comes from LeCun’s group at FAIR.
Key highlights
- Pretrained ResNet-50 available via direct download and PyTorch Hub (
torch.hub.load) - Achieves 73.5% top-1 / 91.0% top-5 ImageNet accuracy with linear evaluation after 1000 epochs
- Includes evaluation modes for both frozen linear probes and semi-supervised finetuning
- Community has ported the method to CIFAR-10, TensorFlow, and even EEG signal learning
- MIT licensed, explicitly permitting commercial use
Caveats
- Training the best model takes ~7 days on 16 V100 GPUs; this is not a casual experiment
- Code targets PyTorch 1.7.1 / torchvision 0.8.2; newer versions should work but are untested by the authors
- No distributed training without SLURM is officially supported; you’ll need community workarounds for other setups
Verdict
Worth a look if you’re researching self-supervised representation learning or need a solid ImageNet-pretrained backbone without the licensing friction of some alternatives. Skip it if you’re hoping to train something competitive on a single GPU over the weekend.