Exemplar VAEs for Exemplar based Generation and Data Augmentation

Sajad Norouzi, David J. Fleet, Mohammad NorouziarXiv 2020

Abstract

We introduce Exemplar VAEs, a family of generative models that bridge the gap between parametric and non-parametric, exemplar based generative models. Exemplar VAE is a variant of VAE with a non-parametric prior in the latent space based on a Parzen window estimator. To sample from it, one first draws a random exemplar from a training set, then stochastically transforms that exemplar into a latent code and a new observation. We propose retrieval augmented training (RAT) as a way to speed up Exemplar VAE training by using approximate nearest neighbor search in the latent space to define a lower bound on log marginal likelihood. To enhance generalization, model parameters are learned using exemplar leave-one-out and subsampling. Experiments demonstrate the effectiveness of Exemplar VAEs on density estimation and representation learning. Importantly, generative data augmentation using Exemplar VAEs on permutation invariant MNIST and Fashion MNIST reduces classification error from 1.17% to 0.69% and from 8.56% to 8.16%.

Introduction

Generative modeling typically falls into two distinct paradigms: parametric and non-parametric. Parametric models, such as standard Variational Autoencoders (VAEs) or Generative Adversarial Networks (GANs), compress a dataset into a fixed set of neural network weights. While powerful, these models often struggle to capture the fine-grained diversity of large datasets and effectively "discard" the training data once training is complete.

Conversely, non-parametric (exemplar-based) methods, like Parzen window estimators, use the data directly to generate new samples. However, these methods struggle in high-dimensional spaces—such as raw pixels—because they lack a meaningful distance metric. Exemplar VAEs bridge this gap by using deep learning to learn a structured latent space (parametric) while utilizing actual training examples to define the distribution within that space (non-parametric).

The Exemplar VAE Framework

The core innovation of the Exemplar VAE is the replacement of the standard Gaussian prior with a Parzen window estimator in the latent space. In this setup, the prior is a Gaussian Mixture Model (GMM) where each component is centered on the latent code of a training exemplar.

Architecture of the Exemplar VAE, showing the non-parametric prior in the latent space.

Technical Contributions

  • Retrieval Augmented Training (RAT): Computing a prior over thousands of exemplars for every training step is computationally prohibitive. RAT utilizes approximate nearest neighbor (kNN) search in the latent space to identify only the most relevant exemplars. This provides a mathematically justified lower bound on the log-likelihood that significantly accelerates training.
  • Regularization Strategies: To prevent the model from simply memorizing the training set, the authors introduce Leave-One-Out (LOO) Training, ensuring a data point is never explained by itself, and Exemplar Subsampling, which explains a training point using only a random subset of the remaining exemplars.
  • Generative Data Augmentation: The model generates new variations of a specific image by encoding it, adding noise in the latent space (guided by the exemplar prior), and decoding it. This allows for controlled diversity that preserves the identity of the source image.

Representation Learning and Latent Structure

A key insight of this work is that the latent space is the ideal environment for Parzen windows. While they fail on raw pixels due to the "curse of dimensionality," they excel in the lower-dimensional, structured latent space learned by the VAE.

t-SNE visualization comparing latent space clustering of Exemplar VAE vs standard VAE on MNIST.

As shown in t-SNE visualizations, Exemplar VAEs produce much tighter and more semantically meaningful clusters than standard VAEs, even without using labels during training. Furthermore, the model exhibits a higher number of "active dimensions" in the latent space compared to baseline VAEs, suggesting it makes better use of its representational capacity and is less prone to posterior collapse.

Experimental Results

The model was evaluated on several standard benchmarks, including MNIST, Fashion MNIST, Omniglot, and CelebA.

  • Density Estimation: Exemplar VAEs consistently outperformed standard VAEs and the state-of-the-art "VampPrior" across MNIST, Fashion MNIST, and Omniglot.
  • Data Augmentation: Using the model to generate synthetic training data significantly boosted classifier performance. On permutation-invariant MNIST, classification error dropped from 1.17% to 0.69%. On Fashion MNIST, it dropped from 8.56% to 8.16%.
  • Controlled Diversity: Unlike standard VAEs that sample from a generic "blob" of noise, Exemplar VAEs allow for exemplar-guided generation—creating new images that preserve the identity of a source image while varying its style or attributes.

Discussion and Future Directions

While Exemplar VAEs offer significant advantages in representation and generation, they introduce some evaluation complexity. Evaluating the exact log-likelihood on a test set requires a pass over the entire training set of exemplars, though kNN retrieval can mitigate this.

Future work may explore learned or non-Euclidean metrics for kNN retrieval to further improve quality. Additionally, extending this framework to Natural Language Processing (NLP) and other discrete data types remains a promising avenue for research.

Summary updated

BibTeX
@misc{norouzi2020exemplar,
  author = {Sajad Norouzi and David J. Fleet and Mohammad Norouzi},
  title = {{Exemplar VAEs for Exemplar based Generation and Data Augmentation}},
  year = {2020},
  eprint = {2004.04795},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.04795},
}
Figure