PYTHON: Implement ConvNet using PyTorch for digit classification. Sample code files (two files: CNN.py and main.py) are given in the attachment. Fill the parts indicated clearly in the code. The output should be saved as output.txt. When you are asked to include a convolutional layer, do not forget to include max pooling or average pooling layer(s) as well. Note that while main.py is for training, CNN.py includes models.
STEP 1: Create a fully connected (FC) hidden layer (with 100 neurons) with sigmoid activation function. Train it with SGD with a learning rate of 0.1 (a total of 60 epochs), a mini-batch size of 10, and no regularization. Note that there will be an output layer after the hidden layer to map hidden neurons to a number of classes.
STEP 2: Now insert two convolutional layers to the network built in STEP 1 (and put the pooling layer too for each convolutional layer). Pool over 2x2 regions, 40 kernels, stride = 1, with a local receptive field of 5x5.
STEP 3: For the network depicted in STEP 2, replace Sigmoid with ReLU, and train the model with a new learning rate (= 0.03). Re-train the system with this setting.
STEP 4: Add another fully connected (FC) layer now (with 100 neurons) to the network built in STEP 3. Use L2 regularization on the parameters of the two FC layers. (Remember that the first FC was put in STEP 1, here you are putting just another FC).
STEP 5: Change the number of neurons in FC layers to 1000. For regularization, use Dropout (with a rate of 0.5). Train the whole system using 40 epochs.
Files: CNN.py and main.py
https://github.com/franky1001/CNN