justgo
justgo

Reputation: 11

IOError for import MNIST datasets

I followed the TensorFlow tutorial for import MNIST datasets,i run those commands:

from tensorflow.examples.tutorials.mnist import input_data 
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

then it shows error:

anaconda2/lib/python2.7/gzip.pyc
IOError: Not a gzipped file

I am new to python and tensorflow, and I don't understand what it means, thanks for any help.

My system is ubuntu,run on Ipython 5.1.0.

Upvotes: 1

Views: 1053

Answers (1)

AntiPawn79
AntiPawn79

Reputation: 384

What it Means:

It means it is looking in the MNIST_data directory and the files it is looking at are not gzip files. More specifically, it more than likely just means it looked in the directory and couldn't find the files in this case. This could be due to a variety of reasons. I believe in my case for some reason it just wasn't downloading the files when it found the files didn't exist in the MNIST_data directory.

I had this exact problem and it was quite annoying.

Solution:

Get the data via your browser directly from using curl in your console.

curl -O http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
curl -O http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
curl -O http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
curl -O http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz

Put the data in your root tmp directory. I put it in /tmp/tensorflow/mnist/input_data but you can put it anywhere you want to put it.

Then alter your line to get the mnist data with the directory matching where you put the data.

mnist = input_data.read_data_sets('tmp/tensorflow/mnist/input_data', one_hot=True)

My Environment: (in case that starts to matter for you)

tensorflow pip installed within a virtualenv

python 2.7.10

tensorflow==1.4.0

MacOS Sierra

Upvotes: 1

Related Questions