May 2020
Intermediate to advanced
404 pages
10h 52m
English
The current shape of the image arrays are not Keras-friendly. We must convert the image arrays into a shape of (60000, 28, 28, 1) and (10000, 28, 28, 1), respectively.
To do so, we use the following lines of code:
x_train = train_images.reshape(train_images.shape[0], 28, 28, 1)x_test = test_images.reshape(test_images.shape[0], 28, 28, 1)
Now, if we observe the shape of x_train, we get an output as follows:
(60000, 28, 28, 1)
We have no changes to make in the labels arrays and so we directly assign them to y_train and y_test:
y_train = train_labelsy_test = test_labels
Next, we will create a neural network using Keras.
Read now
Unlock full access