CNN Assignment - Milestone 1
Overview
The purpose of this assignment is to learn about the inner workings
of CNNs. You are asked to implement a pioneering CNN, LeNet5, which is
a CNN for MNIST digit recognition.
Assignment
This assignment is worth 80 points. Please work on it by yourself.
- Create new Java files/classes entitled "LeNet5.java" and
"MNISTCNN.java" They will be used to implement the LeNet5 CNN and the
set-up and testing of LeNet5 on the MNIST data set.
- Since you already working with the MNIST data set, importing it
into your project, reading the files and displaying the images should
be reused from your FFnet project. Notice that you need to modifiy the
drawImage() procedure to accept a 2D array. Do all of this in
your "MNISTCNN.java" file.
- In the "LeNet5.java" file, for this milestone, implement the
forward pass as documented in section II.B of the GradientBased
Learning Applied to Document Recognition paper by Yann LeCun, Leon
Bottou, Yoshua Bengio and Patrick Haner.
- Set-up the weight matrices as we worked out in class through the
LeNet5
architecture worksheet.
- Ensure that in the prior part, you do not use magic
numbers. Define constants that you will use to declare the arrays and
that you will use later on in the code.
- Initialize the weights as specified on page 41 of the paper.
- Next, implement the padding (unless you send LeNet5 already padded
inputs).
- Implement C1, the first layer, ensuring you use the tanh
activation function as specified on page 8 [formuli (5) and (6)] as
well as Appendix A.
- Please ensure you use structured programming principles. You
should have procedures for initializing the weights, for the
convolutional layers, for the pooling layers and for the classifier as
necessary.
- Implement S2, using the expression as specified on page 7, rather
than MaxP from the worksheet.
- Implement C3, using the connectivity as specified in table I.
- Implement S4. This should be the same process as used for S2.
- Implement C5. Be mindful of the full connectivity and how it is
set up.
- Implement F6.
- Implement the Output layer. Please use the expression as specified
on page 8 in formula (7).
- Test your network. To test it please do the following:
- Comment out the initializations of the weights and instead set all
of them to zero, including the bias weights. Then set the center of
the filter to 1.0. For the C6, F6 and Ouput layers, set the weights to 1.0.
- Deactivate the activation functions for all layers, except for S2
and S4. Simply use the weighted sum of the inputs as activation.
- Duplicate the "displayImage" and "drawPixel" methods and change
the method signatures so that they accept an array. Modify the methods
so that they can be used to display the single layers of the
classifier. Please limit the image width to 40.
- Display the following images, ensuring they are properly
labeled. (Simply pass in the layer name when creating a new JFrame.)
Input, C1, S2, C3, S4, C5, F6, Output. Please only display the images
of the first of the feature maps and the first of the pooling layer
map at each level.
Submission
Please submit "LeNet5.java" and "MNISTCNN.java" files as well as the
lab manual to the appropriate
drop-box on Moodle.