0
votes

Error

When I run the below code to import the fashion_mnist data:

fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

I get:

ValueError Traceback (most recent call last) in () 1 fashion_mnist = keras.datasets.fashion_mnist 2 ----> 3 (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

~/Asha/machineLearningAsha/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/datasets/fashion_mnist.py

in load_data() 64 with gzip.open(paths[3], 'rb') as imgpath: 65 x_test = np.frombuffer( ---> 66 imgpath.read(), np.uint8, offset=16).reshape(len(y_test), 28, 28) 67 68 return (x_train, y_train), (x_test, y_test)

ValueError: offset must be non-negative and no greater than buffer length (0)

Can someone please help me import the `fashion_mnist' data?

4
What versions of keras, tensorflow, numpy you use? Please provide conda list or conda list -n <myenv> (in case you use conda environment).Mikhail Stepanov
numpy 1.14.5 python 3.6.2 tensorflow 1.10.1AshaLv
Hmm I can't reproduce it in a new environment. Could you create new conda / virtualenv environment and install only keras and tensorflow? It's a library code error, but it works for me with numpy 1.14.5 python 3.6.2 tensorflow 1.10.1 dependencies. I can post a list of my deps but I/m not sure that it's a root of the problem.Mikhail Stepanov
Thanks for your continuing help. I am new to tf and machine learning, I will temporarily ignore this and continue to learn others in tf.AshaLv

4 Answers

1
votes

after deleting that dataset from keras folder after that executing this command that is worked for me

(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
train_images.shape
0
votes

The raw file you download has something wrong(maybe due to your network),so you can delete the file to solve this problem

0
votes

Method load_data refers to the mnist datasets that have already been downloaded to your local keras folder. But if the web download of those datasets has been interrupted you may get faulty (in my case: zero-sized) files which cause the error message (stepping forward an offset of 16 is difficult in a size zero file).

After deleting the disrupted local files load_data will download the files from the web again and everything should be fine.

On my mac the files are located in ~/.keras/datasets/fashion-mnist. Your path should be similar.

0
votes

Go to C:/Users/some_user

where you can find .keras folder

delete that .keras folder

And then run the code.

This will download all the files.