Balanced Mini-batch Sampling for SGD Using Determinantal Point Processes

Cheng Zhang, Hedvig Kjellström, Stephan Mandt

Introduction

Stochastic Gradient Descent (SGD) is the backbone of modern machine learning, typically relying on uniform random sampling to construct mini-batches. However, this "blind" approach often fails when dealing with real-world datasets characterized by significant class imbalances. In such scenarios, majority classes dominate the training signal, effectively drowning out rare but critical examples. To address this, we present Diversified Mini-Batch SGD (DM-SGD), a novel framework that leverages Determinantal Point Processes (DPPs) to ensure each mini-batch is a diverse and representative subset of the data.

The Problem with Uniform Sampling

In standard SGD, every data point has an equal probability of being selected. While computationally efficient, this approach ignores the underlying geometry and distribution of the dataset. For instance, in a dataset containing millions of common images and only a few hundred rare ones, uniform sampling will rarely include the rare samples in a single batch. This leads to high gradient variance and poor performance on minority classes.

Comparison of random sampling vs. k-DPP sampling on an imbalanced dataset.

As illustrated above, random sampling tends to over-represent the majority class (blue circles), whereas $k$-DPP sampling actively selects a more diverse set that includes rare examples (red and green shapes).

Methodology: Diversified Mini-Batch SGD (DM-SGD)

The core of our approach is the use of $k$-Determinantal Point Processes ($k$-DPP) for mini-batch selection. A DPP is a probabilistic model designed to capture "repulsive" interactions between elements.

The DPP Mechanism

The probability of selecting a specific subset of data points is proportional to the determinant of a similarity matrix $L$. If two points are highly similar (redundant), the determinant of the submatrix containing them will be small, significantly reducing the likelihood of them appearing together in the same mini-batch. This mechanism enforces diversity without requiring explicit labels.

Similarity Kernels and Algorithm

Users define a similarity kernel based on the data type—such as deep feature embeddings for images or tf-idf vectors for text. DM-SGD then samples a $k$-sized subset from the DPP at each iteration. This method generalizes both standard SGD (when the kernel is identity) and stratified sampling (when the kernel reflects cluster membership).

Visual comparison of various sampling methods against the true population.

As shown in the comparison above, $k$-DPP sampling (e) provides a coverage of the data space that more closely aligns with the true population (a) compared to simple stratified sampling (c) or pre-clustering (d), especially in capturing the density variations across the dataset.

Key Insights

Soft Stratification

Unlike traditional stratified sampling, which requires pre-defined "strata" or hard clusters, DM-SGD uses a continuous similarity measure. This "soft stratification" allows for effective diversification in unsupervised or complex settings where discrete categories are not readily available.

Variance Reduction and Automatic Re-balancing

Theoretically, we prove that diverse mini-batches reduce the variance of the stochastic gradient. Because the samples within a batch are less correlated, their individual gradients provide a cleaner, more directed signal for optimization. Furthermore, the DPP naturally up-weights rare samples by suppressing redundant common ones, achieving automatic data re-balancing during the training process.

Experimental Results

We evaluated DM-SGD across several benchmarks:

  • R8 News Dataset: On this highly imbalanced text corpus, DM-SVI (the variational inference variant) achieved a classification accuracy of 94.7%. Notably, accuracy for the rare "grain" class improved from 70% to 90%.
  • Oxford 102 Flower Dataset: In fine-grained image classification with skewed test distributions, DM-SGD reached 86.7% accuracy, outperforming the standard SGD baseline of 84.7% while converging in fewer epochs.
  • Efficiency: Using fast $k$-DPP approximations, the sampling overhead was restricted to approximately 10% of the total update time, a negligible cost given the gains in convergence speed and final performance.

Conclusion and Future Work

DM-SGD offers a robust, mathematically grounded alternative to uniform sampling that excels in imbalanced and high-variance scenarios. While the method's success depends on the choice of an appropriate similarity kernel, it significantly improves model robustness and learning efficiency. Future research will focus on automated kernel learning and scaling these techniques to billion-scale datasets.

Summary updated

BibTeX
@inproceedings{zhang2017balanced,
  author = {Cheng Zhang and Hedvig Kjellström and Stephan Mandt},
  title = {{Balanced Mini-batch Sampling for SGD Using Determinantal Point Processes}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2017},
}
Figure