Assignment 3– CNN and Keras Solution

$30.00 $26.40


Assignment overview. This assignment can be submitted with a partner or individually. The assignment is designed so you can experiment with convolutional networks and Keras. To run the program in a reasonable time it is recommended to use a GPU. If you don’t have access to a GPU then you might want to try the Google cloud service mentioned below. Please let me know if this provides difficulties.

Submission. Please submit your program and answers as Jupyder notebook on Brightspace as A3. All programs have to be included in the submission.

Submission deadline. Wednesday, October 17 at 11:00 am.

Late submission can not be accepted and no extension will be granted for this assignment!

Academic Integrity. Dalhousie academic integrity policy applies to all submissions in this course. You are expected to submit your own work. Please refer to and understand the academic integrity policy, available at

If you have a question: Teaching Assistants (TAs) will be present during the labs to help you with any questions you may have. If you still have questions, feel free to email me at


In this assignment your task is to use the VGG16 model that is trained on ImageNet to create a model for the MNIST data. In the Keras documentation under you find an example how to “Fine-tune InceptionV3 on a new set of classes”. You can follow this example by replacing InceptionV3 with VGG16.

The MNIST data are smaller than the required input for VGG16. You should therefore enlarge the images by interpolation which can be done with the scipy function ndimage.zoom().

You can run this model on a GPU by using a free Google service. See instructions on the next page.

Report the following tests. Run a basic MLP and CNN from the class examples on only 1024 training examples and plot the training and test accuracy. Then retrain only the dense layers of the new VGG16 network with the 1014 training images and also report the learning curves. Finally, try to retrain some more layers. Note, if you try to train all layers the kernel might die, which might be due to memory problems. Please just report briefly your experience.

If you like you can experiment with training on more pattern, but this submission is not required for the assignment.

Using Google GPU service

  1. Open google drive if you have already had a google gmail account.
  2. Select New->more->connect more apps, type “colaboratory”, and connect it. (If you cannot find the colaboratory in more)
  3. Again Select New->more-> colaboratory, then notebook comes up.
  4. Rename the file name “Untitledx.ipynb” to whatever you want.
  5. Edit > Notebook settings or Runtime>Change runtime type, and you can select python version and select GPU as Hardware accelerator.
  6. Run these codes first in order to install the necessary libraries and perform authorization.
        from google.colab import drive
  7. When you run the code above, you should see an link, and click the link, copy verification code and paste it to text box.
  8. To install Keras, type
       !pip install -q keras