Contents
08Self-training, consistency and FixMatch
8.1Self-training: learning from your own confident answers
The oldest semi-supervised idea is self-training (Scudder, 1965). Train a model on the labeled data; use it to predict the unlabeled data; take the predictions it is most confident about, say those with probability at least \tau, as pseudo-labels; add them to the training set; retrain; repeat. It is the student who, after the teacher grades a few problems, checks the remaining answers they are very sure of and studies those too. Yarowsky (1995) used it for word-sense disambiguation, deciding for example whether “plant” means a factory or a living plant, starting from a handful of seed examples. Starting from a few seed collocations per sense (“manufacturing plant”, “plant life”), it reached 96.5\% accuracy on twelve ambiguous words when it also used the rule that a word keeps one sense within a document, as good as supervised training on the same contexts (96.1\%).
The danger is confirmation bias: a confident mistake becomes a training label, which makes the model even more confident in the same mistake. The confidence threshold \tau trades the number of pseudo-labels against their quality.
8.2Pseudo-labels and entropy minimization
Lee (2013) applied pseudo-labeling to neural networks: for each unlabeled input, the class with the highest predicted probability is treated as if it were the true label, and the network is trained on it with cross-entropy. Lee pointed out that this is closely related to entropy minimization (Grandvalet and Bengio, 2005), which adds to the loss the entropy of the predictions on unlabeled points,
where p_c(x) is the predicted probability of class c. The entropy is largest, \log C, when the prediction is maximally unsure and zero when it is certain. Unlabeled points near the decision boundary have unsure predictions and high entropy, so minimizing it pushes the boundary away from them, into a region with few points: entropy minimization is the low-density assumption written as a loss.
8.3Consistency regularization
A second family uses the smoothness assumption locally. A small, meaning-preserving change to an input, such as adding noise, cropping or flipping an image or replacing a word by a synonym, should not change the prediction:
The \Pi-model (Laine and Aila, 2017) uses exactly this penalty. Mean Teacher (Tarvainen and Valpola, 2017) makes the target more stable by computing it with a second copy of the network whose weights are an exponential moving average of the trained weights, \theta'\leftarrow\beta\theta'+(1-\beta)\theta with \beta close to 1. Consistency regularization does not need a graph: the augmentations themselves define which inputs count as neighbours.
8.4FixMatch: pseudo-labels plus consistency
FixMatch (Sohn et al., 2020) combines the two ideas in a strikingly simple way. For each unlabeled image u it makes a weakly augmented version \alpha(u) (a flip and a small shift) and a strongly augmented one \mathcal{A}(u) (heavy colour and shape distortions and a cut-out patch). The prediction on the weak version, q=p_\theta(y\mid\alpha(u)), becomes a pseudo-label \hat y=\arg\max_cq_c, but only if the model is confident, \max_cq_c\ge\tau. The model is then trained to predict that label from the strong version. With B labeled and \mu B unlabeled images per batch, the unlabeled loss is
where H is the cross-entropy, and the total loss is \ell_s+\lambda_u\ell_u with the usual supervised loss \ell_s on the labeled images. The paper used \tau=0.95, \mu=7 and \lambda_u=1. The intuition: the easy (weak) view is used to decide what the image is, and the hard (strong) view is used to learn to recognize it under difficult conditions.
Worked example 5. Take the probabilities shown in the video, for the classes (mountain, beach, city). For one unlabeled photo the weak view gives q=(0.91,\,0.06,\,0.03); with \tau=0.95 it is skipped this time, because the model is not yet confident enough (with the threshold 0.8 drawn in the video it would be kept). For another photo q=(0.97,\,0.02,\,0.01), so it gets the pseudo-label “mountain”. If the strong view is currently predicted as (0.48,\,0.34,\,0.18), its loss is -\log0.48=0.734; after training has raised the mountain probability to 0.88 the loss is -\log0.88=0.128.
How far does this go? On CIFAR-10, ten classes of small photos with 50,000 training images, FixMatch reached 94.9\% accuracy with only 250 labels (25 per class) and 88.6\% with 40 labels (four per class); the older \Pi-model and plain pseudo-labeling, run in the same code with 250 labels, got about half of the test images wrong (Sohn et al., 2020).
8.5When unlabeled data hurt
Semi-supervised learning is not free accuracy. In a careful re-evaluation, Oliver et al. (2018) found that many published gains shrink once the supervised baseline is tuned as carefully as the semi-supervised method, and that adding unlabeled data from classes not present in the labeled set can make results worse than using no unlabeled data at all. On CIFAR-10 with 4,000 labels, their carefully tuned supervised network had 20.3\% error rather than the 34.9\% reported in earlier papers, the \Pi-model reached 16.4\% (earlier reports: 12.4\%), and simply fine-tuning a network pretrained on ImageNet beat every semi-supervised method (12.1\% against 13.1\%). The practical rules that follow are: compare against a strong supervised baseline; make sure the unlabeled data come from the same distribution as the test data; and keep a labeled validation set to check that the unlabeled data actually help.
A real case. Medical imaging is where these ideas matter most. The ChestX-ray8 data set has 108,948 frontal chest X-rays of 32,717 patients. Reading an X-ray takes a trained radiologist, so the labels could not be crowd-sourced; they were text-mined from the radiology reports instead, with precision about 0.90 on a hand-checked sample, and a radiologist drew disease boxes on only 983 images (Wang et al., 2017). A hospital archive with many images and a few expert labels is exactly the semi-supervised setting; the video’s 100,000 scans with 2,000 labels illustrate it.
Pause and think. Why does FixMatch compute the pseudo-label on the weak augmentation rather than the strong one?
Show the answer
The weakly augmented image still looks like the original, so the model’s prediction on it is more likely to be right. Strong augmentation would make the pseudo-labels noisier, and noisy pseudo-labels feed confirmation bias.