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