6. Neural Networks and Deep Learning
Activity 6.01: Finding the Best Accuracy Score for the Digits Dataset
Solution:
- Open a new Jupyter Notebook file.
- Import
tensorflow.keras.datasets.mnist
asmnist
:import tensorflow.keras.datasets.mnist as mnist
- Load the
mnist
dataset usingmnist.load_data()
and save the results into(features_train, label_train), (features_test, label_test)
:(features_train, label_train), \ (features_test, label_test) = mnist.load_data()
- Print the content of
label_train
:label_train
The expected output is this:
array([5, 0, 4, ..., 5, 6, 8], dtype=uint8)
The
label
column contains numeric values that correspond to the10
handwritten digits:0
to9
. - Print the shape of the training set:
features_train.shape
The expected output is this:
(60000, 28, 28)
The training set is composed of
60,000
observations of shape28
by28
. We will need to flatten the input for our neural network. - Print the shape of the testing set:
features_test.shape
The expected...