One-element Batch Training by Moving Window

Przemyslaw Spurek, Szymon Knop, Jacek Tabor, Igor T. Podolak, Bartosz WójcikarXiv 2019

TL;DR

This paper introduces a "Moving Window" (MoW) optimization technique that enables training generative models with extremely small, even single-element, mini-batches. This is achieved by leveraging historical latent representations, significantly reducing memory requirements and allowing for training on higher-resolution images than previously feasible.

What Problem Does This Paper Address?

Many modern generative deep learning models, such as Wasserstein Autoencoders (WAE) and Generative Adversarial Networks (GANs), rely on comparing samples from different distributions within their cost functions. This comparison is crucial for tasks like matching latent space distributions to a prior or measuring the distance between generated and real data. However, this comparison inherently requires multiple samples within a batch, making it difficult or impossible to train these models directly with very small mini-batches (e.g., single elements). This limitation poses a significant challenge when dealing with high-resolution data, which demands substantial GPU memory, often preventing the use of larger batch sizes.

Methods

The core innovation is the "Moving Window" (MoW) optimization procedure. Instead of processing a batch of n samples all at once, MoW maintains a buffer of historical latent representations. In each training step, a new mini-batch of k elements is introduced, while n-k elements from the previous step's historical buffer are retained. The cost function is then computed using the current k elements for reconstruction and the combined n elements (current k and historical n-k) for latent space distribution matching. Crucially, gradients for the historical n-k elements are frozen, meaning only the current k elements contribute to updating the model's weights for the reconstruction part. This approach effectively amortizes the cost of comparing latent distributions over time, allowing for training with k=1 (a single element). The paper also proposes an optimizer called MoW that implements this strategy.

Datasets

The paper uses the following datasets for training and evaluation:

  • CELEB A: A dataset of celebrity faces.
  • CIFAR-10: A dataset of 10 classes of images.
  • MNIST: A dataset of handwritten digits.
  • Fashion MNIST: A dataset of clothing items.
  • Flickr-Faces-HQ (FFHQ): A dataset of high-quality images (1024x1024 resolution) used to demonstrate training on very high-resolution data.

Key Insights and Ideas

  • Memory Efficiency through History: The key insight is that by retaining historical latent representations, the model can "remember" past samples' contributions to the distribution matching objective without needing to reprocess them in every single step. This dramatically reduces the memory footprint.
  • Bridging the Gap to Single-Element Batches: The MoW method provides a principled way to adapt models that require batch comparisons to work with single-element batches, overcoming a fundamental limitation.
  • Enabling High-Resolution Training: The significant memory savings directly translate to the ability to train models on much higher resolution images than previously possible with standard batching techniques.
  • No Architectural Changes Needed: The MoW approach is an optimization strategy and does not require modifications to the underlying generative model architectures (like WAE, CWAE, SWAE).

Key Results

  • The paper demonstrates that MoW can successfully train generative models (WAE, WAE-MMD, CWAE, SWAE) using single-element mini-batches (k=1).
  • Qualitative results on CELEB A show no perceptual differences between MoW (k=1) and classical batch training (n=k=64) for interpolation and reconstruction tasks.
  • Quantitative comparisons (Table 1, 2, 3, 4) show that MoW with k=1 or k=32 often achieves comparable or even slightly better results in terms of reconstruction error, WAE distance, and FID scores compared to classical batch training, despite using significantly less memory.
  • Crucially, the method successfully trains on high-resolution FFHQ images (1024x1024), a task that would be prohibitive with standard batching due to memory constraints.

Limitations and Future Work

  • Approximation of Gradients: The MoW method relies on the assumption that gradients for historical elements can be frozen. While the paper shows this works well in practice, it is an approximation. The paper notes that "since @ does not, almost, change during the optimization process for the time in the interval [t, t+h], Egxj ≈ zj".
  • Learning Rate Sensitivity: The paper mentions using grid search for learning rates and that results can be sensitive to this parameter, especially for k=1.
  • Future Work: The paper suggests that the MoW optimizer could be applied to other models that require batch comparisons, and further exploration of its applicability to various architectures and datasets is implied. The ability to train on high-resolution images directly, without progressive growing strategies, is highlighted as a significant advantage for future work.

Summary updated

BibTeX
@misc{spurek2019one,
  author = {Przemyslaw Spurek and Szymon Knop and Jacek Tabor and Igor T. Podolak and Bartosz Wójcik},
  title = {{One-element Batch Training by Moving Window}},
  year = {2019},
  eprint = {1905.12947},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1905.12947},
}
Figure