// part 5 of 8
Part 5
Our rule
Parts 3 and 4 built DINO and SelfPatch. This part is about the change this thesis makes to them: a new way to choose, for every patch, which other patches it should agree with and which it should disagree with, and a contrastive loss that acts on those choices. You will see the rule exactly as the code computes it, run it on real tokens, walk its loss and its gradient number by number, follow the three runs as they trained, and read what the frozen decoder and the linear probe measured afterwards.
5.1 The question, and the picture behind it
The question, in the protocol's words: does a patch objective whose positives are the most similar patches anywhere in the crop, and whose negatives are the crop's least similar fifth, change the label-free mask quality, against the released start and the campaign's SelfPatch runs from the same start? Fact
Picture a photograph of a dog and a cat by a door. Cut into a grid of patches, the dog covers many patches, the cat a few others, and the door and the floor the rest. If the model's tokens worked as we hope, every patch of the dog would carry a token close to every other patch of the dog and far from the patches of the cat and the floor. The tokens would form islands of agreement, one island per object, and a decoder could read an object as an island. Toy
The image comes from GLOM, a paper that says it describes no working system: it proposes to represent the parts of an image by islands of identical vectors. This course uses GLOM as a picture, never as a method. Fact
SelfPatch, in Part 4, pulls each patch towards some of its 8 neighbours in its 3 × 3 window, and towards nothing else. Two things are missing for islands. A patch of the dog's ear can only agree with patches right next to it, so agreement creeps across an object one window at a time. And nothing in SelfPatch's loss ever pushes two patches apart: between patches it has attraction only. Fact
On 8 October 2026 the supervisor proposed, instead of SelfPatch's 3 × 3 window, to rank every patch against all other patches of the crop, take the top k as positives and the bottom k as negatives, do the same with a shared threshold for the image level, and change the loss accordingly. Fact
The owner then fixed the run in the chat of the same day: one run, with the row level and the image level combined, positives from the top k of all the patches, negatives from the lowest K per cent, and k fixed for the first run. For the loss the owner asked whether to keep SelfPatch's or to bring in a contrastive loss beside DINO's global loss; the lead recommended a contrastive loss on the tokens in place of SelfPatch's patch term, with DINO's global loss unchanged, and the owner proceeded. Fact
5.2 The rule, exactly as built
The rule runs on every crop of every image at every optimiser step. An image gives ten crops: two global crops of 224 pixels, each a grid of 14 × 14 = 196 patches, and eight local crops of 96 pixels, each a grid of 6 × 6 = 36 patches. Every patch of a crop is in turn the anchor, and the rule gives it two sets: its positives and its negatives. Fact
- Similarity. Take the teacher's final-block tokens of the crop, scale each to length 1, and compute the cosine of every pair: a table of N × N numbers, the diagonal (a patch with itself) set to minus infinity so that it never counts. No gradient flows through this table. Fact
- Two thresholds. Over the crop's N(N − 1) off-diagonal cosines, τhi is the quantile at 1 − k/(N − 1) and τlo the quantile at 0.20: one high and one low cut for the whole crop. Fact
- Positives. The anchor's k most similar candidates (k = 8 on a 224-pixel crop, 4 on a 96-pixel crop), united with every candidate at or above τhi; above 24, the 24 most similar are kept. Fact
- Negatives. The candidates at or below τlo that are not positives; above 48, the 48 least similar are kept. Fact
- The term. For each positive, an InfoNCE term at temperature τ = 0.2 compares the student's token of the anchor with the teacher's tokens of the positive and of all the negatives. Fact
- The objective. L = Lglobal + λ Lcon with λ = 1.0; SelfPatch's patch term is not in it. Fact
Each step is one function of cluster/contrastive.py, and the trainer composes them crop by crop. Fact
| Step | Function | Where |
|---|---|---|
| the crop's k (8 or 4) | k_for | cluster/contrastive.py:110 |
| the cosine table | all_pairs_similarity | cluster/contrastive.py:124 |
| τhi and τlo | thresholds | cluster/contrastive.py:131 |
| the positives and the cap | positive_mask | cluster/contrastive.py:139 |
| the negatives and the cap | negative_mask | cluster/contrastive.py:161 |
| the InfoNCE term of one view | contrastive_loss | cluster/contrastive.py:177 |
| the ten views, divided by ten | con_terms | cluster/train.py:652 |
| Lglobal + λ Lcon | ContrastiveGlobalLoss.combine | cluster/selection.py:675 |
The cosine table and the two quantiles
- ti
- the teacher's final-block token of patch i: 384 numbers, scaled to length 1
- sij
- one cosine, a number between −1 and 1; all of them form an N by N table
- N
- the patches of the crop: 196 at 224 pixels, 36 at 96 pixels
- k
- the crop's k: 8 at 224 pixels, 4 at 96 pixels
- the quantile at level q with linear interpolation, over the N(N − 1) off-diagonal cosines
- τhi, τlo
- two scalars per crop: the high cut and the low cut
A toy crop of 4 × 4 = 16 patches (a cat, a ball and grass; the lab below draws it) has 16 × 15 = 240 ordered pairs. Sort their cosines from smallest to largest and number them 0 to 239. Toy
With k = 4 the high level is 1 − 4/15 = 0.7333. Its position is 0.7333 × 239 = 175.2667: between the sorted values number 175 and 176, which are 0.5271 and 0.5332, at 0.2667 of the way. So τhi = 0.5271 + 0.2667 × (0.5332 − 0.5271) = 0.5288 (its last digit comes from the unrounded values). On average each anchor has k = 4 partners at or above it. Toy
The low level 0.2 sits at 0.2 × 239 = 47.8: between number 47 and 48, which are −0.0168 and −0.0077, at 0.8 of the way. So τlo = −0.0168 + 0.8 × (−0.0077 + 0.0168) = −0.0096 (the four-decimal values round its last digit). Toy
On the real followed photograph, under run 2's teacher at its end, the 224-pixel crop has 38,220 such cosines; τhi sits at the level 1 − 8/195 = 0.959 and equals 0.8685, and τlo equals −0.3202. Real
None. The table, the thresholds and the sets are computed from the teacher's tokens without gradient: within a step they are fixed numbers that the loss uses, and nothing in the loss can move them. Fact
The thresholds move between steps, because the teacher moves. In run 1 the crops' mean τhi rose from 0.63 to 0.73 and the mean τlo fell from 0.11 to −0.06: the most similar pairs grew more similar and the least similar pairs less similar, as the token space spread. Lab 5E draws both curves. Reading
The positives and the negatives, with their caps
- topk(i)
- the anchor's k most similar candidates, the row part: a floor, so every anchor has at least k positives
- { sij ≥ τhi }
- the image part: every candidate above the crop-wide cut, however many
- cap24
- keeps the 24 most similar positives; cap48 keeps the 48 least similar negatives
- P(i), N(i)
- two lists of patch indices per anchor; their sizes vary from anchor to anchor
Anchor 5 of the toy crop (a cat patch) ranks its 15 candidates: 10, 6, 9 and 15 come first, with cosines 0.8122, 0.6783, 0.6281 and 0.5362, then 12 at 0.2974. The row part at k = 4 is {10, 6, 9, 15}. The image part keeps what is at or above τhi = 0.5288: the same four, because 0.5362 is above and 0.2974 below. The union has 4 members, far under the cap of 24. Toy
The negatives are the candidates at or below τlo = −0.0096: patch 8 at −0.0789, 3 at −0.1171, 0 at −0.1213 and 2 at −0.1807, four grass and ball patches, far under the cap of 48. Over the whole toy crop the anchors keep 4 to 7 positives, 4.4375 on average, and 2 to 5 negatives, 3 on average. Toy
On the real crop the followed anchor, patch 34 on the bulldog's nose, keeps 8 positives, all from its top k, because its most similar candidate has cosine 0.8137, below τhi. It has 79 candidates at or below τlo, and the cap keeps the 48 least similar. Real
Across that crop the anchors keep 11.8112 positives and 31.6429 negatives on average; the cap on positives cuts 7 anchors, the cap on negatives 36, 6 anchors have no negative at all, and 747 positive pairs come from the threshold, beyond their anchor's top k. Real
None through the sets themselves: they are chosen without gradient. They decide which terms the loss holds, so they decide where the gradient of 5.4 points. Fact
In run 1 the anchors kept between 8.6 and 8.7 positives and between 20.5 and 21.1 negatives on average from the first step to the last; these means include the eight 96-pixel crops, where k = 4 and an anchor has only 35 candidates. Reading
The lab below is the first explainer's Lab N, unchanged in what it computes. At load it shows the worked example above: anchor 5 of the 4 × 4 toy crop under the combined rule at k = 4, the bottom 20 per cent and τ = 0.2. Click any patch to make it the anchor, switch to the 6 × 6 crop, or train the toy and watch the islands form. Toy
Positives anywhere in the crop
What does the combined rule pick on a toy crop, and what does its loss do over a few toy steps?
ToyWhat you are looking at: a toy crop of patches with 8 numbers each (a cat with a detached tail, a ball, grass, and on the 6 × 6 crop a fence). The grid paints each patch by its role for the anchor; the bars rank the anchor's cosines with the two thresholds drawn across them; the heat map holds every pair of the crop; the chart on the right shows who holds the denominator of one positive's term. The rule switch also offers SelfPatch's window and the two parts of the combined rule alone, and the objective switch offers SelfPatch's pull and the two pushes that were dropped.
Real model versus this toy: a real token has 384 numbers and a real crop 196 or 36 patches; the toy's tokens are drawn from seeded random numbers around three object directions. A toy step moves the tokens themselves, while a real step moves the network's weights through AdamW. The toy teacher keeps 0.9 of itself at each toy step, while the real teacher keeps 0.9995 of itself at the first step, rising to 1 by the last, so the toy teacher follows its student far faster.
5.3 Real sets on a real photograph
The lab runs the rule in your browser on the real tokens of the course's photographs: the 196 final-block tokens of each photograph's 224-pixel view, under five models (the converted DINO start, the released SelfPatch model, and the teachers of runs 1, 2 and 3 at their last epoch). Real
Start on the bulldog's nose (patch 34) under run 2. Its eight positives are its eight most similar patches, all within two patches of it, and all its negatives lie at least four rows below it. Then press "An anchor the threshold adds to": the lab jumps to the anchor that gets the most extra positives from the crop-wide threshold (the first, when several tie), and draws those extra positives hatched. Slide k, the negatives' per cent and the caps, and watch the histogram's two lines and the counts move. Real
Real positives and negatives
Which patches does our rule pick for one anchor on a real photograph, and how many does it pick across the crop?
Real ToyWhat you are looking at: the photograph's 224-pixel view cut into its 14 × 14 patches, each painted by its role for the anchor: solid orange for a positive from the anchor's top k, hatched orange for a positive that the crop-wide threshold adds, purple for a negative. On the right, every one of the crop's cosines between two different patches as a histogram, with τhi and τlo, and under it the anchor's own row as ticks. The sets are computed here by the same rule as the trainer's (Core.rule.sets), from the bundle's tokens.
Real model versus this toy: the global crop's tokens are real. On the followed photograph under run 2 the lab reads the bundle's 32-bit teacher tokens, so its thresholds and sets are the bundle's own; for the other photographs and models it reads tokens stored to 8 bits per number, whose cosines move by at most 0.00621: enough to carry a pair that sits at a threshold or a cap across it, so some anchors' sets there differ from what 32-bit tokens would give. The 6 × 6 local crop is a toy: it reuses 36 tokens of the global view, while a real 96-pixel crop is a new, smaller picture with tokens of its own. A real crop also comes from random augmentations; this view is the plain centre square.
5.4 The InfoNCE term, walked
For an anchor i and one of its positives p, the term asks the student's token of i to be closer to the teacher's token of p than to the teacher's tokens of all of i's negatives at once: it is near zero when the positive wins by a wide margin and grows when any negative comes close. Fact
The InfoNCE term and its gradient
- zsi
- the student's final-block token of the anchor: 384 numbers; the gradient flows into it
- ztj
- the teacher's token of patch j of the same crop: 384 numbers
- sg( )
- stop-gradient: the teacher's tokens are constants for the loss
- sip, sin
- two cosines: student anchor against the teacher's positive, and against one teacher negative
- τ
- the temperature, 0.2: dividing by it stretches the cosines before the exponentials
- wp, wn
- the shares of the denominator: wp = e−ℓip for the positive, and the negatives' shares add up to 1 − wp
- ℓip, Li
- one scalar per (anchor, positive), and its mean over the anchor's positives
At the start of the toy, the student's tokens equal the teacher's, so the cosines are those of 5.2. Anchor 5 has four negatives. Their es/0.2: patch 2, e−0.1807/0.2 = 0.4052; patch 0, 0.5453; patch 3, 0.5568; patch 8, 0.674. Their sum is 2.1814, the same for every positive of the anchor. Toy
Positive 10: e0.8122/0.2 = 58.0453, the denominator 58.0453 + 2.1814 = 60.2267, its share w = 58.0453 / 60.2267 = 0.9638, and ℓ = −log 0.9638 = 0.0369. Positive 6: 29.7134 / 31.8947 = 0.9316, so ℓ = 0.0708. Positive 9: 23.1153 / 25.2967 = 0.9138, so ℓ = 0.0902. The tail, positive 15: 14.5968 / 16.7782 = 0.87, so ℓ = 0.1393. Toy
L5 = (0.0369 + 0.0708 + 0.0902 + 0.1393) / 4 = 0.0843. At τ = 0.1 it would be 0.0024 and at τ = 0.3 it would be 0.265: a lower temperature makes the negatives' exponentials tiny next to the positive's, so the term shrinks. Toy
A note for checking by hand: the numbers above come from the toy's unrounded cosines, as Lab N computes them, and are rounded only at the end. Redone from the four-decimal cosines printed here, the exponentials and their sums can move in their second to fourth decimal, while every share and the three values of L5 come out the same, and each term the same or one apart in its last digit. Toy
The real followed anchor under run 2 at its end has L = 0.0483 at τ = 0.2; its positives hold 0.9529 of their denominators on average and its negatives 0.0471. At τ = 0.1 its term is 0.0000605 and at τ = 0.3 it is 0.392. Real
The gradient on the student's token is d ℓip / d zsi = (1/τ) [ −(1 − wp) gip + Σn wn gin ], where gij is the gradient of the cosine sij. A step against it pulls the token towards the positive with the weight (1/τ)(1 − wp) and pushes it away from each negative with the weight (1/τ) wn: the pull's weight is the pushes' total. Fact
For the toy tail, the negatives hold 1 − 0.87 = 0.13 of the denominator, split 0.0242, 0.0325, 0.0332 and 0.0402 between patches 2, 0, 3 and 8. The pull towards the tail has the weight 5 × 0.13 = 0.65, and each negative pushes with five times its share, the most alike negative hardest. Toy
The real followed anchor's gradient, computed by PyTorch through the token's normalisation, has length 0.1582: its pull part 0.0987 and its push part 0.1234. Real
In run 2 the contrastive term was 0.7336 at step 1, 0.0372 at step 4,620 and 0.0269 at step 9,240, and the negatives' share of the denominators fell from 0.4976 to 0.0462 and then 0.0326. As the negatives drift away their shares shrink, and so does every pull and push: the term works hardest at the start. Real
In the lab below, the followed anchor's term is rebuilt from the real student and teacher tokens of run 2, step by step for one positive, and checked against the value that PyTorch computed for the bundle. Slide τ and watch the shares and the term; move the positive's cosine with the toy slider; click another anchor of the crop. Real
The InfoNCE term, walked
How is one anchor's loss built from its shares, and how does the temperature change it?
Real ToyWhat you are looking at: run 2's crop of the followed photograph at the end of training, the anchor outlined, its positives orange and its negatives purple. Beside it, the term of the followed positive in eight steps, the shares of its denominator as bars (the positive first, then its negatives, largest first), every positive's term and their mean Li, and Li against the temperature on a log scale with the bundle's three values as dots. The sets are the bundle's, chosen on run 2's teacher tokens.
Real model versus this toy: the tokens, the sets and the dots are real. The toy slider changes one cosine by hand, which no training step does, to show how the term reacts; with it at 0 every number is the real one.
The gradient of the term is a sum of pulls and pushes on the student's token. The lab below draws them on a flat map of the crop's tokens and lets you take toy steps against the gradient. Toy
Pull and push
In which direction does the loss move one student token, and how much does each partner contribute?
Toy RealWhat you are looking at: the 196 teacher tokens of run 2's crop of the followed photograph, each scaled to length 1, projected onto their two main directions (a fixed projection that the page computes). The green dot is the student's token of the anchor; the orange arrows are its pulls towards its positives, the purple arrows its pushes away from its negatives, each scaled by its share, and the thick green arrow is their sum, the step against the gradient. The gradient itself is the real one: for the followed anchor it matches the bundle's, which PyTorch computed.
Real model versus this toy: the map is a projection from 384 numbers to 2, so an arrow can point away from the dot it belongs to; the readout gives the true lengths. A toy step moves the token itself and keeps the teacher still, while a real step moves every weight of the backbone with AdamW, so the tokens of the whole crop move together and the teacher follows by its moving average.
5.5 Why these choices
Most of the evidence below comes from the two premise tests: label-free measurements on existing weights, run on a CPU before the run, never a training run. They read the released model on the first 200 images of the image-only COCO v4 manifest. Fact
Several premise numbers use the frozen decoder's regions as a stand-in for objects: a region is a label-free guess, and a positive that shares its anchor's region probably lies on the same object. Fact
Before the run the second premise test also measured the combined rule at k = 8 on the released model: on the 224-pixel views 11.1 positives per anchor (median 8.0), 28.2 % of them from the threshold, the cap at 24 cutting 7.2 % of the anchors; on one draw of the trainer's crops 10.6 positives per anchor, 24.3 % from the threshold. Its verdict set τ = 0.2 and left k to the lead, who decided it before the protocol was committed. Fact
5.6 The projection head of run 3
Run 3 starts where run 1 started and changes one knob: the space of the contrastive term, which moves into a projection head's outputs. Fact
The head is a Linear layer from 384 to 1,024 values with a bias, the exact GELU, and a Linear layer from 1,024 to 256 with a bias, applied to each token alone with no normalisation layer; its outputs are scaled to length 1 before the cosine. Fact
The positives, the negatives, both thresholds, k and the caps are still chosen from the teacher's raw final-block tokens, so the premise calibration and the rule's telemetry keep their meaning; only the term's similarities move into the head's space. Fact
The head moves the term's similarities into a token-wise MLP's space, as SimCLR applies its loss and DenseCL, Leopart and CrIBo their local terms, so that the push shapes the backbone through the head. Fact
What the head costs: two more modules to train and to carry, which add 10.5 MB to run 3's final envelope, the file in which a run saves its state, and a term whose negatives' share and margin are measured in the head's space, so they are not like for like with run 1's. Reading
The projection head
- z
- one final-block token: 384 numbers
- W1, b1
- a matrix of 1,024 by 384 and a bias of 1,024
- GELU
- the bend x Φ(x), with Φ the normal distribution's cumulative function
- W2, b2
- a matrix of 256 by 1,024 and a bias of 256
- hs, ht
- the student's head, trained, and the teacher's head, its moving average
- sij
- the term's cosine, now between two 256-value outputs
A toy head from 2 numbers to 3 and back to 2. Take z = (1, 2), W1 with rows (1, 0), (0, 1) and (1, −1), no biases: W1 z = (1, 2, −1). Toy
GELU bends each number: GELU(1) = 0.8413, GELU(2) = 1.9545 and GELU(−1) = −0.1587, so large positive numbers pass almost unchanged and negative ones shrink towards 0. With W2 rows (1, 0, 1) and (0, 1, 1): h = (0.8413 − 0.1587, 1.9545 − 0.1587) = (0.6827, 1.7958), of length 1.9212, which scales to (0.3553, 0.9347). Toy
The term's gradient on h travels back through the head before it reaches the token: through W2, then the GELU's slopes, then W1. The slopes at 1, 2 and −1 are 1.0833, 1.0852 and −0.0833. Toy
Push the toy head's first output by 1 and nothing else: W2 sends 1 to the first and the third hidden numbers, the slopes turn them into 1.0833 and −0.0833, and W1 turns those into (1.0833 − 0.0833, 0.0833) = (1, 0.0833) on z. A push on the head's output reaches the token reshaped: the head decides which of the token's numbers move, and by how much. Toy
Run 3's contrastive term, measured in the head's space, was 0.6444 at step 1 and 0.0538 at step 9,240; it is not like for like with run 1's term, which is measured on the raw tokens. Real
The projection head
Why does a loss in the head's space change the gradient that reaches the backbone?
Toy RealWhat you are looking at: run 3's real teacher tokens of the followed photograph at its last epoch, the anchor's sets chosen on those raw tokens with the run's rule, and a head of the real shape. The flow shows the anchor's token at each stage of the head, the bars compare each partner's cosine on the raw tokens and in the head's space, and the readout compares the gradient that reaches the token's 384 numbers on the two paths.
Real model versus this toy: the head is a toy: fresh random weights of the real shape, drawn as a new Linear layer is drawn, because the bundle does not hold run 3's trained head. The student's tokens are taken equal to the teacher's, as at the start of a run. The real run trains its head with the heads' learning rate, and the teacher's head follows by the moving average.
5.7 The three runs, and the training in numbers
Each further run changes one value against run 1, so that a difference has one cause. Fact
| Run | Starts from | Changes | Launched | Completed |
|---|---|---|---|---|
| run 1 | the released DINO+SelfPatch checkpoint | the rule replaces SelfPatch's patch term | 2026-10-09 15:23:36 UTC | 2026-10-10 01:16:28 UTC |
| run 2 | the converted DINO ViT-S/16, fresh SelfPatch heads | the start | 2026-10-10 08:06:49 UTC | 2026-10-10 17:57:55 UTC |
| run 3 | the released checkpoint, as run 1 | the term in a projection head's space | 2026-10-10 17:59:41 UTC | 2026-10-11 04:02:00 UTC |
Each run completed its 9,240 steps with none skipped; run 1 trained for 35,521.3 seconds, run 2 for 35,435 and run 3 for 36,088, on one card. Reading
A run draws everything random from one number, its seed: the order in which the images come in each epoch, the crops of every image, the random numbers of every step and, from the DINO start, the first weights of the fresh heads. Two runs with the same seed see the same images in the same order with the same crops; a run with another seed sees other draws. Fact
Besides the starts themselves, two kinds of comparators already existed on disk. The two LC0 twins, named after LC0, the training recipe that they and all three runs share (its numbers are listed below), trained SelfPatch's own patch term from run 1's start, one with SelfPatch's row rule and one with the pooled image rule, with the same seed, initial state, image order, crops and per-step random seeds as run 1, so the contrasts with them are paired by construction. Fact
The pilot is the comparator of run 2 from the same DINO start: DINO trained with SelfPatch's window term under LC0 for 20 epochs, which had spent 0.56 points of the primary endpoint. Fact
The training, in numbers, for all three runs: Fact
- all 118,287 COCO train2017 images, images only, in batches of 256: 462 optimiser steps per epoch, the last 15 images of each epoch's order dropped;
- 20 epochs, so 9,240 steps; ten crops per image (2 × 224 + 8 × 96), so 174,080 anchors per step;
- the heads' learning rate peaks at 1e-4 and ends at 1e-6, the backbone's peaks at 1e-5 and ends at 1e-7, after a linear warm-up of 10 epochs and then a cosine;
- the backbone is frozen in epoch 0 (steps 1 to 462), so step 463 is the first in which the term can move it; the last layer of each head is held fixed in epoch 0 too;
- weight decay from 0.04 to 0.4 on a cosine; teacher momentum from 0.9995 to 1; the global term's teacher temperature 0.04 and student temperature 0.1; centre momentum 0.9; each gradient tensor clipped to 3.0; bf16 mixed precision, in which the backbones and the global heads compute with 16-bit numbers while the rule and the term are computed with 32-bit ones;
- pair 1 of the campaign's paired initial states, seed 906; an envelope every 5 epochs, and the final one,
ckpt_epoch020.pt, is the object of the run: no checkpoint is chosen by any score.
The protocol laid the batch out as two cards with four micro-batches of 32 images each; the runs were executed on one card, card 6, with eight micro-batches of 32 images per step, a declared deviation that keeps the global batch at 256. Fact
The total loss with λ
- Lglobal
- DINO's global term: a scalar, the cross-entropy between the teacher's and the student's class outputs over 18 crop pairs
- Li
- one anchor's term from 5.4, a scalar
- v
- one of the image's ten views: 196 anchors in a global view, 36 in a local view
- λ
- the weight of the contrastive term, 1
Toy: if the two global views had terms 0.5 and 0.3 and each of the eight local views 0.4, then Lcon = (0.5 + 0.3 + 8 × 0.4) / 10 = (0.8 + 3.2) / 10 = 0.4, and with a global term of 3.9 the total is 3.9 + 1 × 0.4 = 4.3. With λ = 0.5 it would be 3.9 + 0.2 = 4.1. Toy
At step 1 of run 1 the progress line held a global term of 4.2292 and a contrastive term of 0.4685, so a total of 4.2292 + 0.4685 = 4.6977. Real
The gradient of the total is the gradient of the global term plus λ times the gradient of the contrastive term: both flow into the same backbone, and λ sets their exchange rate. Dividing by the ten views keeps the term's size independent of how many crops an image has, as SelfPatch's patch term divides by the number of views. Fact
In run 1 the contrastive term fell from 0.47 to 0.11 and the negatives' share from 0.41 to 0.11 while the global term kept falling, so the push acted on the token space without fighting DINO's term. Reading
One AdamW step
- θ
- one weight of the network (each weight has its own m and v)
- g
- the weight's gradient at this step, after clipping
- η
- the learning rate of the step: the backbone's or the heads' schedule
- λwd
- the weight decay of the step, from 0.04 to 0.4
- m, v
- running averages of the gradient and of its square; β1 = 0.9 and β2 = 0.999 keep that much of the old value
- ε
- 1e-8, added so that the division never blows up
- t
- the step number, which corrects m and v for their start at zero
Toy: a weight θ = 0.5 at step 1, gradient g = 0.2, learning rate 0.01, decay 0.04. The decay first takes 0.01 × 0.04 × 0.5 = 0.0002, so θ = 0.4998. Then m = 0.1 × 0.2 = 0.02 and v = 0.001 × 0.04 = 0.00004; corrected, m̂ = 0.02 / 0.1 = 0.2 and v̂ = 0.00004 / 0.001 = 0.04, whose square root is 0.2. The step is 0.01 × 0.2 / 0.2 = 0.01, so θ = 0.4898. Toy
The first step moves the weight by the learning rate, whatever the gradient's size: a gradient a hundred times smaller gives the same 0.01. AdamW reads a gradient's direction and its consistency over steps more than its size. Toy
This is the step itself: it turns the gradients of the loss into a change of every weight. At each step AdamW first shrinks a decayed weight by the learning rate times the decay rate times the weight, then updates m and v, scales both up to make up for their start at zero, which gives m̂ and v̂, and subtracts the learning rate times m̂ / (√v̂ + ε) from the weight. Fact
The schedules of run 1: the backbone's learning rate was 0 at step 1, where its warm-up starts, 1e-06 at step 463, 1e-05 at step 4,620, the warm-up's peak, and 1e-07 at step 9,240; the weight decay was 0.04, 0.0422, 0.2199 and 0.4 at the same steps. Lab 5E draws them. Real
5.8 How the model trains itself: the real telemetry
The trainer writes one progress line per optimiser step with the step, the epoch, the losses, the learning rates, the weight decay, the teacher momentum and diagnostics; the contrastive path adds 14 fields, the term and 13 statistics of the rule. Fact
Read the curves of run 2 from left to right. At step 1 the total loss was 11.2743, the global term 10.5406 and the contrastive term 0.7336, and the negatives held 0.4976 of the denominators. By step 4,620 the term was 0.0372 and the share 0.0462; at step 9,240 the term was 0.0269, the share 0.0326 and the margin between a positive and the closest negative 1.2792. Real
Run 2's negatives' share fell fast at first, each epoch keeping about 75 % of the last, then about 87 %, and it sat near 0.03 for the last five epochs, above the stop line of 0.02. Reading
What the shapes mean. The term and the share fall together, because once the negatives are far their exponentials are tiny and the pulls and pushes weaken. The margin rises as positives and negatives move apart. τlo falls as the least similar pairs grow less similar and τhi rises as the most similar pairs grow more similar: the crop's thresholds move as the token space spreads. In run 1, τhi went from 0.63 to 0.73 and τlo from 0.11 to −0.06. Reading
How the model trains itself
What do the real training curves of the three runs show, step by step?
RealWhat you are looking at: the progress lines of runs 1, 2 and 3, sampled at the first step, every tenth step and the first step of every epoch, for the field you choose. The shaded band is epoch 0, when the backbone is frozen; dashed lines mark a stop rule where the field has one. The scrubber reads every chosen run at one step, and the list under the chart says what each field measures. Run 3's term, share and margin are measured in its head's space.
5.9 What the readings showed
Each run's final envelope was read in one evaluation beside its comparators, by the frozen decoder on the COCO v4 validation panel: 1,000 images, 988 of them defined because 12 hold no retained truth object. A reading is a checkpoint's score on the panel, for most endpoints its mean over the defined images. A paired contrast is the mean, over the same images, of one checkpoint's value minus another's, written as that difference with its 95 % image-bootstrap interval in brackets. Fact
The interval asks how much the contrast could change if the panel had held other images of the same kind. The evaluator draws the panel's 1,000 images again at random with replacement, so that some come twice and some not at all, recomputes the contrast over the defined images drawn, and repeats this 2,000 times (500 times for AP100, the decoder's average precision); the 2.5 and 97.5 percentiles of the results, which hold the middle 95 per cent between them, are the interval's ends. Fact
A toy panel of four images, on which checkpoint b scores 1, −1, 3 and 1 points above checkpoint a, has the contrast (1 − 1 + 3 + 1) / 4 = 1 point. A resample that draws images 1, 1, 3 and 4 gives (1 + 1 + 3 + 1) / 4 = 1.5; one that draws 2, 2, 4 and 4 gives (−1 − 1 + 1 + 1) / 4 = 0; one that draws 3, 3, 3 and 1 gives (3 + 3 + 3 + 1) / 4 = 2.5. Over many resamples the results spread around 1, and their middle 95 per cent is the interval. An interval that leaves out 0 says that other images of the same kind would rarely turn the difference round; one that contains 0 says that they could. Toy
The interval holds one source of chance only, the images. A second source is the seed of 5.7: two runs that differ only in their seed end with different weights, and that seed spread is not in the interval of a run trained once. A verdict needs it: in the thesis's pre-registered selector study of 5.10, a contrast was declared different when the 95 % interval over the seeds left out zero and the mean difference exceeded a margin fixed in advance, equivalent when the 90 % interval over the seeds lay inside that margin, and inconclusive otherwise. Each contrast of a run here is a single-seed observation, so no verdict of different or equivalent is declared and nothing is adopted. Fact
| Checkpoint | Hungarian IoU | union IoU | fg ARI | bg false positives | regions | probe mIoU |
|---|---|---|---|---|---|---|
| released SelfPatch (start of runs 1 and 3) | 15.58 | 30.66 | 22.98 | 60.37 | 2.11 | 23.8 |
| row twin | 15.71 | 30.94 | 23.18 | 60.26 | 2.09 | 24.68 |
| image twin | 15.68 | 30.85 | 22.77 | 60.19 | 2.09 | 24.59 |
| run 1 | 15.62 | 31.47 | 21.24 | 56.02 | 1.91 | 25.15 |
| run 3 | 15.95 | 30.73 | 22.81 | 60.29 | 2.13 | 25.31 |
| converted DINO (start of run 2) | 17.23 | 32.68 | 22.62 | 56.59 | 2.38 | 14.41 |
| pilot | 16.67 | 32.63 | 22.22 | 54.52 | 2.22 | 20.88 |
| run 2 | 17.41 | 36.47 | 24.56 | 41.2 | 1.77 | 21.11 |
Run 1, from the released start: on the primary endpoint it is indistinguishable from its comparators, +0.04 [−0.58, +0.63] points against the start, every interval about plus or minus 0.6 points around zero. Its term changed the decoder's output in one direction at every look: fewer background pixels claimed, a higher foreground union IoU, fewer regions, a lower foreground ARI and slightly lower recall. Reading
Run 2, from the DINO start, keeps the start's geometry: +0.18 [−0.59, +0.92] against the converted DINO, while the window-term pilot from the same start had spent 0.56 points. Against every comparator it claims much less background (13 to 15 points), raises the foreground union IoU by 4 to 5 points and the foreground ARI by 2 to 3, doubles AP100 and returns fewer regions, at the price of a little recall against its start. Under the rule the DINO start ends above the released start by +1.80 [+1.02, +2.61] points of Hungarian IoU. Reading
Run 3, through the head: +0.34 [−0.23, +0.93] against run 1 on the primary endpoint, and run 1's secondary signature is gone. Across the three runs, the rule on the raw tokens changes what the decoder groups, most from the DINO start, while the head version leaves the decoder where its start was. Reading
The linear probe tells another story. Run 1's tokens are more linearly separable than its start's by +1.35 mIoU [0.87, 1.79] while the decoder did not move; run 3 keeps that gain, 1.51 above its start; run 2 reads 4.0 mIoU below run 1 while the decoder ranks the two the other way round. The probe and the decoder reward different properties of the same tokens. Reading
What the readings showed
How do the eight checkpoints compare on each endpoint, and which contrasts leave zero out of their interval?
ReadingWhat you are looking at: every decoder and probe reading of the eight checkpoints, copied from the course's fact sheet. Choose an endpoint and the checkpoints to show; switch to the contrasts to see each paired difference with its 95 % image-bootstrap interval, drawn in ink when the interval leaves out zero and in grey when it contains zero. Under the chart, one line says what the chosen endpoint measures.
The second seed pair has four runs from pair 2's initial states, seed 907: A repeats run 2 and B the window-term pilot from the DINO start; C repeats run 3 and D run 1 from the released start, all with the run-1 recipe and the rule's values. The amendment plans two evaluations after them, one for the DINO side and one for the SelfPatch side, with decision none, and the probes 9 to 12. With two seeds the thesis can say that a reading repeats in both seeds or in one of two, and no more than that. Fact
Runs A and C were launched on 12 October 2026 and completed their 9,240 steps on 13 October with none skipped; runs B and D then started on the same two cards. Reading
5.10 Before the rule: the selector study
The first question kept SelfPatch's loss and changed only how a patch picks its positives: one shared threshold instead of each patch's own top 4. SelfPatch trains each patch to agree with its 4 most similar neighbours; the thesis replaced that fixed 4 with one similarity threshold shared by a whole crop or a whole training step, hoping that the patches of one object would form islands. Fact
Three rules shared one form, the window neighbours above a threshold: the row rule (SelfPatch's own, the 4th largest of the anchor's 8 similarities), the image rule (one threshold per crop, the median of its similarities) and the batch rule (one threshold per optimiser step). Because they cut the same ranking, the only information a pooled rule adds is a comparison across anchors. Fact
The released-start campaign ran three pairs of row and image runs, seeds 906, 907 and 908. All four pre-registered verdicts of the sealed test reading on image minus row were "equivalent", the 90 % seed-level interval inside a margin of 1 point either side of zero, and the image arm met none of the quality bars. Fact
So far pooling has measured as weaker smoothing: the pooled arms sit where a row rule with k between 2 and 4 would sit, and no term of the loss lowers the agreement of any pair of patches. The report's analyses agreed that a separating term is needed for islands, though it is not enough on its own; this part adds one, a push, beside positives from the whole crop. Fact
5.11 Related ideas
GLOM proposes islands of identical vectors as the parts of an image, and says that once two representations are sufficiently different there is no further pressure to push them even further apart; the course borrows the picture of islands, never a method. Fact
Run 3's projection head follows the way SimCLR applies its loss and the way DenseCL, Leopart and CrIBo apply their local terms, through a token-wise MLP. Fact
Our rule can be read as a loss that encourages islands of agreeing patch tokens inside one crop and pushes apart the tokens that disagree most. The link to GLOM is that picture and nothing more: the rule has no columns of vectors, no levels and none of GLOM's iterative settling. Reading
Two papers read on 12 October 2026
Two papers were read on 12 October 2026. What their readers found follows, as the lead's summary of their reports gives it. Reading
The Composer (ICLR 2024 submission 297, withdrawn; OpenReview JAfGlmRBTU) is a spiking network of two levels whose neurons synchronise in time: parts and wholes are read out as groups of neurons that fire together. It is trained with a denoising autoencoder for each level, on isolated single parts and wholes, with sixteen hand-set time constants, on four binary synthetic datasets (Ts, Squares, SHOPs and Double MNIST). Its coordination metrics need the true labels of the parts and the wholes, and its binary input gates every firing rate, so figure and ground never have to be separated. Reading
The readers' verdict: the Composer does not solve label-free grouping of photographs, and nothing in it carries over to our trainer. One idea survived, for evaluation only: a silhouette diagnostic of the instances in the frozen decoder's keys, pre-registered and used only to explain, which the owner has not taken up. Reading
Zeng, Song, Zhang, Hu and Yu, Agreement aware and dissimilarity oriented GLOM (ICCV 2025, pages 24351 to 24359) is a column network in GLOM's style that classifies images: SmallNORB, MNIST, Fashion-MNIST, CIFAR-10 and CIFAR-100. Its contrastive-attention operator is a step of the forward pass and no loss. In every update it splits all the pairs of columns at a level into an attract set and a repel set by a fixed cosine threshold, 0 at the bottom level and −0.2 at the top, and it moves each column toward the softmax-weighted mean of the columns that attract it and away from the columns that repel it. A pooling weighted by dissimilarity cuts its parameters from 72 M to 2 M. Its training is supervised, a supervised contrastive stage and then cross-entropy, and with those labels the paper reports a CIFAR-10 error of 10.90 against Agglomerator's 11.15. Reading
The readers found two defects in the paper's printed mathematics. Its dissimilarity metric reduces to at most 1/d for unit vectors of d numbers, so it cannot reach the published values of 0.37 to 0.54; and its negative term, which uses raw cosines as weights, moves the embeddings toward the negatives. Reading
What this network shares with our rule is the split, gated by a threshold, of all the pairs inside one image into pairs that attract and pairs that repel. Everything else differs: its operator sits inside the forward pass, it trains with labels, it works at the scale of CIFAR and it segments nothing. The readers kept three ideas for later: positives gated by a threshold, which our rule already has through τhi; loosening the positives as training goes on, judged risky; and one step of smoothing the agreement before the decoder, at low priority. Reading
What the literature sweep of 12 October 2026 found
The sweep looked for work after SelfPatch that resembles the rule. It read the citation lists of SelfPatch in Semantic Scholar, OpenAlex and OpenCitations, queried the arXiv API, searched OpenReview and read the title listings of CVF, ECCV, NeurIPS, ICLR, PMLR and TMLR, in English only and without Google Scholar. Reading
Within those sources it found no earlier work that trains a ViT backbone with a patch-level InfoNCE whose positives are the anchor's most similar tokens anywhere in the crop, a rank floor plus a crop-wide quantile threshold, and whose negatives are the least similar fifth of the crop, next to DINO's global term, and that reads the result with a frozen spectral decoder on class-agnostic COCO instance masks. Each piece exists somewhere; the combination was not found. This is a statement about the sources searched, and it does not prove that no such work exists. Reading
| Work | Shares with our rule | Differs |
|---|---|---|
CoViT (arXiv 2609.01787, September 2026) | fine-tunes released DINO ViTs on COCO with a patch InfoNCE inside each image | its positives come from attention masks; its negative is the single most similar patch of another instance, the opposite polarity to our bottom fifth; it drops the global term; it is read by supervised detection |
| Hidden Positives (CVPR 2023), SmooSeg (NeurIPS 2023) and CAUSE | thresholds that attract and repel inside the image | they train a head on frozen DINO and never the backbone |
| FLSL (NeurIPS 2023) and CoTAP (TPAMI 2025) | positives chosen by similarity beyond a window, with the global term kept | soft weighting or a ranking loss, and no negatives from the crop |
| CtCAE (NeurIPS 2023) | the top k most similar positions as positives and the bottom m least similar as negatives, in an InfoNCE | a complex-valued autoencoder on synthetic scenes |
Two more works are the precedents for the way we evaluate: DiffNCuts (ECCV 2024) and SimDINO (ICML 2025) each read a short label-free fine-tune, or a changed self-distillation rule, with a frozen spectral decoder on COCO. Reading
The sweep also found evidence against parts of the design, which the thesis should report. Global-Local Self-Distillation (WACV 2023) found local positives mined by similarity harmful when the data are few. ASL (CVPR 2024) argues that a global contrastive term conflicts with patch contrast. VICRegL found a count of positives set by a threshold no better than a fixed count. AdaSim shows that nearest-neighbour positives without negatives can collapse, which is the argument for keeping negatives. Reading
LiFT (ECCV 2024) measured released SelfPatch below DINO on label-free TokenCut, with a COCO20K CorLoc of 52.18 against 53.98. That is the same direction as our decoder's Hungarian matched IoU on the validation panel in 5.9, 15.58 for released SelfPatch against 17.23 for the converted DINO. Reading
No published number is on our scale. The nearest are the Hungarian mIoU of the slot-attention line (7 slots, 256 px), mBO, FG-ARI, class-agnostic AP (bounded by recall for a decoder that returns few regions), CorLoc and semantic mIoU; our background false-positive rate has no published counterpart. Reading
This section quotes the lead's summary .superpowers/sdd/explainer_v2/related_work_summary.md, written on 13 October 2026 from the two paper reports and the consolidated sweep report of the day before; those three reports sit in the lead's working folder, outside the repository. Part 8 lists the summary with the course's other sources, in section 8.3. Fact
Glossary of this page
- Anchor
- The patch whose partners a rule is choosing. Every patch of a crop is in turn the anchor, and each gets its own positives and negatives.
- AP100
- The mask average precision of COCO's evaluation with the object categories ignored and up to 100 masks per image. The decoder's masks are ranked by a label-free score; a mask is a hit when its IoU (overlap divided by union) with a true object not yet matched reaches the threshold, and the precision over the levels of recall is averaged over ten thresholds, from an IoU of 50 to 95 per cent.
- Attraction
- A loss term that only pulls tokens together. SelfPatch's patch loss is attraction only: nothing in it lowers the agreement of any pair of patches.
- Bootstrap interval (image-bootstrap interval)
- A range for a number measured on a panel of images. Draw the panel's images again at random with replacement, recompute the number, repeat that many times and keep the middle 95 per cent of the results: the interval shows how much the number could move with other images of the same kind. It holds no seed spread.
- Contrastive loss
- A loss that pulls an anchor towards its positives and pushes it away from its negatives in one formula. For each positive, a softmax over that positive and all the negatives should put most of its weight on the positive; the loss is minus the logarithm of the positive's share. InfoNCE is the contrastive loss of our rule.
- In the contrastive loss, the part of the softmax's denominator that one partner holds: wp for the positive and wn for each negative. The shares add up to 1. The negatives' total, 1 − wp, is the weight of the pull, and each negative's share is how hard it pushes.
- Direct push
- A push considered for the non-local idea and dropped: it adds the overlap of each negative pair itself to the loss, so that every negative pair is pushed apart, however far apart it already is.
- Envelope
- The file in which a run saves its whole state: the student's and the teacher's weights, the loss's centres, the optimiser's state, the step, the seed and the settings, enough to continue the run or to read it. Our runs write one every 5 epochs, and the last, after epoch 20, is the object of a run.
- Epoch
- One pass over the training images. In our runs an epoch is 462 optimiser steps of 256 images each.
- Exponential moving average (EMA)
- A running average that keeps most of its old value at each step and mixes in a little of the new one. DINO's teacher is the exponential moving average of the student's weights.
- Heat map
- A table of numbers drawn as a grid of cells whose shade shows the size of each number. In Lab N the heat map holds the cosine of every pair of the toy crop.
- Hinge
- A loss that is zero until a quantity crosses a margin and grows after it. The bounded hinge of the first non-local design pushed a pair apart only while its overlap stayed above a margin; it was dropped.
- InfoNCE
- The contrastive loss our rule uses. For an anchor and one positive: minus the logarithm of the positive's exponential cosine, over the sum of that and of every negative's exponential cosine, all divided by a temperature first.
- Island of agreement
- A group of patches whose tokens agree with each other and disagree with the patches around them. GLOM pictures the parts of an image as islands of identical vectors; our rule hopes that each object becomes such an island.
- Learning rate
- How far one optimiser step moves the weights. Our runs give the heads a learning rate that peaks at 1e-4 and the backbone one that peaks at 1e-5.
- Negative
- A patch that a rule chooses for an anchor to disagree with. Under our rule: a patch of the same crop at or below the crop's low threshold, never one of the anchor's positives, at most 48 per anchor.
- Optimiser step
- One update of every weight of the network, from the gradients of one batch of images. Our runs take 9,240 of them.
- Overlap
- In the pushes that were considered first, oij: the sum over the prototypes of the student's probability for anchor i times the teacher's target probability for patch j. It is 0 when the two share no prototype and 1 only when both put everything on the same one.
- Paired contrast
- The mean, over the same images, of one checkpoint's value minus another's on each image. Each image is compared with itself, so what makes an image easy or hard for both checkpoints cancels in its difference.
- Pilot
- An earlier run of the project: DINO trained with SelfPatch's own window term under recipe LC0 for 20 epochs. It is run 2's comparator from the same DINO start.
- Positive
- A patch that a rule chooses for an anchor to agree with. Under our rule: one of the anchor's k most similar patches, or any patch of the crop at or above the crop's high threshold, at most 24 per anchor.
- Prototype
- One of the learned directions that a projection head compares a token with. DINO's head has 65,536 prototypes and SelfPatch's patch head 4,096; the toy of Lab N has 8.
- Quantile
- The value below which a given share of a sorted list falls. The 0.20 quantile of a crop's cosines has a fifth of them at or below it; between two sorted values, linear interpolation takes the point in between.
- Seed
- The number from which a run draws everything random: in our runs the order of the images in each epoch, the crops of every image, the random numbers of every step and, from the DINO start, the first weights of the fresh heads. Two runs that differ only in their seed differ by chance alone. Our first runs used seed 906; the second seed pair uses 907.
- Stop-gradient
- Treating a quantity as a fixed number when the loss is differentiated, so that no gradient flows into it. The teacher's tokens are behind a stop-gradient; only the student's tokens move by the loss.
- Telemetry (progress line)
- The numbers a trainer writes about itself while it runs: one line per optimiser step with the losses, the learning rates and the rule's statistics, read afterwards to see how training went.
- Temperature
- A number that the cosines are divided by before a softmax. A small temperature sharpens the softmax towards its largest entry; our rule's term uses 0.2.
- Toy step
- One training step of a lab's toy. The gradient moves the toy's tokens directly, each is scaled back to length 1, and in Lab N the teacher's tokens move a tenth of the way towards the student's. A real step moves the network's weights instead.
- Twin (LC0 twin)
- One of the campaign's two runs of pair 1 under recipe LC0, trained with SelfPatch's own patch term from run 1's start, with the same seed, images, order and crops as run 1: the row twin with SelfPatch's rule, the image twin with the pooled rule.
- Verdict (different, equivalent)
- The conclusion that a pre-registered rule draws from an interval over several seeds: different when the 95 % interval leaves out zero and the mean difference exceeds a margin fixed in advance, equivalent when the 90 % interval lies inside that margin, and inconclusive otherwise. One seed gives no interval over seeds, so the readings of a single run declare none.
- Warm-up
- The first epochs of training, during which the learning rate rises in a straight line from 0 to its peak, so that the first steps stay small.
- Weight decay
- A small pull of every decayed weight towards 0 at each step, which AdamW applies apart from the gradient. Our runs raise it from 0.04 to 0.4.
- Within-object cosine
- In Lab N, the mean cosine between two patches of the same object: cat with cat, ball with ball, fence with fence. The grass, the background, is counted on its own. When it rises while the cosine between patches of different kinds falls, islands are forming.