TensorFlow Tutorial-MNIST Data Download (Translation)

TensorFlow Tutorial (MNIST Data Download) https://www.tensorflow.org/versions/master/tutorials/mnist/download/index.html#mnist-data-download It is a translation of. We look forward to pointing out any translation errors.


Code: tensorflow / examples / tutorials / mnist /

The purpose of this tutorial is to show you how to download the dataset files needed to classify handwritten numbers using the (classical) MNIST dataset.

Tutorial file

In this tutorial, we will refer to the following files:

File Purpose
input_data.py Code to download the MNIST dataset for training and evaluation.

Data preparation

MNIST is a classic problem in machine learning. The problem is that you look at a grayscale 28x28 pixel image of handwritten numbers and decide which of the numbers 0 to 9 the image represents.

MNIST Digits

For more information, see Yann LeCun's MNIST Page (http://yann.lecun.com/exdb/mnist/) or Chris Olah's MNIST Visualization (http://colah.github.io/posts/) See 2014-10-Visualizing-MNIST /).

download

The Yann LeCun MNIST page (http://yann.lecun.com/exdb/mnist/) hosts training and test data for download.

File Purpose
train-images-idx3-ubyte.gz Training set image-55000 training images, 5000 verification images
train-labels-idx1-ubyte.gz Training set label corresponding to the image
t10k-images-idx3-ubyte.gz Test set image-10000 images
t10k-labels-idx1-ubyte.gz Test set label corresponding to the image

The maybe_download () function in the input_data.py file ensures that these files have been downloaded to the local data folder for training.

The folder name is specified by a flag variable at the beginning of the fully_connected_feed.py file and can be changed as needed.

Unzip and reshape

The file itself is not in standard image format, but is manually unzipped (following the website's instructions) with the extract_images () and extract_labels () functions in input_data.py.

Image data is extracted into a 2D tensor with Image Index, Pixel Index. Here, each element is the intensity value of the pixel in the image indicated by the index, rescaled from [0, 255] to [-0.5, 0.5]. The "image index" corresponds to the images in the dataset and counts up from 0 to the size of the dataset. And the "pixel index" corresponds to a particular pixel in the image and ranges from 0 to the number of pixels in the image.

The 60000 samples in the train- * file are then split into 55000 samples for training and 5000 samples for validation. The image size of all 28x28 pixel grayscale images in the dataset is 784, so the shape of the output tensor for the training set image is [55000, 784].

The label data is extracted into an Image Index 1D tensor valued by the class identifier of each sample. Therefore, for the training set label, the shape of the tensor is [55000].

Data set object

The underlying code downloads, unzips, and reshapes images and labels for the following datasets:

data set Purpose
data_sets.train 55000 images and labels for main training.
data_sets.validation 5000 images and labels for iterative verification of training accuracy.
data_sets.test 10000 images and labels for final test of trained accuracy.

The read_data_sets () function returns a dictionary that holds a DataSet instance for each of these three datasets. The DataSet.next_batch () method is used to fetch a tuple consisting of a list of batch_size sized images and labels. These lists are fed to a running TensorFlow session.

images_feed, labels_feed = data_set.next_batch(FLAGS.batch_size)

Recommended Posts

TensorFlow Tutorial-MNIST Data Download (Translation)
TensorFlow Tutorial-TensorFlow Mechanics 101 (Translation)
Reading data with TensorFlow
TensorFlow Tutorial-Image Recognition (Translation)
Tuning experiment of Tensorflow data
TensorFlow Tutorial-Sequence Transformation Model (Translation)
TensorFlow Tutorial-Partial Differential Equations (Translation)
TensorFlow Tutorial-Convolutional Neural Network (Translation)
[Translation] scikit-learn 0.18 Tutorial Text data manipulation
TensorFlow MNIST For ML Beginners Translation
TensorFlow Tutorial-Vector Representation of Words (Translation)
[Translation] scikit-learn 0.18 User Guide 4.3. Data preprocessing
Try data parallelism with Distributed TensorFlow
Download sample data before running Bokeh
TensorFlow Deep MNIST for Experts Translation