Exploiting autoencoder's weakness to generate pseudo anomalies

Marcella Astrid, Muhammad Zaigham Zaheer, Djamila Aouada, Seung-Ik Lee

Exploiting Autoencoder Generalization for Robust Pseudo-Anomaly Generation

Introduction

Anomaly detection is frequently framed as a One-Class Classification (OCC) problem, where models are trained exclusively on "normal" data due to the scarcity of anomalous examples. Autoencoders (AEs) are the standard tool for this task, operating on the principle that anomalies will yield higher reconstruction errors. However, a persistent challenge is the AE's tendency to generalize; it often reconstructs unseen anomalies with high fidelity, rendering them indistinguishable from normal data.

Previous solutions addressed this by introducing "strong inductive biases"—hard-coded assumptions about anomaly characteristics, such as frame-skipping to simulate high speed in video. While effective in specific contexts, these methods lack generality and fail when applied to static images or tabular network data.

Proposed Framework: Cooperative Pseudo-Anomaly Generation

The authors introduce a dual-network architecture comprising a main Autoencoder ($\mathcal{F}$) and a Noise Generator ($\mathcal{G}$). Instead of relying on heuristic noise, $\mathcal{G}$ is trained to identify the specific perturbations that most effectively exploit the AE's current reconstruction weaknesses.

The training process follows an alternating, cooperative cycle:

  1. Training the Generator ($\mathcal{G}$): $\mathcal{G}$ receives normal input $X^N$ and produces noise $\Delta X$. The objective is to create a pseudo anomaly $X^P = X^N + \Delta X$ that the current AE can still reconstruct with low error, while maximizing the magnitude of the noise.
  2. Training the Autoencoder ($\mathcal{F}$): $\mathcal{F}$ is trained on both real normal data and the generated pseudo anomalies. Crucially, when presented with $X^P$, the AE is tasked with reconstructing the original $X^N$ rather than the noisy input. This explicitly teaches the AE to "unlearn" its ability to reconstruct the specific noise generated by $\mathcal{G}$.
The alternating training cycle between the noise generator (G) and the autoencoder (F) to refine the reconstruction boundary.

Tightening the Reconstruction Boundary

This adversarial-like setup results in a "moving boundary." As training progresses, the AE becomes increasingly sensitive to deviations from the normal distribution. The generator must continuously find more subtle "reconstructible" noise, forcing the AE to refine its internal representation of normalcy. This process iteratively shrinks the AE's reconstruction boundary, making it highly sensitive to anything that isn't strictly normal.

Evolution of the reconstruction boundary (yellow) over training iterations, showing how it tightens around normal data (white) while excluding anomalies.

Experimental Results

The framework was evaluated across three distinct domains to demonstrate its versatility:

  • Video Surveillance: On the ShanghaiTech and UCSD Ped2 datasets, the method achieved state-of-the-art (SOTA) results (e.g., 94.57% AUC on Ped2), outperforming models that use complex external features like optical flow.
  • Image Classification: Using CIFAR-10 in a one-vs-rest configuration, the model reached an AUC of 67.76%, a significant improvement over the 60.10% baseline AE.
  • Network Security: On the KDDCUP99 dataset, the method achieved an F1-score of 95.58%, proving its efficacy on non-visual, tabular data.

Conclusion

By treating the autoencoder's generalization capability as a vulnerability to be exploited during training, this method provides a robust, domain-agnostic approach to anomaly detection. It eliminates the need for hand-crafted inductive biases, allowing the data itself to define the boundaries of normalcy through a learned, iterative process.

Summary updated

BibTeX
@article{astrid2024exploiting,
  author = {Marcella Astrid and Muhammad Zaigham Zaheer and Djamila Aouada and Seung-Ik Lee},
  title = {{Exploiting autoencoder's weakness to generate pseudo anomalies}},
  journal = {Neural Computing and Applications},
  year = {2024},
  doi = {10.1007/s00521-024-09790-z},
}
Figure