A generative adversarial network (GAN) pairs two neural networks. A generator turns random noise, or a latent vector z, into synthetic data G(z) resembling training data X. A discriminator learns to distinguish G(z) from X. As they train together, the generator makes increasingly realistic data while the discriminator learns to detect subtler differences. section 16.2.3
Figure 16.4 GAN network. This includes two neural networks: the generator (G) and discriminator (D). The generator learns to take random input (z) and convert this to synthetic data (G(z)) that is very similar to real data (X). The discriminator learns to distinguish synthetic data generated by G from the real data. They are trained together such that over time both become more powerful, with the generator being able to produce increasingly realistic data and the discriminator being able to detect increasingly subtle deviations from real data. Once trained, both the generator and discriminator may be used for outlier detection.
The diagram traces noise through the generator and shows how the discriminator compares generated and real data. section 16.2.3
For outlier detection, one approach passes observations through the discriminator to assess how unlike its training data they appear. A BiGAN adds an encoder that maps real data toward the generator’s input space; at prediction time, it can use both reconstruction error and discriminator estimates. GANs can generate very realistic data, but balancing the training of two networks makes them harder to train than variational autoencoders. section 16.2.3
Fit a GAN-based detector
PyOD’s ALAD example fits a detector to X, reads its decision_scores_, and plots learning curves. PyOD deep-learning detectors require TensorFlow/Keras or PyTorch. This is a scoring workflow, not a reason to treat every high-scoring observation as a confirmed anomaly. section 16.2.3 section 16.2
GANs are one option alongside autoencoders and variational autoencoders for deep-learning outlier detection, including with images. For tabular data, such methods are often slower and harder to tune than established detectors without being more accurate; they may still add diversity to an ensemble or help when many records and complex feature relationships are available. section 16.0 section 16.6











