We will proceed with the recipe as follows:
- We will start by loading the necessary libraries. Note that we will also import the Python Image Library (PIL), to be able to plot a sample of the predicted outputs. And TensorFlow has a built-in method to load the MNIST dataset that we will use, as follows:
import random import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from PIL import Image from tensorflow.examples.tutorials.mnist import input_data
- Now, we will start a graph session and load the MNIST data in a one-hot encoded form:
sess = tf.Session() mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)