Simple_Neural_Network.py: Implementation of a simple neural network and gradient descent using backpropagation for a neural network architecture [2,m,1]
Numerical_Gradient_Calulation.py: Program to numerically obtain gradients from the simple nueral network, used to check that the Network is working correctly
Handwriting_Neural_Network.py: Program using a Neural Network Model to create a classifier to seperate handwritten "1" digits from "5" digits
Handwriting_Neural_Network_With_Validation.py: Program Implmenting the previous Neural Network Model with early stopping with a validation set of size 50 and training set of size 250
A program to implement neural networks and gradient descent using backpropagation for a neural network architecture [2,m,1] with
2 input nodes,
• Allows user to specfify m hidden nodes in 2nd layer
• Allows the user to pick between identity: θ(s) = s, tanh: θ(s) = tanh(s), and sign: θ(s) = sign(x) for the output node transformation in the last layer.
• All the hidden node transformations are tanh, θ(s) = tanh(s) for hidden-layer nodes
• All inital weights set to 0.25:
Figure 1: 2-input, 2-hidden layer, 1-output Neural network
the gradient of Ein(w) using the backpropagation algorithm using a network where m = 2, all the weights equal to 0.25 and a data set with 1 point: x1 =[1,2]; y = 1
Output with identity transformation: θ(s) = s:
Output with tanh transformation: θ(s) = tanh(s):
Python3 Simple_Neural_Network.py
Program to obtain previous gradients numerically by peturbing each weight in turn by 0.0001.
Output with identity transformation: θ(s) = s:
Output with tanh transformation: θ(s) = tanh(s):These results are almost identical to our previous results verifing my back proogation gradient calculation.
Python3 Numerical_Gradient_Calulation.py
Using the Neural Network Model from the previous part create a classifier to seperate the 1 digits from the 5 digits as shown below:
Figure 2: 1 and 5
I chose to use the features of intensity and symmetry, where symmetry in this case means the whether the image is verticaly symmetrical. Let $f(i,j)$ denotes the grayscale values from $-1$ to $1$ for pixel $(i,j)$ as given. And $i,j$ ranges from $1$ to $16$.Then the intensity is defined as:
And the symmetry is defined as:
Using the Neural Network Model developed in the previous part to create this classifier, with
Figure 3:
Python Handwriting_Neural_Network.py
I then separated my set of 300 data points into a validation set of size 50 and training set of size 250, so:
Figure 4:
Python Handwriting_Neural_Network_With_Validation.py