Reference no: EM132298902
Assignment -
Introduction - In this assignment, you will develop classification models to classify noisy input images into two classes: square or circle. Examples are shown in Fig. 1. (attached)
Assignment - Your task is to write Python code which will train and validate the following two classification models:
1) K-Nearest neighbour (KNN) classifier.
For the KNN classifier, you can only use standard Python libraries (e.g., numpy) in order to implement all aspects of the training and testing algorithms.
Using matplotlib, plot a graph of the evolution of classification accuracy for the training and testing sets as a function of K, where K = 1 to 10.
Clearly identify the value of K for which generalisation is best.
2) Convolutional neural network (CNN) classifier.
For the convolutional neural network, you should use Tensorflow within Jupyter Notebook by modifying the Multilayer Perceptron program supplied with this assignment. Instructions for installation of Python 3.7, Jupyter and TensorFlow (via a package called miniconda) are in a separate sheet supplied with this assignment.
You should modify the code so that it implements the LeNet CNN structure to that was presented in lectures. In particular, the LeNet architecture should comprise two convolutional layers (5x5 convolutions), and two hidden full- connected (dense) layers in addition to the output layer. After each convolutional layer the architecture should use max pooling to reduce the size by a factor of 2 in each axis. After each pooling operation you should use a RELU (Rectified Linear Unit) activation function. The LeNet will also have three dense layers forming a Multilayer Perceptron (MLP) classifier (you can use the ones already in the sample implementation. The size of the two hidden-layers in the MLP must be 2x and x (where you will need to test different values of x by changing the code or writing a suitable function). Of course the output layer will have a single neuron.
Using matplotlib, plot a graph of the evolution of accuracy for the training and testing sets as a function of the number of epochs, for each of the CNNs you train (up to a maximum of 200 epochs).
Sample python code that trains and tests a multi-layer perceptron classifier (and can run in a Jupyter Notebook session) is provided with the assignment specification. You should modify this code to produce your own program.
Attachment:- Assignment Files.rar