Foundations to Frontier
Tests
E. Deep Learning › E16 Self-Supervised and Contrastive Learning

BYOL

Bootstrap Your Own Latent (BYOL; Grill and colleagues, NeurIPS 2020) learns representations with no negative pairs at all. An online network predicts a target network's projection of a different augmented view. The target is a slow exponential moving average of the online network. A trivial solution exists (every image maps to the same vector), yet BYOL avoids it in practice, thanks to the asymmetry between an online predictor and a slowly moving target. This page covers the online/target design, the 2 − 2·cos loss, the EMA schedule and why collapse is avoided. In the exercises you implement the loss and a collapse measure, then train BYOL and two ablations on the style-dominated world. Full BYOL reached probe accuracy 0.69 with healthy embedding spread (0.20). Without the predictor it reached 0.53, and without the momentum target 0.33, both with embeddings partly collapsed (spread 0.05–0.06).

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Predict your own slower twin

BYOL has two copies of a network. The online copy sees one altered view of an image and tries to predict what the target copy outputs for a different view. The target is not trained directly; it slowly follows the online copy. There are no negatives, nothing pushing different images apart, so in principle the networks could cheat by mapping everything to the same point. Surprisingly, with a predictor and a slow target, they do not. The demo shows what collapse looks like: an embedding whose spread shrinks to a few directions.

Self-supervised learning lab
Effective rank 15.6 of 16 dimensions. Non-contrastive methods need stop-gradients, predictors, centring or variance terms to keep the spectrum from collapsing to a few directions.
Why engineers care

Methods without negatives are robust to batch size and do not need careful negative sampling, which helps when data has few classes or many near-duplicates, as in industrial and sensor imagery.

📝 Quick check (Level 0)
0/3 answered
  1. 1. BYOL uses negatives?
  2. 2. The target network…
  3. 3. The risk without negatives is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Online branch: encoder f_θ → projector g_θ → predictor q_θ → p.
  • Target branch: encoder f_ξ → projector g_ξ → z’ (no gradient).
  • Loss: ‖p/‖p‖ − z’/‖z’‖‖² = 2 − 2 cos(p, z’), symmetrised over swapping the views.
    • cos = 1 gives 0, cos = 0 gives 2, cos = −1 gives 4.
  • Target update: ξ ← τξ + (1 − τ)θ, with τ rising from 0.996 to 1 on a cosine schedule.
  • Collapse diagnostic: the mean per-dimension standard deviation of normalised embeddings is near 0 when every image maps to the same direction.
📝 Quick check (Level 1)
0/3 answered
  1. 1. BYOL loss for cos = 0:
  2. 2. Which branch has the predictor?
  3. 3. τ at the end of the cosine schedule:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

BYOL in code

Exercise 1.

  • The BYOL loss equalled 2 − 2 cos.
  • The EMA moved the target by 1 − τ toward the online network.
  • The spread was zero for a collapsed embedding.

Practice.

  • Use lightly or solo-learn BYOL implementations: ResNet encoder, 2-layer MLP projector and predictor (4096 hidden, 256 output), LARS, τ_base = 0.996.
  • Batch norm in the MLPs helps but is not strictly required (group norm with weight standardisation also works).
  • Monitor embedding spread or effective rank during training, so you catch collapse early.
p1, p2 = pred(proj(enc(x1))), pred(proj(enc(x2)))          # online branch
with torch.no_grad():
    z1, z2 = proj_t(enc_t(x1)), proj_t(enc_t(x2))          # target branch (EMA, no grad)
loss = (2 - 2 * F.cosine_similarity(p1, z2)).mean() + (2 - 2 * F.cosine_similarity(p2, z1)).mean()
loss.backward(); opt.step(); ema_update(enc_t, enc, tau); ema_update(proj_t, proj, tau)
🐍 Exercise 1: BYOL loss and collapse
Implement the BYOL loss, the EMA update and an embedding-spread collapse measure.
📝 Quick check (Level 2)
0/3 answered
  1. 1. BYOL's predictor is…
  2. 2. Collapse is caught by monitoring…
  3. 3. BYOL without batch norm is possible with…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why does BYOL not collapse?

  • The constant map minimises the loss, yet training does not find it.
  • Analyses (Tian, Chen and Ganguli, 2021) show that, with a predictor and a slowly moving target, the dynamics of gradient descent on the online network do not flow toward the collapsed solution: the predictor learns to track the target’s directions, and the EMA prevents the target from collapsing as fast as the online network would.
  • Remove either asymmetry and collapse becomes much more likely.

Bootstrapping. The target supplies regression targets that improve as the online network improves, like target networks in reinforcement learning. Its slowness keeps targets stable.

Fragility. Without negatives, success depends on optimisation details: predictor learning rate, momentum schedule, normalisation and training length. Ablations often fail differently in different settings.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The constant map is…
  2. 2. BYOL's target network resembles…
  3. 3. BYOL's success depends on…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Do the predictor and the momentum target prevent collapse?

History.

  • J.-B. Grill et al., “Bootstrap your own latent: a new approach to self-supervised learning” (NeurIPS 2020).
  • P. Richemond et al. (2020), BYOL works without batch statistics.
  • Y. Tian, X. Chen and S. Ganguli (ICML 2021), analysis of non-contrastive learning dynamics.

Exercise 2.

  • Setup: the same style-dominated world and probe as earlier pages. Encoder 32 → 64 → 16, projector and predictor 16 → 32 → 16, 1500 Adam steps (learning rate 0.01), symmetric loss.
  • Variants: full BYOL (predictor, EMA target with m = 0.99); without the predictor; and without momentum (target = online network).
  • Measurements: probe accuracy and the spread of the normalised embeddings.
variant probe accuracy embedding spread
raw observations 0.522 0.176
BYOL 0.686 0.204
no predictor 0.534 0.059
no momentum 0.330 0.051
  • BYOL works without negatives: it improves the probe from 0.52 to 0.69 and keeps a healthy spread.
  • Removing either asymmetry causes partial collapse: spread falls by a factor of 3–4, and accuracy drops to raw level or below.
  • Seeds: with seeds 1 and 2, BYOL beat both ablations again (0.73 and 0.64 against 0.59 and 0.51 without the predictor, 0.47 and 0.50 without momentum).
  • The no-momentum result depended on settings: at learning rate 0.003 that variant did not collapse (0.67), a reminder of how fragile non-contrastive training is.
  • BYOL stayed below SimCLR here (0.69 vs 0.78) in this small setting.
🐍 Exercise 2 (research): do the predictor and the momentum target prevent collapse?
Train BYOL and ablations without the predictor and without momentum, measuring probe accuracy and embedding spread.

BYOL in AI, robotics and aerospace

  • Few-class sensor data: pre-training where negatives are often false negatives (many near-identical scenes).
  • Robotics: bootstrapped targets also appear in reinforcement learning and world models.
  • Design lesson: without negatives, guard against collapse explicitly. Monitor spread or rank, and ablate the asymmetries in your own setting.

References

  1. J.-B. Grill et al. (2020). “Bootstrap your own latent: a new approach to self-supervised learning.” NeurIPS.
  2. Y. Tian, X. Chen and S. Ganguli (2021). “Understanding self-supervised learning dynamics without contrastive pairs.” Proc. ICML.
  3. P. H. Richemond et al. (2020). “BYOL works even without batch statistics.” arXiv:2010.10241.