RareGAN: Generating Samples for Rare Classes

Zinan Lin, Hao Liang, Giulia Fanti, Vyas Sekar

Abstract

Generative Adversarial Networks (GANs) have demonstrated remarkable success in data synthesis, yet they frequently struggle with the "needle in the haystack" problem: generating high-fidelity samples from rare classes within a dataset. This challenge is compounded when labeling data is expensive or requires complex black-box evaluations. RareGAN is a novel generative framework designed to synthesize samples from rare, unlabeled data classes under a strict labeling budget. By integrating active learning with a specialized weighted loss function and a semi-supervised architecture, RareGAN significantly outperforms both standard GANs and domain-specific tools in generating diverse, high-fidelity samples for critical applications such as cybersecurity and system stress testing.

Introduction

In many real-world scenarios—ranging from identifying network packets that trigger Distributed Denial of Service (DDoS) attacks to finding specific workloads that cause server failures—the data of interest makes up a tiny fraction of the total available dataset. Standard GANs typically prioritize the "common" class to minimize global error, often leading to mode collapse or the complete omission of the rare class.

Existing approaches to this problem face two primary hurdles. First, the high cost of labeling: determining if a sample belongs to a rare class often requires expensive evaluations. Second, the inherent class imbalance makes it difficult for a generator to learn the underlying distribution of the minority class. RareGAN addresses these challenges by learning the distribution of a rare class given a large unlabeled dataset and a very limited budget for requesting labels.

Methodology

RareGAN builds upon the Auxiliary Classifier GAN (ACGAN) architecture, introducing three key innovations to handle rarity and labeling constraints:

1. Semi-Supervised Learning

Unlike traditional models that rely solely on labeled data, RareGAN leverages all available unlabeled data. This allows the GAN to learn the overall structure and manifold of the data distribution. The limited labeled samples are used specifically to train an internal classifier that distinguishes between the rare and common classes, providing a guide for the generator.

2. Active Learning via Least Confidence Sampling

To maximize the utility of a limited labeling budget, RareGAN employs an active learning strategy. Instead of selecting samples for labeling at random, the model identifies samples where the internal classifier is "least confident" about the label. These "boundary" samples are the most informative for refining the model's understanding of the transition between common and rare classes. This approach allows RareGAN to map difficult class boundaries much more efficiently than random sampling.

3. Weighted Loss Function

The authors introduce a multiplicative weight ($w$) into the GAN's loss function. This mathematical adjustment forces the generator to prioritize the fidelity of the rare class over the common class. By increasing the penalty for errors on rare samples, the model is prevented from "forgetting" the minority class in favor of the majority distribution, ensuring stable training even under extreme imbalance.

Experimental Evaluation

The researchers evaluated RareGAN across three distinct domains to demonstrate its versatility and robustness:

  • DNS Amplification Attacks: A security-focused task where the goal is to generate DNS requests that trigger massive responses. RareGAN achieved a fidelity score of 4.16 and 98.07% diversity with a budget of only 200,000 queries. In contrast, the domain-specific state-of-the-art tool, AmpMAP, required over 14 million queries and achieved only 1.68% diversity.
  • Packet Classification: A networking dataset focused on generating packets that result in high processing latency, testing the model's ability to identify performance bottlenecks.
  • Image Benchmarks (MNIST & CIFAR-10): By artificially creating rare classes (e.g., treating a specific digit as a 1% rare class), the authors visualized performance and measured diversity against standard computer vision baselines.

Key Insights

A central finding of the research is the power of "hard" samples. While some generative models focus on labeling high-certainty samples to ensure quality, RareGAN’s focus on least-certainty samples allows it to define the boundaries of the rare class more effectively. Furthermore, the use of unlabeled data acts as a regularizer, providing essential context that prevents the GAN from overfitting to the few rare samples it has encountered.

From a theoretical perspective, the authors provide proof (Proposition 1) that their active learning implementation does not bias the final learned distribution of the rare class, despite using a biased selection of samples for the classifier. This ensures that the generated samples remain representative of the true rare class distribution.

Results and Performance

RareGAN demonstrated a superior fidelity-diversity tradeoff across all benchmarks. It remained stable even when the rare class constituted as little as 0.2% of the total data. While baselines like ACGAN and BAGAN often suffered from mode collapse or produced samples from the wrong class entirely under these conditions, RareGAN maintained high diversity and lower variance across experimental runs.

Limitations and Future Work

Despite its success, RareGAN operates under the "disjoint support" assumption, meaning it assumes rare and common classes do not perfectly overlap in feature space. If classes are heavily overlapped, the active learning strategy may struggle to find a clear boundary. Additionally, the weight $w$ and the number of active learning stages $S$ are hyperparameters that currently require manual tuning. Future research may focus on automating these parameters and addressing extremely complex, non-smooth boundaries in high-dimensional spaces.

Summary updated

BibTeX
@inproceedings{lin2022raregan,
  author = {Zinan Lin and Hao Liang and Giulia Fanti and Vyas Sekar},
  title = {{RareGAN: Generating Samples for Rare Classes}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i7.20715},
}
Figure