Self-supervised learning: contrastive, non-contrastive and masked modelling
Before this lesson: lesson 09 (attention, the encoders) and lesson 07 (image encoders). The vision transformer and its patch tokens (used by MAE) are in lesson 11. From the information-theory track: entropy, KL divergence and cross-entropy, and mutual information with its chain rule. Section 3 recalls what the proof needs. Time: about 75 minutes, plus the notebook.
Why this matters #
Nearly every foundation model is pretrained without labels. CLIP learns from image–caption pairs and gives the image encoders of many multimodal language models and the text encoders of text-to-image diffusion models. DINO and MAE give vision backbones that work for segmentation and depth with few labels. BERT's masked-token objective is masked modelling for text. In science, SSL is the default for large unlabelled archives: satellite images, weather reanalysis fields and continuous seismic records. Interviews ask two things here: "write the CLIP loss" and "why does this method not collapse?"
1. Predict first #
2. The picture #
Two views, one image, and the trap #
Take an image . Make two random views and of it, for example a random crop and a colour change. An encoder maps each view to a vector, its embedding. We want the two embeddings to be close, because they show the same content.
The trap: collapse. "Make the two vectors close" has a trivial solution: map every input to the same vector. Then all pairs are perfectly close, and the encoder has learned nothing. This is collapse. Every SSL method needs a second force that prevents it. There are three families:
- Contrastive (SimCLR, MoCo, CLIP): also push apart the embeddings of different images. Training becomes a classification: "which of these candidates is my partner?"
- Non-contrastive (BYOL, SimSiam, DINO): no negatives. An asymmetry between two networks (a predictor head, a stop-gradient, a slowly moving teacher) prevents collapse.
- Masked modelling (MAE, BERT): hide part of the input and reconstruct it. The target is the data itself, so a constant output cannot succeed.
The similarity matrix #
Simplest case: . Two images and their two text captions. The model computes a table of similarities, one row per image and one column per caption. Training raises the diagonal (the matching pairs) and lowers the off-diagonal (the wrong pairs). With candidates, a random guess is right with probability . This is where the in the theory comes from.
Drag the points on the unit circle. Each blue point is an image embedding and each aqua point is a text embedding , all of length 1. The first table is the cosine similarity (darker = larger, aqua outline = matching pair); the second is the softmax of each row of (the probability that image picks caption ). Notice: with aligned pairs the diagonal wins and the loss is small; with collapsed embeddings every row is uniform and the loss is ; a smaller makes the rows sharper. The bound never exceeds .
Two forces. Wang and Isola (2020) split a contrastive loss into two parts. Alignment pulls the two views of one image together. Uniformity spreads all embeddings over the sphere. The negatives give the uniformity. Without them, nothing stops collapse.
Press Play to train a tiny encoder. Ten images have two noisy views each (a filled and a hollow blue dot, joined by a line); a linear encoder maps them to the unit circle. With alignment only, the two views of each image meet, but all points also slide to one spot: collapse. With alignment + uniformity, the pairs stay close and the images spread around the circle. The magenta arrow is the mean embedding ; its length is near 1 after collapse and near 0 when the embeddings are well spread.
A contrastive model computes the InfoNCE loss over candidates. The encoder has collapsed: every embedding is the same vector. What is the loss?
All logits are equal, so each softmax gives probability to the positive, and the loss is . This is the loss of a random guess. The positive similarity is 1, but the negatives have similarity 1 too, so the denominator makes collapse expensive. ( would need 7 candidates; SimCLR's NT-Xent has candidates, so its collapsed loss is .)
3. Definitions and main results #
Notation. A batch has pairs . For SimCLR, and are two views of image ; for CLIP, an image and its caption. Encoders give embeddings , normalized to length 1. Then is the cosine similarity, is the similarity matrix, and is the temperature.
The InfoNCE loss is a cross-entropy #
Row of is a vector of logits over the candidates , and the correct class is . The InfoNCE loss is the mean cross-entropy of the rows:
In code this is cross_entropy(S / tau, labels=arange(N)). The other items of the batch
are the negatives. They are called in-batch negatives: no extra negative sampling is needed.
CLIP (Radford et al. 2021) uses both directions: image→text (a softmax over each row) and text→image (a softmax over each column, that is, the rows of ):
CLIP learns as a scalar parameter (stored as a logarithm), starts at , and clips it so that the logit scale never exceeds 100. It trained on 400 million pairs with batch size 32,768.
SimCLR's NT-Xent loss (Chen et al. 2020) puts all views in one pool. For view , the positive is the other view of the same image, and the negatives are the other views. The view itself is excluded, so each softmax has terms.
The gradient and the temperature #
Write and for the loss of row . The gradient of a cross-entropy with respect to its logits is "probabilities minus one-hot". With the chain rule through the division by :
where if and 0 otherwise.
- The positive is pulled up with weight .
- Negative is pushed down with weight , which is proportional to .
- So the ratio of the weights of two negatives is . A small puts almost all the push on the hardest negatives: the wrong items that are most similar.
- As , : a hinge on the hardest negative. A large weights all negatives nearly equally.
Move the temperature slider. One anchor has a positive with similarity and seven negatives. The bars show the share of the total push that each negative gets ( divided by the sum over the negatives). At the push is spread over all negatives; at almost all of it goes to the hardest one. Lower below the hardest negative and watch approach the hinge .
Row 1 of a batch has softmax probabilities at ; the positive is column 1. What is ?
The gradient is . The negative sign on the positive means that gradient descent raises . Option 2 forgets the factor from the logits .
InfoNCE lower-bounds mutual information #
The mutual information measures how much knowing tells you about , in nats. It is 0 when and are independent. Contrastive learning is often described as "maximizing the mutual information between views". The precise statement is a bound.
Theorem (InfoNCE bound; Oord et al. 2018, Poole et al. 2019). Let . Draw an index uniformly from . Let be the partner of (a sample of ), and let the other , , be independent samples of . For any function (the critic), define
Then . The best critic is for any function , and the bound can never exceed .
A contrastive batch is this setting. Row uses , the candidates are , the negatives come from other pairs (so they are independent of ), and the critic is . The temperature is part of the critic.
Why this is true: the loss is the log-loss of a classifier that guesses which of the candidates is the partner. No classifier can beat the true posterior. The true posterior can only beat a random guess () by using information that carries about , and that information is at most .
Proof (seven steps)
Write for everything the critic sees. Two facts from information theory: the cross-entropy of under is (Gibbs' inequality), and the chain rule .
- The loss is a classifier's cross-entropy. The critic defines a guess for the index of the positive, . So .
- Cross-entropy is at least entropy. For every , . Average over : .
- is uniform, so . Hence .
- The joint density. . Integrate out : . So is independent of , that is, . Divide the two lines: .
- Chain rule. . Also , and mutual information is non-negative, so .
- Only the partner carries information about . By step 4, depends on only through , and . So .
- Combine steps 3, 5 and 6: .
The optimal critic. Step 2 is tight when . By step 4, , so . A softmax over ignores any term that depends on only. So : the pointwise mutual information, up to a term in .
The ceiling. A cross-entropy is never negative, so . When , the estimate is biased low, whatever the critic. To certify nats you need candidates. This is one reason contrastive methods like large batches.
Bounded logits. With cosine similarity, every logit lies in . Even with perfect embeddings (, all ), the row loss is at least . With a fixed and this is 6.32, so the bound can show at most nats. This is one reason for small or learned temperatures.
A contrastive model uses batches of . Whatever the encoder and the temperature, what is the largest mutual information that can certify?
The loss is a cross-entropy, so and nats (12 bits is the same amount in base 2, but the loss uses natural logarithms). To certify more, you need more candidates: .
Answers to section 1. (1) At most nats, far below 20. The estimate saturates at . (2) Collapse is a fixed point of BYOL's loss, but the predictor, the stop-gradient and the slowly moving target make the training dynamics avoid it in practice. SimSiam shows that the stop-gradient is essential: remove it and the model collapses. There is no complete theory of why this works; the explanation is an empirical finding with partial analyses for linear models.
How each method avoids collapse #
SimCLR (contrastive). NT-Xent with in-batch negatives. If all embeddings are equal, every logit is the same and the loss is , its value for a random guess. The denominator makes collapse expensive. Other findings of the SimCLR paper:
- Augmentations define the task. The model learns what stays the same across views. Random crop plus colour distortion is the key pair. With crops alone, colour histograms identify the image, and the model learns little else.
- Projection head. The loss is applied to , a 2-layer MLP on top of the encoder output . Downstream you use : it is more than 10% better in linear evaluation than , because is trained to be invariant to the augmentations and so discards information.
- Batch size and . Batches from 256 to 8192 (16,382 negatives per positive pair), with the LARS optimizer. With -normalized embeddings and batch 4096 (100 epochs), gave 64.4% top-1, against 59.7% for and 60.7% for (their Table 5). Global BatchNorm across devices is needed: with statistics per device, the model can recognize the positive pair by a statistics shortcut.
MoCo (contrastive with a queue). The negatives come from a queue of keys from earlier batches. The keys are encoded by a momentum encoder: an exponential moving average (EMA) of the query encoder, with momentum . So the keys in the queue stay consistent. Many negatives, small batches.
BYOL (non-contrastive). An online network (encoder, projector, predictor ) and a target network (encoder, projector) whose weights are an EMA of the online weights, , with from 0.996 up to 1. The loss is the squared distance between the normalized prediction and the normalized target projection (it equals ), with a stop-gradient on the target: no gradient flows into the target branch. Collapse is a solution of the loss, but the training dynamics do not go there in practice. SimSiam (Chen and He 2021) removes the EMA and shows that the predictor plus the stop-gradient is enough; without the stop-gradient, the model collapses at once.
DINO (self-distillation). A student and a teacher (an EMA of the student) output a softmax over dimensions. The student is trained with the cross-entropy to match the teacher on other views (multi-crop: two global 224-pixel views for the teacher, extra small 96-pixel local views for the student). Two operations on the teacher output prevent collapse:
- centering: subtract an EMA of the teacher's mean output over the batch. This stops one dimension from dominating, but alone it pushes towards a uniform output;
- sharpening: a low teacher temperature ( from 0.04 to 0.07, student ). This pushes away from uniform, but alone it lets one dimension dominate.
The two effects balance each other.
MAE (masked modelling). Cut the image into patches, as in the vision transformer. Remove a random 75% of them (uniform sampling without replacement). The ViT encoder runs only on the visible 25%, with no mask tokens. A light decoder (by default 8 blocks of width 512, under 10% of the encoder's compute per token) takes the encoded patches plus mask tokens and predicts the pixels. The loss is the mean squared error on the masked patches only; targets with the pixels normalized per patch work better.
Move the mask ratio. The left panel is the image, cut into patches. The middle panel is what the encoder sees: only the visible patches (masked patches are grey). The right panel fills the masked pixels by repeated averaging of neighbouring pixels: a "reconstruction" with no learning at all. Notice: at 25% masking this smooth fill is already good (relative error about 0.08), so the task teaches little; at 75% the error is about 3 times larger, and whole shapes are lost. A model must understand the picture to do better. The magenta curve is this error against the mask ratio; the readout gives the number of encoder tokens and the cost relative to the full image.
Why 75%? Images are spatially redundant: at a low ratio, a missing patch can be filled in from its neighbours with little understanding. BERT masks only 15% of the tokens, because each word carries much more information. Removing the masked patches from the encoder also makes pretraining 3 times or more faster.
| Method | Negatives | What prevents collapse | Key knobs |
|---|---|---|---|
| SimCLR | in-batch, | contrastive denominator | augmentations, , , projection head |
| MoCo | queue of 65,536 | contrastive denominator | queue size, momentum 0.999 |
| CLIP | in-batch, per direction | contrastive denominator | batch 32,768, learned |
| BYOL / SimSiam | none | predictor + stop-gradient (+ EMA target) | EMA rate, predictor |
| DINO | none | EMA teacher + centering + sharpening | , multi-crop |
| MAE | none | reconstruction target | mask ratio 75%, decoder size |
Why does MAE mask 75% of the image patches, while BERT masks only 15% of the words?
Images are spatially redundant. With few patches missing, interpolation from the neighbours solves the task without understanding the content, so the encoder learns little. A word carries much more information, so 15% masking is already hard. The speed-up (the encoder sees only 25% of the tokens) is a second benefit, not the reason.
Using the learned representation #
After pretraining, the encoder output (not the projection-head output ) is the representation. There are four standard ways to evaluate and use it.
- Linear probe. Freeze the encoder. Compute for the labelled examples and train only a linear classifier (logistic regression) on it. The accuracy measures how much of the label information is linearly available in . This is the standard test in the SimCLR, MoCo and BYOL papers. A SimCLR ResNet-50 (4×) reached 76.5% top-1 on ImageNet under this protocol, the accuracy of a supervised ResNet-50.
- k-NN evaluation. Freeze the encoder, normalize , and classify a test example by a vote of its nearest labelled neighbours (DINO uses , with votes weighted by similarity). No training at all, and no hyperparameters to tune, so it is a quick and honest check.
- Fine-tuning. Start from the pretrained weights and train all of them on the labelled task, with a small learning rate (for ViTs often with smaller rates for the early layers). This usually gives the best accuracy when there are enough labels. MAE features are weaker than contrastive features under a linear probe, but they fine-tune very well (He et al. 2022, §4.3). SimCLR fine-tuned on only 1% of the ImageNet labels reached 85.8% top-5 accuracy.
- Zero-shot classification (CLIP). No labelled examples at all. Write one text prompt per class ("a photo of a cat", "a photo of a dog", …), encode the prompts with the text encoder, and classify an image by the softmax over its cosine similarities with the prompts. This is one row of the CLIP similarity matrix. CLIP's best model reached 76.2% top-1 on ImageNet zero-shot, matching the original ResNet-50, which was trained on 1.28 million labelled images.
Rules of thumb: very few labels → linear probe or k-NN on frozen features; many labels → fine-tune; classes given only as names → zero-shot.
You pretrained SimCLR and want a linear probe on 1,000 labelled images. Which features do you give the logistic regression?
The projection head is trained to be invariant to the augmentations, so throws away information (colour, orientation) that downstream tasks may need. SimCLR found more than 10% better than under linear evaluation. The notebook shows the same effect on small digit images.
4. Worked example #
(a) The CLIP loss for . Cosine similarities (row = image, column = text) and the logits:
Divide the numerator and the denominator of the row softmax by . Then row 's loss is .
- Image 1: .
- Image 2: .
- Image 3: . Text 1 (similarity 0.5) is a hard negative for image 3.
So . The columns give , and , so and . The bound: nats, out of at most .
(b) Same embeddings, . Now , so the bound is only nats. The embeddings did not change; only the critic did. The bound holds for every critic, and a better critic gives a tighter bound.
(c) The gradient for image 1, . The softmax of row 1 of is . So . The negative with similarity 0.4 gets times the push of the negative with similarity 0.2. At the factor is only .
(d) Zero-shot. An image embedding has cosine similarities with the prompts for "cat", "dog" and "car". With the logits differ from the largest by , so the softmax is : "cat".
(e) MAE token count. ViT-B/16 at 224 pixels: patches. With 75% masked, the encoder sees . The per-token costs (MLP, projections) drop to 1/4. The cost of the attention matrix drops to .
5. In code #
PyTorch checks the worked example, the gradient, the collapse value, the effect of bounded cosine logits, and zero-shot classification. The notebook for this lesson has these cells and the exercises.
import numpy as np
import torch
import torch.nn.functional as F
# 1. Worked example: CLIP loss as cross-entropy over the similarity matrix
S = torch.tensor([[0.9, 0.2, 0.4],
[0.1, 0.8, 0.3],
[0.5, 0.0, 0.7]], dtype=torch.float64) # S[i, j] = cos(image i, text j)
labels = torch.arange(3) # the positive of row i is column i
for tau in (0.2, 1.0):
l_it = F.cross_entropy(S / tau, labels) # image -> text: softmax over each row
l_ti = F.cross_entropy(S.T / tau, labels) # text -> image: softmax over each column
print(tau, round(l_it.item(), 4), round(l_ti.item(), 4),
round((l_it + l_ti).item() / 2, 4), round(np.log(3) - l_it.item(), 3))
# 0.2 0.1826 0.1717 0.1772 0.916
# 1.0 0.7755 0.7745 0.775 0.323
# 2. Gradient of the row-1 loss with respect to the similarities: (p - e_1) / tau
S1 = S.clone().requires_grad_(True)
F.cross_entropy(S1[:1] / 0.2, labels[:1]).backward()
print(S1.grad[0].numpy().round(4)) # [-0.5047 0.1357 0.369 ]
# 3. SimCLR NT-Xent on 2N views; a collapsed encoder (all embeddings equal) costs log(2N - 1)
N = 4
z = F.normalize(torch.ones(2 * N, 16, dtype=torch.float64), dim=1)
logits = z @ z.T / 0.5
logits.fill_diagonal_(float("-inf")) # a view is not its own negative
pos = (torch.arange(2 * N) + N) % (2 * N) # view i and view i + N come from one image
print(round(F.cross_entropy(logits, pos).item(), 4), round(np.log(2 * N - 1), 4)) # 1.9459 1.9459
# 4. Cosine logits lie in [-1/tau, 1/tau]: a lower bound on the loss for N = 4096
N = 4096
for tau in (1.0, 0.1):
best = np.log1p((N - 1) * np.exp(-2 / tau))
print(tau, f"{best:.2g}", round(np.log(N) - best, 3))
# 1.0 6.3 1.998
# 0.1 8.4e-06 8.318
# 5. Zero-shot classification = one row of the similarity matrix
img = F.normalize(torch.tensor([[0.8, 0.6, 0.1]]), dim=1) # one image embedding
prompts = F.normalize(torch.tensor([[1.0, 0.2, 0.0], # "a photo of a cat"
[0.1, 1.0, 0.0], # "a photo of a dog"
[0.0, 0.1, 1.0]]), dim=1) # "a photo of a car"
probs = F.softmax(img @ prompts.T / 0.07, dim=1)
print(probs.numpy().round(3)) # [[0.961 0.039 0. ]]
Part 4 shows that a fixed with cosine similarity can never certify more than about 2 nats with 4096 candidates, even with perfect embeddings: the logits cannot spread far enough.
6. Where it shows up #
- Vision–language models. CLIP-style contrastive pretraining gives the image encoders of many multimodal language models and the text encoders of text-to-image diffusion models.
- Vision backbones. DINO and its successors give features for segmentation and depth without labels. MAE pretraining is a standard start for large ViTs (ViT-H reached 87.8% ImageNet top-1 after fine-tuning, with ImageNet-1K data only).
- Language models. BERT's masked-token objective is masked modelling; next-token prediction (lesson 08) is also self-supervised: the target is the next word of the text itself.
- Earth observation and weather. Prithvi (NASA and IBM, 2023) pretrains a ViT as an MAE on Harmonized Landsat Sentinel-2 imagery, with 3-D (time × space) patches. Masked reconstruction is natural for gridded geophysical fields, where clouds and gaps already mask parts of the data.
- Seismology. SeisCLIP (Si et al. 2023) trains a transformer on time–frequency spectra of waveforms and an MLP on phase and source information of the same event, contrastively. Then it fine-tunes the spectrum encoder for event classification, location and focal mechanism.
- Practice. Choose augmentations that keep the physics you care about. A random crop of a weather field changes the location; a colour jitter has no physical meaning. The augmentations decide which invariances the encoder learns.
7. Common mistakes #
- Using the projection-head output downstream. Use the encoder output .
- Forgetting to normalize the embeddings. The temperature then has no fixed meaning, and SimCLR's results drop a lot without normalization.
- Reading as the mutual information. It is a lower bound, capped at . A pair with high mutual information always looks like "".
- False negatives. In-batch negatives can be true matches (two photos of the same dog, two captions that fit both images). They get pushed apart anyway.
- BatchNorm statistics per device in SimCLR, or a too small (unstable; all the gradient goes to a few negatives).
- Low mask ratios for images. BERT's 15% is right for text, not for pixels.
- Thinking BYOL has no collapse solution. It has one; the training dynamics avoid it.
- Judging an MAE encoder only by a linear probe. Masked models can probe poorly and still fine-tune best; report both.
8. Check yourself #
- SimCLR with images (512 views). Give the number of negatives per anchor and the loss of
a collapsed encoder.
Answer
negatives. All logits are equal, so each softmax gives to the positive: the loss is . - . An anchor has two negatives with cosine similarity 0.9 and 0.1. What is the ratio
of their gradient weights?
Answer
. Almost all the push goes to the hard negative. - In the proof of the InfoNCE bound, why is , and where is it used?
Answer
The joint density of is : without , all candidates are independent samples of , whatever is. It makes in the chain rule (step 5). - What is the optimal critic of InfoNCE, and why can you add any to it?
Answer
, the pointwise mutual information. The softmax is over the candidates for a fixed , so a term that depends on only cancels. - CLIP with a fixed and . Even with perfect embeddings, what is the largest
bound it can reach, and why?
Answer
The logits lie in , so the loss is at least , and the bound is at most nats. CLIP learns (starting at 0.07) to avoid this. - Why does DINO need both centering and sharpening?
Answer
Centering alone stops one dimension from dominating, but drives the teacher output towards uniform. Sharpening (a low ) alone does the opposite. Together they balance, and neither collapse mode wins.
Write the InfoNCE loss for a batch of pairs with cosine similarities .
, that is,
cross_entropy(S / tau, arange(N)).Write the CLIP loss in terms of the similarity matrix .
: rows for image→text, columns for text→image.
What is collapse in self-supervised learning?
The encoder maps every input to (nearly) the same vector. The alignment loss is then perfect, but the features carry no information.
State the InfoNCE bound on mutual information.
for any critic, where is the number of candidates.
Why can the InfoNCE estimate never exceed ?
is a cross-entropy, so it is , and . Certifying nats needs .
Compute the loss of a collapsed encoder under SimCLR's NT-Xent with images.
: all logits are equal, so the positive gets probability .
Give the gradient of a row loss with respect to , and say what a small does.
. A small gives almost all the push to the hardest negatives (weight ).
What prevents collapse in BYOL and SimSiam?
A predictor on the online branch and a stop-gradient on the target branch (BYOL also uses an EMA target). Without the stop-gradient, SimSiam collapses.
What is the MAE recipe?
Mask a random 75% of the patches, run the encoder only on the visible 25%, and train a light decoder to predict the pixels of the masked patches (MSE on masked patches only).
What is a linear probe?
Freeze the pretrained encoder and train only a linear classifier on its features ; the accuracy measures how linearly available the labels are.
9. Interview angle #
- "Write the CLIP loss." — Normalize both embeddings, logits , cross-entropy with
labels
arange(N)on the rows and on the columns, and average the two. - "Why do contrastive methods want large batches?" — More negatives make the task harder and the gradient less noisy, and the bound is capped at . MoCo gets many negatives from a queue instead.
- "How does BYOL avoid collapse without negatives?" — A predictor, a stop-gradient and an EMA target. Collapse is a solution, but not where the dynamics go (SimSiam: the stop-gradient is essential).
- "Why does MAE mask 75%?" — Spatial redundancy makes low ratios too easy. The encoder runs only on the visible patches, so pretraining is 3 times or more faster.
- "How do you evaluate a self-supervised model?" — Linear probe and k-NN on frozen features, fine-tuning with few labels (1%, 10%), and transfer to other tasks; zero-shot for CLIP.
- "Contrastive or masked for my scientific data?" — Contrastive learning needs augmentations that keep the meaning (hard for physical fields). Masked modelling needs no augmentations and fits gappy gridded data.
10. Practice #
The notebook for this lesson runs in Colab. It uses NumPy for the losses and PyTorch for training a small encoder (under a minute on a CPU). Five exercises, each with a check cell and a folded solution:
- The CLIP loss from a similarity matrix, written as cross-entropy, checked on the worked example.
- The gradient of a row loss, checked against finite differences.
- SimCLR's NT-Xent loss on views in PyTorch; a collapsed encoder costs .
- Contrastive pretraining of a small MLP on the scikit-learn digits with shift, noise and masking augmentations, then a linear probe on and on , against a random encoder.
- The smallest possible loss with cosine logits for a given and , and the largest mutual information the bound can then certify.
11. Watch and read #
- Lilian Weng, Contrastive Representation Learning: sections "InfoNCE", "Large batch size", "Hard negative mining", "SimCLR", "BYOL", "MoCo & MoCo-V2" and "CLIP".
- Simon Prince, Understanding Deep Learning (free PDF), chapter 14 (unsupervised learning) and the sections on self-supervised learning and transfer learning in chapter 9.
- Poole et al., On Variational Bounds of Mutual Information (2019): §2.3 (multi-sample bounds, eq. 10 InfoNCE, the ceiling and the optimal critic).
- Chen et al., A Simple Framework for Contrastive Learning of Visual Representations (SimCLR, 2020): §2.1 (method, NT-Xent), §3 (augmentations), §4.2 (projection head), §5.1 (temperature, Table 5), §5.2 (batch size).
- Radford et al., Learning Transferable Visual Models From Natural Language Supervision (CLIP, 2021): §2.3 (the training objective and its pseudocode), §3.1 (zero-shot transfer and prompt engineering).
- He et al., Masked Autoencoders Are Scalable Vision Learners (2022): §3 (method), §4.1 (mask ratio, decoder design, reconstruction target), §4.3 (partial fine-tuning vs linear probing).
- Grill et al., Bootstrap your own latent (BYOL) (2020) and Chen and He, Exploring Simple Siamese Representation Learning (SimSiam, 2021): the stop-gradient experiments.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.