Weakly Supervised Variational Autoencoder

Machine Learning
Introduced by
Kingma, D. P. et al. (building on VAE and semi-supervised deep generative models)
Year
2014–2018
Type
Generative model with weak supervision
Family
Deep learning / NLP / CV

What does it do?

A weakly supervised variational autoencoder (WS-VAE) is a deep latent-variable generative model that extends the variational autoencoder (VAE) so that training can use partial, noisy or coarse labels, such as crowd-sourced annotations, keyword heuristics or programmatic rules, instead of complete ground-truth labels.

The label signal enters the encoder and decoder terms and an additional supervised term in the training objective, so the latent space is shaped both by reconstructing the data and by agreement with the weak labels. The approach builds on the VAE framework and on semi-supervised deep generative modelling.

The intuition behind the method

A standard VAE learns to compress data into a continuous latent space and reconstruct it, but its latent dimensions have no guaranteed semantic meaning. Full supervision can tie latent dimensions to known concepts, but it requires costly labelling. Weak supervision sits between the two: cheap, imperfect labels, such as noisy crowd annotations, keyword heuristics or programmatic rules, are used to push the model so that some latent directions align with known concepts. The model learns the data representation and the label information together, so the resulting latent space can support downstream classification, generation or disentanglement. How strongly the labels shape the result depends on the weight given to the supervised term.

History

The variational autoencoder framework is attributed to Kingma and Welling (2014), and semi-supervised learning with deep generative models to Kingma, Mohamed, Rezende and Welling (2014). The weakly supervised extension described on this page builds on these two frameworks; it is a later adaptation of them rather than a single named model with its own dated introduction.

When to use it

Choose WS-VAE when you have a large unlabelled dataset together with a small or noisy labelled subset, and you need both a structured latent space and a generative model of the data. Candidate settings include image generation with semantic control, text with topic or sentiment guidance, and biomedical data with expert-annotated subsets. Do not use it when labels are abundant, clean and complete, since a discriminative classifier is simpler and is usually the better choice for prediction alone. Avoid it when the weak labels carry little information about the target concept, because the supervised term then adds noise to the latent space; an unsupervised VAE is preferable in that case.

Limitations and considerations

  • The result depends on the balance of alpha and beta: a large alpha can pull the latent space toward the labels at the expense of reconstruction, while a large beta pushes the posterior toward the prior.
  • The objective takes y* as given and does not model label noise or label confidence, so noisy or biased weak labels pass directly into the latent space and the decoder. Per-example confidence weights in the supervised term, or filtering of low-confidence labels, are common ways to reduce this effect, but they are design choices outside the base objective.
  • The KL term can drive posterior collapse, in which the encoder ignores the input and the latent code carries little information; the objective as written contains no term that addresses this.
  • The encoder and decoder must be designed for each modality (images, text or tabular data), because the appropriate likelihood and architecture differ.
  • Both generative quality (for example ELBO, reconstruction error or FID) and downstream task performance need to be reported, since a model can score well on one and poorly on the other.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The supervised term has its own weight alpha, so the influence of weak labels can be tuned separately from the reconstruction and KL terms.
  • The decoder is conditioned on the label signal, p(x|z, y*), so generation can in principle be steered by the labels as well as by the latent code.
  • The Gaussian posterior is sampled with the reparameterization trick, so the whole objective remains trainable by gradient-based optimisation.
  • Unlabelled examples still shape the representation through the reconstruction term, so the model does not rely on labels alone.

Applications

  • Image generation conditioned on noisy or crowd-sourced semantic labels.
  • Text representation learning guided by weak topic, sentiment or intent annotations.
  • Biomedical analysis with partial expert labels, such as pathology image classification.
  • Disentangled representation learning in which only some factors of variation are labelled.
  • Data augmentation for low-resource supervised tasks, using samples from the generative decoder.

How it works

How it works

1

An encoder network maps each input x, together with any available weak label signal y*, to a distribution over the latent space. It outputs the parameters of a Gaussian approximate posterior q(z|x, y*): the mean mu and the standard deviation sigma.

Formula
q_{\phi}(z | x, y^*)
2

A sample z is drawn from the posterior using the reparameterization trick: z = mu + sigma * epsilon, where epsilon is standard Gaussian noise. This makes the sampling step differentiable so gradients can flow back through the encoder during training.

Formula
z = \mu + \sigma \odot \epsilon,\quad \epsilon \sim \mathcal{N}(0, I)
3

Weak labels y* enter the model in two places: as a conditioning input to the encoder and decoder, and through a supervised term weighted by alpha in the objective. A common input encoding uses a one-hot or soft-probability vector for each available label, together with an indicator that marks examples whose label is missing or abstained, so that unlabelled examples are represented explicitly. The exact form of the supervised term (for example a classification or conditional log-likelihood loss over the labelled examples) is a design choice. The implementation must also state how examples without a label contribute to the objective.

4

A decoder network reconstructs the input x from z and the available label signal, maximising the conditional likelihood p(x|z, y*). The reconstruction term drives the unsupervised part of learning and helps the latent code capture data structure beyond what the labels convey.

Formula
p_{\theta}(x | z, y^*)
5

Training maximises a weighted objective: the expected log-likelihood of the reconstruction, minus beta times the KL divergence between the approximate posterior and the prior p(z), plus alpha times the supervised term. The reconstruction and KL terms follow the standard ELBO structure, but the alpha-weighted supervised term is added on top of it. Unless that term is itself derived from a likelihood bound, the full objective is not a lower bound on the data log-likelihood and should be treated as a weighted training loss. Because alpha and beta are separate weights, the strength of the label signal can be adjusted relative to the reconstruction and KL terms.

Formula
\mathcal{L} = \mathbb{E}_{q}[\log p_{\theta}(x|z,y^*)] - \beta \, D_{\mathrm{KL}}(q_{\phi}(z|x,y^*) \| p(z)) + \alpha \mathcal{L}_{\mathrm{sup}}

Common pitfalls

  • Treating all weak labels as equally reliable, which the objective does not account for by default.
  • Not monitoring the KL term per latent dimension, so posterior collapse goes unnoticed during training.
  • Reporting only reconstruction loss or only classification accuracy, which does not show whether the latent dimensions encode the supervised factors.
  • Leaving alpha and beta at default values without an ablation, since their balance changes both the latent structure and the predictions.
  • Using WS-VAE when the labels are clean and abundant; a supervised classifier needs less engineering and is the more direct choice.

Frequently asked questions

How is a weakly supervised VAE different from a semi-supervised VAE?

A semi-supervised VAE is usually described as treating labelled examples as correctly labelled and the rest as unlabelled. The weakly supervised variant described here targets labels that are noisy, heuristic or programmatically generated. The base objective does not model label noise, so label reliability must be handled when the labels are built or when the supervised term is weighted, for example with per-example confidence weights or by discarding low-confidence labels.

How do I choose the balance between the reconstruction loss and the supervised loss?

The weights alpha (supervised) and beta (KL regulariser) are the key hyperparameters. Begin with a small supervised weight relative to the reconstruction and KL terms, then increase it while tracking downstream task performance and latent structure on a validation set. Check that the KL term remains non-zero for the latent dimensions you use.

What is posterior collapse and how do I prevent it?

Posterior collapse occurs when the encoder learns to ignore the input and the KL term approaches zero, leaving the latent space uninformative. It can be mitigated by KL annealing (increasing beta gradually from a low value during training), free-bits constraints, or cyclical annealing schedules.

Can WS-VAE be used with text data?

Yes. Text VAEs are well established, and weak labels such as coarse topic categories, keyword-based sentiment, or programmatic rules from tools like Snorkel can serve as supervision signals. Discrete outputs are handled differently from continuous ones: token-level decoders typically use autoregressive likelihoods over the vocabulary, and any discrete latent variables may need a relaxation such as Gumbel-Softmax.

How should I evaluate a weakly supervised VAE?

Report both generative quality (ELBO, reconstruction error and, where applicable, FID or BLEU) and downstream task metrics such as classification accuracy on a clean held-out test set. Also inspect latent traversals or nearest-neighbour analyses to check whether the supervised factors are meaningfully encoded.

Related methods

Sources

  1. Kingma, D. P. & Welling, M. (2014). Auto-Encoding Variational Bayes. In Proceedings of the International Conference on Learning Representations (ICLR 2014).

    Open publication reference
  2. Kingma, D. P., Mohamed, S., Rezende, D. J. & Welling, M. (2014). Semi-supervised learning with deep generative models. In Advances in Neural Information Processing Systems (NeurIPS 2014), 27.

    Open publication reference