- Introduced by
- Chen et al. (SimCLR linear evaluation protocol, 2020); logistic probe practice widely adopted across SSL literature
- Year
- 2020s
- Type
- Self-supervised pretraining + supervised linear classification
- Family
- Machine learning
What does it do?
Self-supervised logistic regression is a two-stage pipeline in which a neural encoder is first trained on abundant unlabeled data through a self-supervised pretext task, such as contrastive learning or masked prediction, and then the frozen learned representations are classified with a standard logistic regression model trained on a small labeled dataset.
This linear evaluation protocol is commonly used to benchmark the quality of self-supervised representations. In the SSL literature the same pipeline is usually called a linear probe or linear evaluation of self-supervised representations; these labels refer to the same procedure.
The intuition behind the method
Imagine teaching yourself to recognize shapes without anyone telling you the labels, simply by comparing pairs of images and learning what makes them similar or different. After this unsupervised practice, your internal representation of images becomes rich and structured. When you finally see a few labeled examples, a simple linear rule, logistic regression applied to your learned representation, may be enough to classify new examples accurately, depending on how closely the self-supervised practice task matches the task you need to solve. The quality of the linear classifier then reveals how useful the self-supervised pretraining was, which is why this combination is a common benchmark probe in the SSL community.
History
The linear evaluation protocol, which trains a logistic classifier on frozen self-supervised features, is a common evaluation practice in self-supervised learning research. SimCLR (Chen et al., 2020) is a prominent example of contrastive pretraining assessed this way, and contrastive methods such as MoCo are also commonly evaluated with linear probes.
When to use it
Use self-supervised logistic regression when labeled data is scarce but unlabeled data from a related domain is plentiful, as is common in medical imaging, NLP, or scientific settings. It is also the standard protocol for checking whether a self-supervised encoder yields transferable features, because a frozen encoder with a linear classifier isolates the quality of the representations. The approach depends on the pretraining and downstream domains being closely related. Avoid it when a large labeled set is available and a supervised model trained directly on the task is a simpler option; whether it outperforms this pipeline should be checked on the task itself. Also avoid it when the downstream task needs nonlinear decision boundaries in feature space, where fine-tuning the encoder is the more likely route, or when the compute needed to pretrain a large encoder is not available.
Limitations and considerations
- Requires a powerful, often large neural encoder to produce useful representations, which demands significant compute and unlabeled data for pretraining.
- Performance depends heavily on how well the pretext task aligns with the downstream classification task; mismatched tasks yield poor embeddings.
- A frozen linear probe may underperform compared to full fine-tuning when the decision boundary is nonlinear in the pretrained feature space.
- End-to-end interpretability is limited: the self-supervised encoder is a black box that produces the features fed to logistic regression.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Uses unlabeled data for the representation-learning stage, so the labeled set only has to support fitting a linear classifier on frozen features.
- The linear evaluation protocol gives a simple, reproducible way to compare encoders, since each encoder is scored with the same type of classifier on the same frozen-feature setup.
- Logistic regression on fixed embeddings is cheap to fit and returns class probabilities that can be inspected directly.
- Pretraining and classification are separate stages, so one pretrained encoder can be reused with different logistic classifiers for different labeled tasks.
- Because the encoder is frozen, the downstream step estimates only the classifier's weights, which keeps the labeled-data requirement for that step modest.
Applications
- Medical image classification with limited labeled scans but large unlabeled archives.
- NLP text classification using sentence embeddings from self-supervised language models.
- Benchmarking and comparing different self-supervised pretraining strategies via linear probing.
- Scientific data classification in biology and chemistry where annotation is expensive.
- Audio event detection using self-supervised audio encoders followed by logistic regression.
- Low-resource domain adaptation where labeled target data is scarce but unlabeled data is available.
How it works
How it works
A self-supervised pretext task is defined on unlabeled data: for example, predicting whether two augmented views of the same image are related (contrastive learning), reconstructing masked tokens (masked autoencoders), or predicting image rotations. The task provides a training signal without human labels, forcing the encoder to learn semantically meaningful representations.
A neural network encoder, often a convolutional network or transformer, is trained to minimize the pretext-task loss on a large unlabeled corpus. After training, the encoder captures high-level semantic structure in its intermediate representations (embeddings), even though no class labels were involved.
The encoder weights are frozen after pretraining. Each labeled training example is passed through the frozen encoder to produce a fixed-length embedding vector z. These embeddings serve as the input features for the downstream supervised step, replacing raw inputs.
A standard logistic regression model is fitted on the small labeled dataset using the frozen embeddings z as features. The mechanics formula is the binary form, giving the probability of class 1 as the sigmoid of a linear function of z. The weights w and bias b are estimated by maximizing the likelihood, which is equivalent to minimizing the cross-entropy loss, usually with an L2 penalty whose strength is chosen on a validation split rather than on the test set. Embeddings are often standardized before fitting, using statistics computed on the training split only, which helps the optimizer and makes the penalty act evenly across dimensions. For problems with more than two classes, the usual extensions are multinomial (softmax) logistic regression, which fits one weight vector per class jointly, or one-vs-rest logistic regression, which fits a separate binary classifier for each class; the choice should be stated when results are reported. When classes are imbalanced, reweighting the loss by inverse class frequency or choosing the decision threshold on validation data keeps the classifier from favouring the majority class. Whether a linear boundary in embedding space is sufficient depends on how well the pretext task aligns with the downstream task, and this should be checked on held-out labeled data.
Formula
P(y=1 \mid \mathbf{z}) = \sigma(\mathbf{w}^\top \mathbf{z} + b)The trained logistic classifier is evaluated on a held-out test set using standard metrics: accuracy, F1, and AUC-ROC. In the SSL benchmarking literature this is called the linear evaluation protocol; high linear accuracy on frozen features signals that the pretraining learned useful, linearly separable representations. Several protocol details matter for a fair result. The test set must be untouched by both encoder pretraining and hyperparameter tuning, including the choice of regularization strength. Under class imbalance, accuracy can be misleading, so per-class metrics or balanced accuracy should be reported alongside it. Because results vary with the labeled subset and the random seed, report variability across several random splits or seeds rather than a single value, and check performance across more than one labeled-set size. Finally, compare the frozen pretrained encoder against a randomly initialized encoder evaluated with the same probe; this baseline shows how much of the score comes from pretraining rather than from the probe itself.
Common pitfalls
- Evaluating on the same unlabeled pool used for pretraining — the encoder has seen these inputs, which can inflate downstream estimates.
- Assuming a high linear probe score means the model will generalize to a different domain without further validation.
- Skipping data augmentation or using weak augmentations in contrastive pretraining, leading to underperforming representations.
- Using too small an unlabeled pretraining set, so the encoder does not learn sufficiently general representations.
- Forgetting to freeze the encoder during linear evaluation, which conflates encoder quality with downstream fine-tuning.
Frequently asked questions
What is a linear probe in self-supervised learning?
A linear probe is exactly this setup: after self-supervised pretraining, the encoder is frozen and a simple linear classifier — typically logistic regression — is trained on its output embeddings using labeled data. The linear probe accuracy benchmarks how useful and linearly separable the pretrained representations are.
Should I use linear probing or full fine-tuning?
Linear probing is faster and reveals whether the representations are already useful; it is the standard evaluation benchmark. Full fine-tuning of the encoder typically yields higher downstream accuracy at the cost of more labeled data and compute, and risks forgetting the pretrained representations. In practice, linear probing first, then fine-tuning if needed.
How much labeled data do I need for the logistic regression step?
There is no fixed rule. The answer depends on how well the encoder's representations separate the classes and on how difficult the task is. Because the logistic step has far fewer parameters than the encoder, results can be informative with small labeled sets, but performance should be checked across several labeled-set sizes rather than taken from a single figure.
Does the pretext task have to match my downstream task?
Not exactly, but alignment matters. Contrastive vision pretraining transfers well to many visual classification tasks. If the pretext task is very different from the downstream task — for example, predicting image rotations and then using the features for molecular property prediction — the representations may be poor. Always validate transfer quality with the linear probe.
Can I apply this without a deep neural encoder?
Self-supervised pretraining is most beneficial when the encoder is expressive enough to learn complex representations. For simple tabular data, classical feature engineering or autoencoders are more commonly used; the deep self-supervised + logistic regression pipeline is most impactful for images, text, audio, and other high-dimensional structured inputs.
Related methods
Sources
Chen, T., Kornblith, S., Norouzi, M., & Hinton, G. (2020). A Simple Framework for Contrastive Learning of Visual Representations. Proceedings of the 37th International Conference on Machine Learning (ICML), 1597–1607.
Open publication referencevan Engelen, J. E., & Hoos, H. H. (2020). A survey on semi-supervised learning. Machine Learning, 109(2), 373–440.
Open DOI reference