Apply the feedforward neural network (FNN) on the MNIST dataset for hand written digit recognition.
The MNIST database of handwritten digits has a training set of 60,000 digit images, and a test set of 10,000 images. It is a subset of a larger set available from NIST. The digits have been size-normalized and centered in a fixed-size image.
A starter script “” is provided for downloading MNIST dataset, splitting datasets, and feature normalization. You don’t need to changes these coding lines. You might need to install the following packages:
• keras
• numpy
• scipy
• matplotlib
• sklearn

For every image, we will use its pixel-wise intensities as features.To define a FNN model, you will need to specify the following hyper-parameters:
i) number of hidden layers and number of neural units for each layer;
ii) learning rate
iii) activation function (sigm, tanh_opt) and
iv) output function (‘sigm’,’linear’, ‘softmax’);
There is no need for you to code the neural network algorithm from scratch. You can use either third-party libraries or the Tensorflow implementations provided along with this homework (folder named ‘code_FNN_TF’).

Question 1. Please further split the 60,000 training images (and labels) into two subsets: 50,000 images, and 10,000 images. Use these two subsets for training models and validation purposes. In particular, you will train your FNN model using the 50,000 images and labels, and apply the trained model over the rest 10,000 images for evaluation purposes.
Please specify at least three sets of hyper-parameters (see the above). For each set, call the third-party functions or tensorflow to train a FNN model on the training samples (50,000 images in this case), and apply the learned model over the validation set (10,000 images in this case). For each model and its results, please compute its confusion matrix, average accuracy, per-class Precision and Recall. Report the model that achieves the top accuracy.
A sample function for calculating confusion matrix is provided in ‘’

Question 2. Apply the top ranked model over the testing samples (10,000 images). Call the above function to compute the confusion matrix, average accuracy, per-class precision/recall rate. In addition, pickup and visualize TEN testing images for which your mode made errors.Try to analyze the reasons of these failure cases.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

Question 1

Model 1:
· Confusion matrix:
· [[ 891    1    6   26    6    4    6   21    7   16]
· [   0 1020    6    0    6    0   17   21    1   22]
· [   7   37 833   15   14    4    7   44    8   25]
· [ 26    8   17 787    2   72    0   59    4   25]
· [   2    5    0    2 838    0   55    1   22   55]
· [   2    7    2 101   18 582    8   18 114   67]
· [   0   16    0    2   43    0 902    4    3   11]
· [   3   23   12   11    1    3    5 913    1   88...

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats