Contrastive self-supervised learning with SimCLR
contrastive learning mechanics.
two augmentations of one image form a positive pair, other images in the batch are negatives; an encoder plus projection head and the NT-Xent loss pull positives together and push negatives apart.
WHAT THIS TESTS: Whether you can explain how augmentations, positive and negative pairs, and the contrastive loss produce useful representations without labels.
A GOOD ANSWER COVERS: SimCLR learns by instance discrimination. Take an image and apply two independent random augmentations, such as cropping, color jitter, and blur, producing two correlated views; these two views form a positive pair because they come from the same source image. Every other image's augmented views in the same batch are treated as negatives for that anchor. A shared base encoder, for example a ResNet, maps each view to a representation, and a small projection head, typically an MLP, maps representations to the embedding space where the loss is computed; the projection head is discarded after pretraining and the encoder is what you keep. The objective is the normalized temperature-scaled cross-entropy loss, NT-Xent: for each anchor it forms a softmax over cosine similarities to all other views, with a temperature parameter, and maximizes the similarity to its positive while minimizing similarity to all negatives. The strength of the augmentations and a large batch, which supplies many negatives, are critical to learning representations that transfer well to downstream tasks.
COMMON WRONG ANSWERS: Saying positives are two different source images of the same class, which would require labels; dropping the augmentation step that creates the views; ignoring the role of the projection head or keeping it for downstream use; forgetting that negatives come from the batch; underplaying the importance of strong augmentation and batch size.
LIKELY FOLLOW-UPS: Why discard the projection head before fine-tuning? Why does SimCLR need very large batches and how do later methods avoid that? What role does temperature play? Which augmentations matter most and why is color distortion important?
ONE CONCRETE EXAMPLE: In a batch of 256 images, each yields two augmented views, giving 512 views. For an anchor view of a particular dog photo, its positive is the other augmentation of that same photo and its 510 negatives are all other views. NT-Xent pulls the two dog-photo views together in embedding space and pushes them away from everything else; after pretraining, the encoder produces features that fine-tune to strong classification accuracy with few labels.
Read the original → arxiv.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.