TensorFlow Study Note Three: instance data download and read

Source: Internet
Author: User

An introductory example of deep learning is generally mnist handwritten digit recognition, so we should download this data set first.

TensorFlow provides a input_data.py file specifically for downloading mnist data, which we can call directly, with the following code:

Import= input_data.read_data_sets ("mnist_data/", One_hot=true)

After execution, a new folder will be created in the current directory Mnist_data, and the downloaded data will be placed in this folder. The four downloaded files are:

The Input_data file invokes a Maybe_download function to ensure that the data is downloaded successfully. This function also determines whether the data has already been downloaded, and if it has already been downloaded, it will not be downloaded again.

The downloaded dataset is divided into three subsets: a 5.5W line of training data set ( mnist.train ), a 5,000-row validation dataset (Mnist.validation), and a 1W row of test Datasets ( mnist.test ). Because each picture is a black and white picture of 28x28, each behavior is 784-dimensional vector.

Each subset consists of two parts: the picture section (images) and the label section (labels), which we can view with the following code:

Print (Mnist.train.images.shape) Print (Mnist.train.labels.shape) Print (Mnist.validation.images.shape) Print (Mnist.validation.labels.shape) Print (Mnist.test.images.shape) Print (Mnist.test.labels.shape)

If you want to view specific values in the Spyder editor, you can extract the data as variables to view, such as:

Val_data=mnist.validation.images
Val_label=mnist.validation.labels

In addition to mnist handwritten font image data, TF also provides several CSV data for everyone to practice, with the following paths:

/home/xxx/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/datasets/data/text_ Train.csv

If you want to read this data out, the code is available:

Import tensorflow.contrib.learn.python.learn.datasets.base as Baseiris_data,iris_label=Base.load_iris () House_data,house_label=base.load_boston ()

The former is Iris Iris floral data Set, which is the Boston house price data.

TensorFlow Study Note Three: instance data download and read

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.