Question: Implement a Neural Network(NN): a. Using tensorflow.keras.datasets import the MNIST dataset. (https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist) b. Transform each image (2D: 28x28) to 1D array (1D: 784) using Pandas

Implement a Neural Network(NN):

a. Using tensorflow.keras.datasets import the MNIST dataset. (https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist)

b. Transform each image (2D: 28x28) to 1D array (1D: 784) using Pandas or Numpy.

c. Let's define the data for the binary classification. From the training and testing datasets select all the samples corresponding to the classes 0 and 1. It will result in 12000 samples for training and 2000 for testing. This is the data you will use in this project.

d. Use the selected data to train a shallow NN:

1. Build a shallow neural network with the following hyperparameters: Activation functions: relu, Number of hidden layers: 3, Neurons per layer: 512, Optimizer: adam, Loss: binary_crossentropy, Metric: accuracy, Epochs: 20

2. Train the NN using 10% (1200 samples) of the training data and 100% (2000 samples) of the testing data. Analyze the training and testing accuracy.

3. Train the network using 100% of the training (12000 samples) data and evaluate the model using 100% (2000 samples) of testing data.

4. Assume that the only available data is the 12000 training samples. Take 25% of the training data (3000 samples) and use it for testing. Use the remaining 75% (9000) for training. Compare the accuracy of the model to the results obtained from parts 2 and 3.

5. Define the network such as it has 8 neurons per layer. Train the NN using 100% of the training data (12000) and evaluate the model with the 100% of testing data (2000).

6.For each part from d2 to d5 answer the following questions:

Q1: Are the accuracy results due to overfitting, underfitting or other? why? Justify your answer.

Q2: What part of the percentage in the testing/training process is affecting the results?

e. List which of the hyperparameters in d1 would you modify (without increasing the number of layers) to improve the testing accuracy for the NN in d2. Justify your answer.

f. Plot the model architecture created in d2.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!