Semi-Supervised & Self-SupervisedSelf-Supervised LearningRepresentation Learning

SimCLR

Primary task · Representation Learning

SimCLR is a semi-supervised & self-supervised method in the self-supervised learning family. This page summarizes its mechanism, practical uses, important trade-offs, and a browser-based concept explorer.

← Directory
Visual intuition

From data to learned behaviour

SimCLR converts patterns in observed data into a reusable prediction or representation rule. The most useful way to understand it is to watch what internal structure changes during training and how that learned structure changes outputs.

Infographic
1Data2Initial state3Optimise4Validate5InferenceTraining transforms evidence into a reusable model state
Conceptual simulation

Watch the learning mechanism form

The structure below is synchronized with the same training state used by the prediction simulation.

Mechanism view
Training control centre

Control both simulations together

Reset regenerates the synthetic data and model state. Train animates to completion. Pause freezes the animation. Train Step advances one learning stage.

Step 0 / 12
Model simulation

Inspect the learned prediction / representation

Synthetic data are generated locally in your browser.

Model description

Understand SimCLR after watching it learn

This section connects the animation to the actual statistical or computational idea behind the model.

Deep description

SimCLR SimCLR is a semi-supervised & self-supervised method in the self-supervised learning family. This page summarizes its mechanism, practical uses, important trade-offs, and a browser-based concept explorer.

What is learned. During training, the algorithm builds or adjusts the parameters and internal representation used by SimCLR. The core learning mechanism is: Maximizes agreement between differently augmented views of the same image via a contrastive loss (NT-Xent) in latent space while pushing different images apart.

How training becomes inference. Prepare data → initialise the model state → evaluate the current objective → update parameters or structure → validate progress → use the final state for inference. Once training stops, the fitted state is reused on unseen inputs rather than being reconstructed from scratch. The resulting output is: A learned embedding that can be reused for similarity, retrieval, clustering or downstream prediction.

Why practitioners use it. Simple architecture without specialized memory banks; produces highly transferable feature representations. Typical fits include Visual representation learning without manual labels, medical image feature extraction.

What to verify before trusting it. Requires massive batch sizes (e.g., 4096) and negative sample pairs to prevent representational collapse. The visual simulation is intentionally simplified, so real use should still validate preprocessing, data independence, hyperparameters, uncertainty and task-appropriate metrics.

Internal statethe parameters and internal representation used by SimCLR
Typical outputA learned embedding that can be reused for similarity, retrieval, clustering or downstream prediction.
Good fitVisual representation learning without manual labels, medical image feature extraction.
Main cautionRequires massive batch sizes (e.g., 4096) and negative sample pairs to prevent representational collapse.
1Training data→
2Learning objective→
3Internal model state→
4Prediction / representation→
5Evaluation
Intuition

What the model is trying to learn

SimCLR converts patterns in observed data into a reusable prediction or representation rule. The most useful way to understand it is to watch what internal structure changes during training and how that learned structure changes outputs.

Mathematical lens

Core logic

Maximizes agreement between differently augmented views of the same image via a contrastive loss (NT-Xent) in latent space while pushing different images apart. The mathematical objective determines which model states are considered better, while regularisation and validation constrain how much complexity should be trusted.

Training sequence

How learning progresses

Prepare data → initialise the model state → evaluate the current objective → update parameters or structure → validate progress → use the final state for inference.

Original mechanism

Taxonomy description

Maximizes agreement between differently augmented views of the same image via a contrastive loss (NT-Xent) in latent space while pushing different images apart.

Evaluation guide

How to evaluate this model responsibly

ValidationChoose validation that matches the independence assumptions of the data.
MetricsUse task-specific primary and complementary metrics.
HPOEstablish a baseline first, then search the parameters that materially change capacity.
Post-processingValidate any downstream transformation on held-out data.
Hyperparameters

Key parameters

temperatureTypical: 0.1

NT-Xent softmax temperature.

batch_sizeTypical: 256+

Larger batches supply more negatives.

projection_dimTypical: 128

Projection-head output width.

augmentation_strengthTypical: strong

View-generation policy.

Use & trade-offs

Where it fits

Typical applications

Visual representation learning without manual labels, medical image feature extraction.

Strengths

Simple architecture without specialized memory banks; produces highly transferable feature representations.

Limitations

Requires massive batch sizes (e.g., 4096) and negative sample pairs to prevent representational collapse.

Code example

Minimal Python implementation

import torch
import torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(7)
encoder=nn.Sequential(nn.Linear(10,16),nn.ReLU(),nn.Linear(16,8))
x=torch.randn(12,10); view1=x+0.10*torch.randn_like(x); view2=x+0.10*torch.randn_like(x)
z1=F.normalize(encoder(view1),dim=1); z2=F.normalize(encoder(view2),dim=1)
sim=z1@z2.T; positives=sim.diag()
print("STEP 1 · Encode two augmented views of each observation")
print("STEP 2 · Build the cross-view cosine-similarity matrix", tuple(sim.shape))
print("STEP 3 · mean positive-pair similarity", round(positives.mean().item(),4))
Expected / representative output
STEP 1 · Encode two augmented views of each observation
STEP 2 · Build the cross-view cosine-similarity matrix (12, 12)
STEP 3 · mean positive-pair similarity 0.9921