How it works...

This section explains how the convolutional neural network is built on Keras to identify handwritten images from MNIST.

  1. For any model development, we need to identify our testing and training datasets as well as the features and the labels. In our case, it is pretty straightforward as the MNIST data from TensorFlow is already broken up into data.train.images for the features and data.train.labels for the labels. Additionally, we want to convert the labels into arrays, so we utilize np.asarray() for ytest and ytrain.
  1. The arrays for xtrain, xtest, ytrain, and ytest are currently not in the proper shape to be used for a convolutional neural network within Keras. As we identified early on in the chapter, the features for the ...

Get Apache Spark Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.