Assignment 05 (Due date: Apr. 07, 2024)
Neural Networks
Assignment 05
Due: Apr. 7, 2024
The purpose of this assignment is to train a Deep Convolutional Generative Adversarial Network (DCGAN) on MNIST.
To begin this assignment download the  Kamangar_05.zip and unzip it to your computer.
Implementation Details
  • Much of the code is already written for you, you must modify the following functions:
    • build_discriminator - This function should build the discriminator as described and return it.
    • build_generator - This function should build the generator as described and return it.
    • train_step in the DCGAN class - This is where you must implement the training logic for GANs. By implementing it in a subclass of keras’s Model class, GANs can be trained using keras’s model.fit() api.
  • The code to load the data and run training is already implemented in train_dcgan_mnist()
    • This function is not part of the grading. This is for you to play with to learn about DCGANs.
    • This will take a long time to train for 50 epochs on the full mnist dataset (maybe an hour or two).
    • Since this is not graded, you can modify the number of samples you train on, or the batch size, to make training quicker (Note: If you reduce the size of the dataset, you may need to increase the number of epochs to get comparable results)
  • A helper function called plot_images is provided that will arrange images into a row/grid
  • A class called GenerateSamplesCallback is provided, that will generate images using your generator after every epoch, using the same input values
    • If you run the train_dcgan_mnist code, you should look in the generated_images subdirectory for examples of generated images.
 
After one epoch of training on the full dataset, you should expect to see this (generated_images_0.png):    graphic  
After ten epochs of training on the full dataset, you should expect to see this (generated_images_9.png):   graphic   
 
Notes:
  • Assignment_05_tests.py file includes 3 tests:
    • test_generator - This tests your generator architecture.
    • test_discriminator - This tests your discriminator architecture.
    • test_dcgan_train_step - This tests the GAN training logic.
  • The files test_dcgan_train_step.npz and test_generator.npz are serialized numpy arrays. They contain some values for testing that were a bit too large to put directly in the file. They can be loaded using np.load() and then function essentially as dictionaries.
  • For brevity, we do not test every single parameter of the architecture. You must follow all instructions in the comments/docstrings, or you will likely fail some tests.
  • Your assignment must pass these tests when the following command is used:
    • py.test --verbose Assignment_05_tests.py
  • DO NOT submit the "Assignment_05_tests.py" file when submitting your Assignment_05
  • You are responsible for understanding this code and may be quizzed on it later.
  
Grading Criteria
  • Passing Unit Tests - 90 points
  • Qualitative Evaluation: 10 points (Grader may examine your code and subjectively award as many as 10 points.)
Submission Guidelines
  • The first four lines of any submitted file must follow the following format according to the assignment submission guidelines.
# Your name (last-name, first-name)
# Your student ID (100x_xxx_xxx)
# Date of submission (yyyy_mm_dd)
# Assignment_nn_kk
 
  • Create a directory and name it according to the submission guidelines and include your files in that directory.
  • Zip the directory and upload it  to Canvas according to the submission guidelines.