Memory-Augmented Generative Adversarial Networks for Anomaly Detection

Iman Soltani, Ziyi Yang, Teng Zhang, Iman Soltani Bozchalooi, Eric DarveIEEE TNNLS 2020 · DOI

Introduction

Anomaly detection involves identifying rare, abnormal events within a dataset predominantly composed of "normal" samples. While deep generative models like Generative Adversarial Networks (GANs) and Autoencoders are frequently employed to learn normal data distributions, they often lack theoretical guarantees for anomaly rejection. A common failure mode occurs when a powerful generator inadvertently reconstructs anomalous data too well, leading to false negatives.

The Memory Augmented Generative Adversarial Network (MEMGAN) addresses this by introducing a bidirectional GAN framework integrated with a trainable external memory module. By structuring the latent space such that normal data is confined within a convex polytope defined by memory units, MEMGAN provides a geometric boundary that naturally excludes anomalies.

Methodology

MEMGAN extends the Adversarially Learned Inference (ALI) framework. The core innovation is the Memory-Augmented Latent Sampling strategy. Instead of sampling from a standard Gaussian distribution, latent variables are represented as convex combinations of memory units $M$.

The training objective incorporates several key loss functions:

  1. Memory Projection Loss ($l_{proj}$): Ensures that the encoder maps normal data points close to the subspace spanned by the memory units.
  2. Mutual Information Loss ($l_{mi}$): Encourages memory units to capture distinct, non-redundant features, preventing the "blurry" representations seen in previous memory-based models.
  3. Cycle Consistency: Guarantees that an image can be reconstructed accurately after being encoded and projected onto the memory space.

During inference, an anomaly score is derived from the reconstruction error. Since anomalies do not "fit" within the convex hull of the memory units, they yield significantly higher errors, facilitating robust detection.

Experimental Results

The authors evaluated MEMGAN on MNIST and CIFAR-10 benchmarks, treating individual classes as "normal" and others as "anomalous."

Quantitative Performance

On the MNIST dataset, MEMGAN achieved an average AUROC of 96.5%, outperforming the previous state-of-the-art MEMAE (95.2%). On the more complex CIFAR-10 dataset, MEMGAN tied for the best average performance at 64.8%, demonstrating superior stability compared to other GAN-based methods like ADGAN and ALAD.

Qualitative Analysis

Visualizations using t-SNE confirm the model's ability to isolate anomalies. As shown in the latent space projections, memory units (red) effectively form a boundary around the normal data cluster (orange), while anomalous points (blue) are pushed to the periphery.

t-SNE visualization showing the separation of normal data (orange), abnormal data (blue), and memory units (red).

Discussion and Interpretability

A significant advantage of MEMGAN is its interpretability. Unlike black-box memory modules, passing individual memory units through the generator produces clear "prototypes" of the normal class. This allows researchers to visualize exactly what the model considers to be the representative features of the training data. For example, in digit classification, memory units capture distinct handwriting styles.

Decoded memory units showing distinct prototypes for different digits, compared to the blurry outputs of previous methods.

The theoretical foundation of the "Convex Polytope Guarantee" ensures that memory units act as vertices of a geometric "safety zone." However, the model inherits the typical challenges of GAN training, such as sensitivity to hyperparameter balancing. Future work may explore the application of these geometric properties to high-dimensional, multi-modal distributions where the normal data might not form a single contiguous cluster.

Summary updated

BibTeX
@article{soltani2020memory,
  author = {Iman Soltani and Ziyi Yang and Teng Zhang and Iman Soltani Bozchalooi and Eric Darve},
  title = {{Memory-Augmented Generative Adversarial Networks for Anomaly Detection}},
  journal = {IEEE TNNLS},
  year = {2020},
  doi = {10.1109/tnnls.2021.3132928},
}
Figure