Search

Search papers and lessons

Semi-Supervised Learning

Level 3 · 12 min read

Semi-supervised learning trains on a small labelled set and a large unlabelled set together, using assumptions about the data's shape to let the unlabelled inputs improve the model.

On this page

  • Colour = topic mix
  • Probability
  • Learning basics
  • Losses & regularization
  • Discrete math
  • Sign in to see your progress

TL;DR

Semi-supervised learning trains one model on two kinds of data: a small set of inputs with labels, and a much larger set of inputs without them. Plain supervised learning throws the unlabelled inputs away. Semi-supervised methods use them anyway, under an assumption about how the data is shaped, such as nearby inputs tending to share a label. When the assumption holds, the unlabelled data sharpens the decision boundary and the model needs fewer labels.

Where you'll see it: in medical imaging, where a radiologist labels a few hundred scans but the hospital holds hundreds of thousands, and in web-scale classification, where labels are expensive but raw inputs are free.

Intuition

Labels are the expensive part

Labelling data costs money and time. Someone has to listen to each recording, read each document, or check each scan. Raw inputs are often cheap: sensors log them, users generate them, archives hold them. A team may have 500 labelled photos and 500,000 unlabelled ones. Supervised learning sees only the 500. The question semi-supervised learning asks is whether the 500,000 can help, even though they carry no answers.

They can, but only if they carry some information about the answers. Imagine two classes of points scattered on a table, and you are shown a few labelled points. The unlabelled points are not useless: they show where the points cluster. If there are two dense blobs of unlabelled points separated by an empty gap, the natural place to draw the boundary is in the gap. The unlabelled data told you something about the shape of the problem.

flowchart LR
  L["Few labelled examples"] --> S["Supervised loss"]
  U["Many unlabelled inputs"] --> A["Assumption about data shape"]
  A --> R["Unlabelled loss or penalty"]
  S --> T["Train one model on both"]
  R --> T
  T --> M["Better model from fewer labels"]

The assumption does the work

Every semi-supervised method rests on an assumption of this kind. The main ones are:

  1. Smoothness. If two inputs are close, their labels are probably the same. The decision function should not change quickly in regions where data is dense.
  2. Cluster. Data forms clusters, and points in one cluster share a label. The decision boundary should fall in low-density gaps between clusters.
  3. Manifold. High-dimensional inputs lie near a low-dimensional curved surface. Closeness should be measured along that surface, not through empty space.

When the assumption is true, unlabelled data is a free source of constraints. When it is false, the unlabelled data can push the model the wrong way, which is the most important practical risk and comes back in the failure section.

The math

Setting

Let L={(x1,y1),…,(xn,yn)}\mathcal{L} = \{(x_1, y_1), \dots, (x_n, y_n)\} be the labelled data and U={u1,…,um}\mathcal{U} = \{u_1, \dots, u_m\} the unlabelled inputs, with m≫nm \gg n. A model fθf_\theta outputs a predicted distribution over labels for each input. Write pθ(y∣x)p_\theta(y \mid x) for the probability it assigns to label yy given input xx. The standard supervised objective is the average cross-entropy over labelled pairs:

Jsup(θ)=1n∑i=1n−log⁡pθ(yi∣xi).\mathcal{J}_{\text{sup}}(\theta) = \frac{1}{n} \sum_{i=1}^{n} -\log p_\theta(y_i \mid x_i).

Semi-supervised methods minimise this plus a term Junsup\mathcal{J}_{\text{unsup}} that depends only on the unlabelled inputs, weighted by a hyperparameter λ≥0\lambda \ge 0:

J(θ)=Jsup(θ)+λ Junsup(θ).\mathcal{J}(\theta) = \mathcal{J}_{\text{sup}}(\theta) + \lambda \, \mathcal{J}_{\text{unsup}}(\theta).

Everything that distinguishes the methods is the choice of Junsup\mathcal{J}_{\text{unsup}}. Three choices cover most of the field.

Consistency regularisation

Under the smoothness assumption, a small change to an input should not change the prediction much. Pick a random transformation TT that keeps the label, such as a small shift or flip of an image, and penalise disagreement:

Jcons(θ)=1m∑j=1mD(pθ(⋅∣uj),  pθ(⋅∣T(uj))),\mathcal{J}_{\text{cons}}(\theta) = \frac{1}{m} \sum_{j=1}^{m} D\big( p_\theta(\cdot \mid u_j),\; p_\theta(\cdot \mid T(u_j)) \big),

where DD is a divergence between two label distributions, often the squared error or the KL divergence. The penalty uses no labels at all. It only asks the model to agree with itself under a transformation that should not matter. This is the reason Data Augmentation and semi-supervised learning are so closely linked.

Pseudo-labelling

The simplest method is to let the model label its own confident predictions. For each unlabelled input, take the most likely class y^j=arg⁡max⁡ypθ(y∣uj)\hat{y}_j = \arg\max_y p_\theta(y \mid u_j). If the confidence max⁡ypθ(y∣uj)\max_y p_\theta(y \mid u_j) exceeds a threshold τ\tau, such as 0.950.95, add the pair (uj,y^j)(u_j, \hat{y}_j) to the labelled set for training. The unlabelled term is then an ordinary cross-entropy on these self-generated labels, with weight λ\lambda and only the confident points included.

The threshold is what keeps this from being a machine for amplifying errors. Without it, every prediction becomes a training label, including the wrong ones.

Entropy minimisation

A related penalty asks each unlabelled prediction to be sharp, meaning close to one class rather than spread across several:

Jent(θ)=−1m∑j=1m∑ypθ(y∣uj)log⁡pθ(y∣uj).\mathcal{J}_{\text{ent}}(\theta) = -\frac{1}{m} \sum_{j=1}^{m} \sum_{y} p_\theta(y \mid u_j) \log p_\theta(y \mid u_j).

This is the entropy of each prediction, averaged. It pushes the decision boundary away from dense unlabelled regions, which is the cluster assumption written as a loss. Like pseudo-labelling, it can lock in mistakes, so it is usually combined with the other penalties.

Label propagation

A different family works on a graph. Connect each input to its nearest neighbours with edge weights wij≥0w_{ij} \ge 0, and let FF hold a score for each input, where labelled inputs have their true scores fixed. A simple iterative rule replaces each unlabelled score by the weighted average of its neighbours:

Fi←∑jwijFj∑jwij,for unlabelled i,F_i \leftarrow \frac{\sum_j w_{ij} F_j}{\sum_j w_{ij}}, \qquad \text{for unlabelled } i,

while labelled entries are reset to their true values after each sweep. The fixed point is the harmonic function: the score at each unlabelled node is the average of its neighbours. The graph Laplacian gives the same solution in closed form, but the averaging rule is enough to see what the method does: information spreads from labelled nodes along the graph.

Worked examples

Example
Label propagation on a line

Five points lie on a line, at positions 1 to 5. Each point is connected to its immediate neighbours with weight 1. Point 1 has label A, which we score as 1. Point 5 has label B, scored as 0. Points 2, 3 and 4 are unlabelled and start at 0.5.

  1. Update all three points from the same starting scores (a simultaneous sweep). Point 2: its neighbours are point 1 (score 1) and point 3 (score 0.5). The average is (1+0.5)/2=0.75(1 + 0.5)/2 = 0.75.
  2. Point 3: its neighbours are point 2 (0.5) and point 4 (0.5). The average is (0.5+0.5)/2=0.5(0.5 + 0.5)/2 = 0.5.
  3. Point 4: its neighbours are point 3 (0.5) and point 5 (0). The average is (0.5+0)/2=0.25(0.5 + 0)/2 = 0.25.
  4. Points 1 and 5 keep their fixed values. The scores are now 1,0.75,0.5,0.25,01, 0.75, 0.5, 0.25, 0.
  5. Another sweep changes nothing, so this is the fixed point. It is exactly the straight line from 1 down to 0.

Interpretation: the label spreads smoothly from A toward B. The midpoint 0.5 is the most uncertain point, and the boundary sits there. With a dense cluster of points between 2 and 4 and a gap elsewhere, the same rule would keep the scores flat inside the cluster and drop them sharply across the gap. That shape is the cluster assumption at work.

Example
Pseudo-labels on a larger unlabelled set

Suppose a classifier has been trained on a small labelled set. It is applied to 10,000 unlabelled images with a confidence threshold of 0.9. These numbers are illustrative, not from a real run.

  1. Assume 6,200 of the 10,000 images pass the threshold. The other 3,800 are discarded for now.
  2. Among the 6,200 kept pseudo-labelled images, assume 97 percent have the correct label. That is 6,200×0.97=6,0146{,}200 \times 0.97 = 6{,}014 correct and 6,200−6,014=1866{,}200 - 6{,}014 = 186 wrong.
  3. Without the threshold, all 10,000 would be used, and the number of wrong labels would be whatever the model gets wrong on the 3,800 low-confidence images. That is typically a much larger share, since these are the hard cases.
  4. The kept set is 6,014 good examples plus 186 bad ones. The 186 bad labels are a 3 percent error rate on the new training data, which the model will partly learn.
  5. Retraining on the kept set usually improves accuracy if the original model was better than chance on those confident images, and the errors do not all point the same way.

Interpretation: the threshold trades quantity for quality. A higher threshold keeps fewer, cleaner examples. A lower one keeps more examples and more noise. Choosing it is a tuning decision, and the right value depends on how well calibrated the model's confidence is.

Tradeoffs and failure modes

Semi-supervised methods pay off when labels are scarce and the assumptions hold. They can hurt when they do not.

SituationWhat goes wrongBetter choice
Labelled and unlabelled data come from the same source, with a clear cluster structureWorks well; the unlabelled data sharpens boundariesUse entropy minimisation or pseudo-labelling with a threshold
Unlabelled data comes from a different distributionThe model learns the wrong structure, a form of [[covariate-shiftdistribution shift]]
The model is confidently wrong on a subgroupPseudo-labels reinforce the error: confirmation biasBalance the classes and add augmentation so errors do not concentrate
Very few labels, say a handful per classThe initial model is too poor to label anything reliablyUse self-supervised pretraining first, then fine-tune on the labels
Inputs have a meaningful graph structure, such as citation or social networksPlain input similarity misses the structureUse label propagation or a graph neural network such as the [[graph-convolutional-network
Labelled and unlabelled sets are both largeThe gain shrinks, and the extra cost is not worth itTrain supervised on all labels

Two failure modes need the most care. First, confirmation bias: the model trains on its own predictions, so an early mistake becomes a label and then a stronger belief. Second, the penalty weight λ\lambda is a hyperparameter that is hard to tune without labels. Many papers choose it using a held-out labelled validation set, which quietly uses more labels than the method is supposed to need. Evaluate on a validation set that is as scarce as the training set, or the reported gains will be too optimistic.

Modern methods such as FixMatch combine consistency with confident pseudo-labels, and they are the usual baseline now. Their gains are real but depend on careful augmentation and the threshold, which is why a careful comparison, like the one by Oliver and colleagues, found that reported improvements often shrink under a fair evaluation.

History

The idea is older than the name. In the 1960s, H. J. Scudder studied adaptive pattern recognisers that train on their own outputs, an early form of self-training, the idea behind pseudo-labelling. In 1977, Dempster, Laird and Rubin published the expectation-maximisation algorithm, which fits a mixture model using labelled and unlabelled data together and gave the field a principled tool. The term "semi-supervised" became common in the following decades, as data collection grew faster than labelling.

Label propagation on graphs was developed by Xiaojin Zhu and Zoubin Ghahramani in the early 2000s, and the book by Olivier Chapelle, Bernhard Schölkopf and Alexander Zien in 2006 gathered the main assumptions into one framework. Pseudo-labelling was revived for deep networks by Dong-Hyun Lee in 2013, and consistency methods such as the temporal ensembling of Samuli Laine and Timo Aila followed in 2016. The field's current baselines come from around 2019 to 2020, when FixMatch and related methods made strong results on image benchmarks routine. The exact years for the early work vary by source, so treat the dates above as approximate.

Check yourself

QuestionRecall: what does a semi-supervised method use the unlabelled inputs for, if they have no labels?Show answer

It uses them through an assumption about the data's shape, such as smoothness or cluster structure. The unlabelled term in the loss penalises predictions that break the assumption, for example predictions that change sharply between nearby inputs or that sit in dense regions. The labels are not needed for that term, only the inputs and the assumption.

QuestionComputation: a model is 0.96 confident on an unlabelled image and the threshold is 0.9. Is the image kept as a pseudo-label? If 200 images had confidence above 0.9 and 4 percent of them are wrong, how many wrong pseudo-labels are added?Show answer

Yes, the image is kept, because 0.96 is above 0.9. The number of wrong pseudo-labels is 200×0.04=8200 \times 0.04 = 8. This is the price of the threshold: even confident predictions err at the stated rate, so the threshold should be set by how calibrated the model is, not by a round number alone.

QuestionWhy: why does pseudo-labelling need a confidence threshold, while consistency regularisation does not?Show answer

Pseudo-labelling turns each prediction into a hard training label, so a wrong prediction becomes a wrong target that the model is then pushed toward. The threshold keeps the least reliable predictions out. Consistency regularisation never creates a hard label: it only asks the model to agree with its own prediction under a transformation. A wrong prediction is still penalised for disagreeing across transformations, but it is not turned into a target, so it does not self-reinforce in the same way.

QuestionApplied: a hospital has 300 labelled scans and 80,000 unlabelled scans from a different scanner model than the labelled ones. A colleague proposes entropy minimisation on all 80,000. What is your concern and what would you do?Show answer

The cluster assumption holds only if the unlabelled scans come from the same distribution as the labelled ones. A different scanner shifts intensities and textures, so the unlabelled data may form clusters that have nothing to do with the diagnosis. Entropy minimisation would sharpen boundaries along those artefact clusters. I would first check whether the shift is real by comparing feature distributions, then either select unlabelled scans from the labelled scanner, or use consistency regularisation with scanner-specific augmentation so the model learns invariance to the shift. I would keep a validation set from the new scanner to measure whether the unlabelled data helps at all.

Sources