Starting from:
$35

$29

Homework 2: Convolutional Neural Network Solution

*GPUs may be needed for speeding up the neural network training process in this homework.

Description

In this homework you will practice how to write a Convolutional Neural Network (CNN) classifier in Python with the Pytorch framework. You need to understand how a CNN works, including backpropagation and gradient descent in order to implement this homework successfully. The goal of this homework is:

    • To implement and understand the CNN architecture.

Instruction

    • The dataset used in this homework is CIFAR-10. You may need these packages: Pytorch, TensorFlow, NumPy, and OpenCV (for reading images). The commonly used classifiers are Softmax and SVM.

    • Requirements:

        1. Contain a training function that will be called to train a model with the command “python CNNclassify.py train”.

            2. Save the model in a folder named “model” after finishing the training process.

            3. Show the testing accuracy in each iteration of the training function. The test accuracy should be greater than or equal to 75% in the end using the CIFAR-10 dataset.

                1) You can add as many layers as you want for both CONV layers and FC layers. Optimization techniques such as mini-batch, batch normalization, dropout and regularization might be used.

                2) In the first CONV layer, the filter size should be 5*5, the stride should be 1, and the total number of filters should be 32. All other filter sizes, strides and filter numbers are not acceptable and may result in a final grade of 0 in this HW.

                3) For other CONV layers (if any), there is no limitation for the size of filters and strides.












Fig. 1 The screenshot of the training result.
EECE 7398 HW 2

Fall 2021    ST: Advances in Deep Learning    Due 11/05/2021

        4) You can choose as many CONV layers as you want, however, please be aware that the computational cost of CONV layer is very high and the training process may take quite long.


        5) You can also choose as many FC layers as you want in order to enhance the model accuracy. There is no limitation for the size of FC layers.

    4. Implement a testing function that accepts the command “python CNNclassify.py test xxx.png” to test your model by loading it from the folder “model” created in the training step. The function should (1) read “xxx.png” and predict the output as shown in Fig. 2, and (2) visualize the output of the first CONV layer in the trained model for each filter (i.e., 32 visualization results), and save the visualization results as “CONV_rslt.png” as shown in Fig. 3. The testing result would match the true image type when the classifier achieves high accuracy.






Fig. 2 The screenshot of the testing result.




















Fig. 3 The screenshot of the first CONV layer visualization (car shape).

Submission

    • You need to submit a zip file including:

        1. a python file named “CNNclassify.py”;

        2. a generated model folder named “model”;

        3. two screenshots of training and testing results;

        4. one screenshot of the visualization results from the first CONV layer.

    • The “CNNclassify.py” file should be able to run with the following commands:

            1. python CNNclassify.py train

to train your neural network classifier and generate a model in the model folder;

            2. python CNNclassify.py test xxx.png
EECE 7398 HW 2

Fall 2021    ST: Advances in Deep Learning    Due 11/05/2021

to (1) predict the class of an image and display the prediction result; (2) save the visualization results from the first CONV layer as “CONV_rslt.png”.

    • The zip file should be named using the following convention: <Last-Name>_<First-Name>_HW2.zip

Ex: Potter_Harry_HW2.zip

    • Note:

Do not put any print function other than showing the results.

Comment your code.

Grading criteria

    • Your model will be tested by running “python CNNclassify.py test xxx.png” with additional testing images to verify (1) the test function and (2) the visualization function. Please make sure your functions work correctly.

    • The testing accuracy should be greater than or equal to 75% in the end. There will be 1-point deduction for every 1% of accuracy degradation based on 75%.
    • Upload the zip file to Canvas before 11:59PM (EST Time) 11/05/2021.

More products