Loading the data is a simple but obviously integral first step to creating a deep learning model. Fortunately, Keras has some built-in data loaders that are simple to execute. Data is stored in an array:
- First, we will import the keras dataset from TensorFlow:
from keras.datasets import mnist
- Then, we will create the test and train datasets:
(x_train, y_train), (x_test, y_test) = mnist.load_data()
- Now, we will print and check the shape of the x_train data:
print(x_train.shape)
- The shape of x_train is as follows:
(60000, 28, 28)
One of the confusing things that newcomers face when using Keras is getting their dataset in the correct shape (dimensionality) required for Keras.
- When we first load our dataset to Keras, it comes in the form of 60,000 images, 28 x 28 pixels. Let's inspect this in Python by printing the initial shape, the dimension, and the number of samples and labels in our training data:
print ("Initial shape &...