The MNIST dataset

We will start the implementation by getting the MNIST dataset, using the helper functions of TensorFlow.

Let's import the necessary packages for this implementation:

%matplotlib inline

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

from tensorflow.examples.tutorials.mnist import input_data
mnist_dataset = input_data.read_data_sets('MNIST_data', validation_size=0)

Output:
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz

Let's start off by plotting some examples from the MNIST dataset:

# Plotting one image from the training set.
image = mnist_dataset.train.images[2]
plt.imshow(image.reshape((28, 28)), cmap='Greys_r')
Output:
Figure 4: Example image from the MNIST dataset
# Plotting one image from the training set.
image = mnist_dataset.train.images[2]
plt.imshow(image.reshape((28, 28)), cmap='Greys_r')

Output:
Figure 5: Example image from the MNIST dataset
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset