Here is how we proceed with the recipe:
- The first step is, as always, importing the modules needed:
import tensorflow as tfimport matplotlib.pyplot as plt, matplotlib.image as mpimg
- We take the input data of MNIST from the TensorFlow examples given in the module input_data. The one_hot flag is set to True to enable one_hot encoding of labels. This results in generating two tensors, mnist.train.images of shape [55000,784] and mnist.train.labels of shape [55000,10]. Each entry of mnist.train.images is a pixel intensity with the value ranging between 0 and 1:
from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
- Create placeholders for the training dataset ...