Fill This Form To Receive Instant Help
Homework answers / question archive / CSE 6363: Machine Learning University of Texas at Arlington Spring 2022 Alex Dillhoff Assignment 2 This assignment covers neural networks and backpropagation
Assignment 2
This assignment covers neural networks and backpropagation.
In this first part of this assignment, you will create a neural network library. The library will be made up of documented classes and functions that allow users to easily construct a neural network with an arbitrary number of layers and nodes. Through implementing this library, you will understand more clearly the atomic components that make up a basic neural network.
For the layers you will create in this assignment, it is worth it to create a parent class named Layer which defined the forward and backward functions that are used by all layers.
In this way, we can take advantage of polymorphism to easily compute the forward and backward passes of the entire network.
Create a class that implements a linear layer. The class should inherit the Layer class and implement both forward and backward. For a given input, the forward pass is computed as
f(x;w) = wTx.
The backward pass should compute the gradient with respect to the weights.
x
This is then multiplied with the gradients computed by the layer ahead of this one.
Create a class that implements the logistic sigmoid function. The class should inherit the Layer class and implement both forward and backward.
CSE 6363: Assignment 2 Dillhoff
Create a class that implements the hyperbolic tangent function. The class should inherit the Layer class and implement both forward and backward.
Create a class that implements the softmax function. The class should inherit the Layer class and implement both forward and backward.
The softmax function is defined as
.
The backward pass should compute the gradient with respect to the weights.
x
Create a class that implements negative log likelihood loss. The class should inherit the Layer class and implement both forward and backward.
In order to create a clean interface that includes multiple layers, you will need to create a class that contains a list of layers which make up the network. The Sequential class will contain a list of layers. New layers can be added to it by appending them to the current list. This class will also inherit from the Layer class so that it can call forward and backward as required.
Implement a weight saving and loading feature for a constructed network such that all model weights can be saved to and loaded form a file. This will enable trained models to be stored and shared.
Construct a neural network with 1 hidden layer of 2 nodes in order to solve the XOR problem. Construct the input using numpy. You can reference the code we used for multilayer perceptrons in class to help. Train and verify that your model can solve the XOR problem.
Save the weights as XOR_solved.w.
2
CSE 6363: Assignment 2 Dillhoff
In the second part of the assignment, you will use your neural network library to construct several networks for handwritten digit recognition. There are 60000 training images and 10000 testing images. You should randomly select 10% of the training images to use as a validation set.
In this part, you can experiment with the number of layers and nodes per layer as you wish. Use the loss of the validation set to guide your selection of hyperparameters. Experiment with at least 3 configurations of hyperparameters, plotting the training and validation loss as you train each configuration. Stop training when the loss does not improve after 5 steps. In your report, include the training/validation plots with each choice of hyperparameters.
Once you have trained at least 3 different models, evaluate each one on the test set. Include the test accuracy with your report.
The model behaves differently depending on many factors. Hyperparameters play a huge role in this. Experiment with the following scenarios and include a written section describing your observations during training under each scenario.
Create a zip file that includes all of your code as well as your report. The TA should be able to easily run the code to reproduce all plots and results. Include any additional instructions, if necessary.
3
Please download the answer file using this link
https://drive.google.com/file/d/1wcmKbwZNsMwSKoy7rDux8uY64fYPRuRm/view?usp=sharing