liveBook · Manning

Generative adversarial network

As explained in Outlier Detection in Python

A generative adversarial network is a model consisting of a generator and discriminator trained competitively so the generator produces data resembling a reference distribution.

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

How Outlier Detection in Python covers it

How deep it goes
Explains joint training, latent input, and discriminator and BiGAN scoring, without detailing loss functions.
Examples
Shows generator–discriminator diagrams, BiGAN prediction paths, and a PyOD ALAD fit-and-score listing.
What it assumes
Introduces generator and discriminator roles from their inputs and tasks; requires a supported deep-learning backend for PyOD use.
What you can do after
Apply it via PyOD’s ALAD detector to fit data, inspect decision_scores_, and plot learning curves.
How it connects
Connects GANs to variational autoencoders, autoencoders, Real versus Fake detectors, and BiGANs.

Also explained in

Compare how 12 books explain generative adversarial network →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.