Skip to content

Visualize the internal activations of a DCGAN when generating and discriminating MNIST images.

License

Notifications You must be signed in to change notification settings

Dan-Andrei-Iliescu/visualizing-GAN-layers

Repository files navigation

visualizing-GAN-layers

Generative Adversarial Networks are state-of-the-art deep models that learn to produce realistic synthtic images as a byproduct of an adversarial game between two competing learning agents, called a generator and a discriminator.

In order to understand more about how GANs learn to represent class information internally, we need a way to visualize the activations of the layers inside the network. I have assembled a dimensionality reduction algorithm which combines PCA and t-SNE in order to represent the multi-dimensional activations in a humanly understandable 2-dimensional space.

The process is to first train a GAN and a classifier on the MNIST dataset, and then generate new images while recording the activations inside the GAN. We predict the labels of the generated images, and then use them to color the activations of the intermediate layers when plotting them. This allows interesting observations to be made about the appearance and propagation of class information inside of the GAN.

This repository is a section of the work completed in partial fulfilment of the requirements for the degree of BSc (Hons) in Computer Science at the University of Manchester. The dissertation details the conclusions of the research Andrei_Iliescu_Report.pdf.

Overview

Dependencies

The model has been run with GPU-accelerated TensorFlow using the following packages:

Installation and running

  1. Make sure all dependencies are installed.

  2. Clone the repository.

  3. First, train the GAN model (skip this step if you want to use the pre-trained model).

python3 train_gan.py
  1. Then, train the classifier model (skip this step if you want to use the pre-trained model).
python3 train_classifier.py
  1. Finally, produce visualizations of the internal GAN layers.
python3 visualize_gan.py

Generated images

GAN-generated MNIST over 1, 20 and 40 epochs.

epoch_1 epoch_3 epoch_5

Visualizations

Visualization of the 3rd discriminator layer on real images.

dr3

Visualization of the 3rd generator layer.

g3

Visualization of the 3rd discriminator layer on generated images.

g3

License

Everything is licensed under the MIT license.

References

[1] Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y. Generative Adversarial Networks. In Advances in neural information processing systems, pp. 2672–2680, 2014a.

[2] van der Maaten, L., Hinton, G. Visualizing Data using t-SNE. Journal of Machine Learning Research 9 (2008) 2579-2605.Aniruddha Ghosh and Tony Veale. 2016.

[3] Radford, A., Metz, L., Chintala, S. Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks. ICLR 2016.

About

Visualize the internal activations of a DCGAN when generating and discriminating MNIST images.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages