- Introduced by
- Odena, A.; Salimans, T. et al.
- Year
- 2016
- Type
- Semi-supervised generative model
- Family
- Deep learning / NLP / CV
What does it do?
Semi-supervised GAN (SGAN) changes the GAN discriminator so that it outputs K+1 classes: the K real categories of interest and one extra class for generated samples.
One network is trained with a supervised loss on labeled examples and an adversarial loss on unlabeled real and generated examples, so a classifier can be learned from a small labeled set together with a large unlabeled set.
The intuition behind the method
In an ordinary GAN the discriminator only answers 'real or fake?'. SGAN keeps that role but adds the real categories: the first K outputs correspond to the classes of interest (for example dog and cat), and the last output marks generated images. Labeled examples train the real classes directly. Unlabeled real images must still be assigned to one of the real classes rather than the fake class, which gives the network a learning signal without labels. The generator's samples supply the fake class, so the classifier has to separate them from real data.
History
Semi-supervised GANs extend the generative adversarial network framework to classification. Salimans et al. (2016), 'Improved Techniques for Training GANs' (NeurIPS 2016), introduced feature matching and reported semi-supervised classification experiments. It is the reference used on this page for those techniques.
When to use it
Choose Semi-supervised GAN when you have a large unlabeled pool of high-dimensional data, such as images, only a small labeled subset, and labeling the rest is costly. It fits classification problems in which a generator can be trained on the same inputs, as in the image settings described on this page. Do not choose it when labeled data are plentiful, because supervised training is simpler and may perform as well. Avoid it when training is unstable or the generator collapses, since the unlabeled and fake-class terms depend on a working generator. The method assumes that labeled and unlabeled data come from the same distribution, that the labeled set contains at least some examples of every one of the K classes, and that the generator reaches a non-collapsed state before the unsupervised term is relied on. Benefits on tabular or text data are not established by the sources for this page, so check any such use against a supervised baseline.
Limitations and considerations
- The unsupervised term depends on the generator, so mode collapse or divergence removes the benefit that the unlabeled data are meant to provide.
- The balance between the supervised and unsupervised losses sets how much unlabeled and synthetic data influence the classifier, and a poor balance lets one term dominate.
- A single discriminator must both classify and detect fakes, so the classification task can compete with generation quality.
- Evaluation needs two kinds of measurement: classification accuracy on held-out data and the quality of generated samples.
- The image-based design uses convolutional networks, which do not transfer directly to tabular or unstructured data without changing the architecture.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Uses unlabeled real data directly through the unsupervised loss, so the classifier can learn from examples that have no labels.
- Generated samples enter only as examples of the fake class, so they do not add labeled examples for the K real classes; their role is to shape the discriminator's features.
- One network serves both classification and generation, sharing feature representations between the two tasks.
- Useful where annotation is costly, provided a stable GAN can be trained on the data.
- Feature matching is one of the generator objectives described for this method and is intended to make training more stable than a plain minimax objective.
Applications
- Classification with a small labeled set and a large unlabeled image pool, where the generator's samples serve as the fake class during training.
- Settings where a generative model is needed alongside the classifier, so that one network provides both tasks.
How it works
How it works
The standard binary discriminator is replaced by a (K+1)-way softmax classifier. The first K outputs correspond to the real categories in the labeled set, and the (K+1)-th output marks generated samples. A single network is therefore asked both to classify and to separate real from synthetic data.
For labeled examples, the loss is the negative log-likelihood of the true class among the K real classes, conditioned on the example being real. This is the only term in which the class labels enter training.
Formula
L_{sup} = -\mathbb{E}_{(x,y)\sim p_{data}}[\log p(y|x, x\text{ is real})]For unlabeled real examples, the first term penalises assigning them to the fake class, so they must receive probability on one of the K real classes. For generated examples, the second term raises the probability of the fake class. Together the two terms form the adversarial signal that makes use of unlabeled data.
Formula
L_{unsup} = -\mathbb{E}_{x\sim p_{data}}[\log(1-p(y=K+1|x))] - \mathbb{E}_{x\sim G}[\log p(y=K+1|x)]The generator is trained so that the discriminator does not assign its samples to the fake class. The page names feature matching and the standard minimax objective as options. With either, the generator is intended to produce samples realistic enough to act as a regularizer for the classifier.
The supervised and unsupervised losses are combined and optimized together, with generator and discriminator updated in alternation. The relative weight given to the two losses controls how strongly unlabeled and synthetic data influence the final classifier.
Common pitfalls
- Treating the (K+1)-th class as an ordinary category rather than an explicit fake detector, which removes the adversarial signal from the unlabeled data.
- Assuming the labeled set covers all K classes; a class with no labeled examples is not learned by the supervised term.
- Ignoring mode-collapse diagnostics such as visual inspection of samples or FID, and reporting classification results from a collapsed generator.
- Tuning only the supervised side while leaving the unsupervised adversarial weight at its default, so the two objectives dominate each other unpredictably.
- Reporting accuracy on the same small labeled split used for training, which can hide overfitting to the labeled portion.
Frequently asked questions
How many labeled examples are needed for Semi-supervised GAN to outperform a plain supervised model?
Gains are largest when labeled examples are scarce relative to the unlabeled pool. When labels are plentiful, a well-tuned supervised model may match or exceed SGAN, so compare against a supervised baseline on your own data.
What is feature matching, and why does it help?
Feature matching replaces the generator's minimax loss with a loss that matches statistics of real and generated data in an intermediate discriminator layer. It is intended to stabilize training and to produce discriminator features that generalize better to classification.
Can Semi-supervised GAN be applied to text or tabular data?
Possibly, but the sources available for this page do not establish that SGAN works on text or tabular data or how much benefit to expect there. The architecture would also need to change from the image design. Validate against a supervised baseline on your own data before relying on it.
How do I know if my GAN is suffering from mode collapse during semi-supervised training?
Inspect generated samples visually for lack of diversity, monitor the discriminator's fake-class probability (if it saturates near the same value for nearly all inputs, something is wrong), and track Frechet Inception Distance (FID) or a similar generative metric alongside classification accuracy.
Is Semi-supervised GAN still competitive with modern self-supervised methods?
Self-supervised and contrastive approaches are an alternative in low-label settings where a generative model is not required. Whether they outperform SGAN depends on the data and task, so compare them on your own data. SGAN remains relevant where a generative model is needed alongside the classifier.
Related methods
Sources
Salimans, T., Goodfellow, I., Zaremba, W., Cheung, V., Radford, A., & Chen, X. (2016). Improved Techniques for Training GANs. Advances in Neural Information Processing Systems (NeurIPS), 29.
Open publication referenceOdena, A. (2016). Semi-Supervised Learning with Generative Adversarial Networks. ICML Workshop on Generative Adversarial Networks.
Open publication reference