Adversarial autoencoder — TensorFlow 2

Repo

A TensorFlow 2 implementation of Adversarial Autoencoder (ICLR 2016).

Model

Regularisation of the hidden code by incorporating full label information. The encoder learns a latent code that the discriminator pushes toward a chosen prior conditioned on the class label.

Fig. 3 from Alireza Makhzani, Jonathon Shlens, Navdeep Jaitly, Ian J. Goodfellow. Adversarial Autoencoders. CoRR abs/1511.05644 (2015).

Adversarial autoencoder architecture, Fig. 3 from the paper

Results for the gaussian_mixture prior

Latent space

Target prior distribution
Target prior distribution
Learnt latent space
Learnt latent space
Sampled decoder output
Sampled decoder output

Reconstruction

Input images
Input images
Reconstructed images
Reconstructed images

Training loss

GAN loss
GAN
Encoder loss
Encoder
Discriminator loss
Discriminator

Example of usage

python train_model.py --prior_type gaussian_mixture

Attributes

Visualisation of outliers

The encoder learns to map inputs into the latent space. By projecting those learnt representations with PCA, samples that fall outside the target Gaussian-mixture distribution can be surfaced as outliers — even when their reconstruction loss looks acceptable.

Outliers in the learnt latent distribution
Outliers from the learnt distribution in the latent space.

Detecting outliers in the latent space with PCA

PCA step 1
PCA step 2
PCA step 3
PCA step 4