Projects / What stop-gradient does in SimSiam
What stop-gradient does in SimSiam
Multimodal Artificial Intelligence, National Taiwan University
Abstract
I re-implement SimSiam [1] on STL-10, pretraining a ResNet-18 on the 100k unlabeled images. A linear probe on the frozen encoder reaches 75.38% test accuracy with only 1,000 labels, against 48.85% for the same network trained from scratch. I reproduce four ablations from the paper and monitor collapse with the output standard deviation and the effective rank of the features, which reveals a transient dimensional collapse during training. Beyond the paper, I ask why stop-gradient prevents collapse: it cannot be relaxed (letting 1% of the gradient through already costs 5 points), but it can be replaced, since variance and covariance penalties on the normalized output match SimSiam without any stop-gradient (75.8% against 75.1%, two seeds).
What I did
Two augmented views of an image pass through the same encoder (ResNet-18 and a projection MLP), giving , and a predictor gives . The loss compares each prediction with the other view’s output, through a stop-gradient :
With no negatives and no momentum encoder, a constant output minimizes this loss (collapse). Besides the loss and a kNN monitor I log two collapse metrics every epoch: the per-channel standard deviation of , which is about when outputs are well spread and 0 under collapse, and the effective rank [3] of the backbone features, which also catches partial (dimensional) collapse. Every run uses the full protocol: 100 epochs of pretraining (about 39 minutes on one RTX 4090), then a linear probe on the 1,000 labeled images.
Results
Pretraining and linear probing
The loss reaches −0.850 and kNN accuracy 71.8%, matching the course’s reference curves, and a second seed gives the same numbers. The effective rank, however, falls from about 340 to about 150 right after warm-up, when the learning rate peaks, and only recovers as the cosine schedule lowers it (Figure 1). SimSiam goes through a phase of partial collapse that the loss curve does not show.

SimSiam pretraining (two seeds): loss, kNN validation accuracy, output std and effective rank of the backbone features. The shaded band is the transient dimensional collapse.
Classification on STL-10 with 1,000 labels (course reference: 47.56% and 75.14%).
| Method | Val acc. (%) | Test acc. (%) |
|---|---|---|
| Supervised from scratch | 47.60 | 48.85 |
| SimSiam + linear probe (seed 0) | 76.20 | 75.38 |
| SimSiam + linear probe (seed 1) | 75.40 | 74.71 |
Ablations from the paper
Ablations from the paper (100-epoch pretraining). std: per-channel std of the normalized output (0.022 when healthy); rank: effective rank of the backbone features; LP: test linear-probe accuracy (%).
| Variant | std | rank | LP | Paper (ImageNet) |
|---|---|---|---|---|
| Baseline | .0220 | 256 | 75.4 | 68.1 |
| Without stop-gradient | .0000 | 8 | 19.1 | 0.1 |
| No predictor | .0000 | 53 | 15.2 | 0.1 |
| Fixed random predictor | .0159 | 6 | 33.7 | 1.5 |
| Cross-entropy similarity | .0180 | 82 | 43.1 | 63.2 |
| Asymmetric loss | .0220 | 234 | 72.1 | 64.8 |
Removing stop-gradient or the predictor collapses the output to a constant, as in the paper. The asymmetric loss costs 3.3 points, exactly the paper’s drop. A fixed random predictor keeps a healthy output std, but its backbone features collapse to rank 6: the two monitors measure different things (Figure 2).

Ablations during pretraining. Without stop-gradient or predictor the std goes to 0; the fixed predictor keeps a healthy std while its features collapse; cross-entropy slowly degrades.
The cross-entropy variant was the one disagreement with the paper (43.1% against 63.2%). Its loss rises back to exactly , the entropy of a uniform distribution: weight decay shrinks the scale of the projector’s output from 1 to about 0.05, which the cosine ignores but which flattens the softmax. With that scale fixed to 1 it reaches 69.2%, close to the paper’s gap.
Beyond the paper: can stop-gradient be relaxed or replaced?
I let a fraction of the gradient flow through the target branch, , which leaves the forward pass unchanged. Accuracy falls from the smallest leak I tried: 1% of the gradient costs 4.9 points, 5% costs 28, and from 20% on the model is fully collapsed (Figure 3, left). Then I removed stop-gradient entirely and added two terms on the normalized output , in the spirit of VICReg [2]: a variance hinge that targets the healthy per-channel std, and the mean squared off-diagonal covariance, with weights fixed so that a random embedding pays about 0.01 in each.

Left: linear-probe accuracy against the fraction of gradient through the target (dotted: chance). Right: without stop-gradient, a variance term prevents complete collapse, and adding a covariance term matches SimSiam.
The variance term alone recovers 39 points (19.1% to 58.1%) but the dimensions stay correlated; adding the covariance term gives 75.8% without any stop-gradient, matching SimSiam (75.1%, two seeds each). A momentum target, in contrast, keeps stop-gradient and removes the transient dip in rank (Figure 4), with a small but consistent gain (76.0%).

Effective rank of the backbone features (two seeds each). SimSiam’s transient dip (shaded) disappears with a momentum target or with the variance and covariance terms.
Findings
- Pretraining is worth 26 points with 1,000 labels: 75.4% for a linear probe against 48.9% from scratch.
- Stop-gradient cannot be relaxed, but it can be replaced. It acts as a guard against both complete and dimensional collapse, and only for the similarity term: a covariance term added with stop-gradient bypasses it and collapses the model.
- The effective rank is worth monitoring. It exposed the transient collapse in the baseline and the feature collapse of the fixed predictor, which the paper’s output-std metric misses.
- A low loss can hide a shortcut: without color distortion the loss is lower than the baseline’s, but the features are worse than training from scratch (46.1%).
References
- X. Chen and K. He. Exploring simple Siamese representation learning. CVPR, 2021.
- A. Bardes, J. Ponce and Y. LeCun. VICReg: Variance-invariance-covariance regularization for self-supervised learning. ICLR, 2022.
- O. Roy and M. Vetterli. The effective rank: a measure of effective dimensionality. EUSIPCO, 2007.