Informations

Auteur(s) Pierre Dupont, Benoit Ronval
Date limite 12/04/2026 23:00:00
Limite de soumission Pas de limite

Se connecter

A4.4 - Deep Learning: GANs

In the previous tasks of the project, you have learned how to build and train neural networks to classify images. In this question, you will explore a different type of neural network architecture, called Generative Adversarial Networks (GANs), that can be used to generate images (often called deep fakes).

GANs are composed of two neural networks, a generator and a discriminator, that are trained together in an adversarial way. The generator takes as input a random noise vector and generates an image, while the discriminator takes as input an image classifies it as real (from the training set) or fake (generated by the generator). The generator is trained to fool the discriminator, while the discriminator is trained to correctly classify real and fake images.

https://inginious.info.ucl.ac.be/course/LINFO2262/A4-4/gan.png
Disclaimer

GAN (Generative Adversarial Network) methodology has previously been used to produce deepfakes capable of deceiving people. By studying GANs in this project, we do not endorse or encourage such deceptive applications. On the contrary, training a robust discriminator represents one promising avenue for automating the detection of fake images — illustrating how the min-max framework at the heart of GAN learning reflects an ongoing race between generation and detection.

Students should be fully aware of this broader context and are under no circumstances encouraged to misuse these techniques. Any such misuse would be their sole responsibility and may carry serious legal consequences.

You can load the data with the following code snippet. Note that, for this task, you will only need the training images, and not the labels. You may also load the test images to assess the quality of your discriminator.

x_train = np.load("p4_2026_svhn_train.npz")["images"].transpose(3, 0, 1, 2)
x_test = np.load("p4_2026_svhn_test.npz")["images"].transpose(3, 0, 1, 2)

Question 1: A Generative Adversarial Network template

Graded question with feedback [20 points]

We provide you with a template for a GAN architecture, that you can use as a starting point to implement your own GAN. This template is not complete, and you will need to fill the missing parts where the TODO comments are located. Do not change the other parts of the provided code.

Complete this template with your code, following the instructions in the comments. Train your generator and discriminator on the training set, and make sure both models are good, i.e., the generator can generate images that look like the ones in the training set, and the discriminator can distinguish real images from fake images.

Submit your code here by replacing the template with your own implementation. Note that x_train will be loaded on Inginious when evaluating your code but you cannot access it or modify it here.

Question 2: Upload your generator model

Test question [40 points]

Upload here your trained generator model.

Your generator will be evaluated on how well it can generate images that fool a discriminator we designed. This question will be evaluated after the deadline. Therefore, it is your job to make sure that your generator is trained correctly and generate images that look like the ones in the training set.

You will receive grade proportional to how well your generator can fool our discriminator.


Taille fichier max. : 238.4 MiB
Extensions autorisées : .keras
Question 3: Upload your discriminator model

Test question [40 points]

Upload here your trained discriminator model.

Your discriminator will be evaluated on how well it can distinguish real images from fake images generated by our generator. This question will be evaluated after the deadline. Therefore, it is your job to make sure that your discriminator is trained correctly and can distinguish real images from fake images.

You will receive grade proportional to how well your discriminator can distinguish real images from fake images.


Taille fichier max. : 238.4 MiB
Extensions autorisées : .keras