Question: Please create a working Python code for this problem and follow all other instructions listed below. (Convolutional Neural Network) First, implement a CNN that contains
Please create a working Python code for this problem and follow all other instructions listed below.

(Convolutional Neural Network) First, implement a CNN that contains 1 convolutional layer, 1 pooling layer, and 1 fully connected layer. The input of the CNN is a gray scale image. The convolutional layer should have two filters/kernels with size of 3 by 3 to for horizontal and vertical edge detection and have the ReLU activation function. For the pooling layer, you can specify the hyperparemters (e.g., filter size, stride size, aggregation function (such as max, min, avg)) yourself. For the fully connected layer, you can specify the number of neurons and the activation function yourself. Let a[0] denote the input image and W[1] and b[1] denote the weight matrix and the bias vector of the convolutional layer, respectively. Let a[1] denote the output of the convoluational layer. Then we have the following mathematical representation: a[1]=g(z[1]),z[1]=W[1]a[0]+b[1] where g() refers to the ReLU activation function. Note that, as W[1] has one horizontal detector and one vertical detector, W[1] is known and does not need to be estimated based on a training set. You may set b[1] to zero or any other values. You may set the values of the weight matrix and the bias vector randomly for the fully connected layer. Based on this procedure, we have predefined all the parameters of the CNN and do not need to learn the parameters from training data. This is the reason no training data are provided in this question. Second, apply the CNN to an input image (see the attachment) to detect all horizontal and vertical edges in this image. You need to first convert the image into gray scale using OpenCV, before you apply the CNN. Third, plot the output of the convolutional layer before the ReLU activation function (z z[1] ), the output of the convolutional layer after the ReLU activation function (a[1]), and the output of the pooling layer. As each of these three outputs is a volume with two channels, you may plot each channel separately. In total, you will generate six figures in total. What need to submit: - Python programming code - Outpus six figures in total
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
