MLP for image classification
Let's build the MLP network for image classification using different libraries, such as TensorFlow, Keras, and TFLearn. We shall use the MNIST data set for the examples in this section.
The MNIST dataset contains the 28x28 pixel images of handwritten digits from 0 to 9, and their labels, 60K for the training set and 10K for the test set. The MNIST dataset is the most widely used data set, including in TensorFlow examples and tutorials.
Note
The MNIST dataset and related documentation are available from the following link: http://yann.lecun.com/exdb/mnist/.
Let us start with the pure TensorFlow approach.
TensorFlow-based MLP for MNIST classification
First, load the MNIST dataset, and define the training and test features and the targets using the following code:
from tensorflow.examples.tutorials.mnist import input_data mnist_home = os.path.join(datasetslib.datasets_root, 'mnist') mnist = input_data.read_data_sets(mnist_home, one_hot=True) X_train = mnist.train.images...