Skip to content Skip to sidebar Skip to footer

Unable To Load Cifar-10 Dataset: Invalid Load Key '\x1f'

I'm currently playing around with some neural networks in TensorFlow - I decided to try working with the CIFAR-10 dataset. I downloaded the 'CIFAR-10 python' dataset from the websi

Solution 1:

Extract your *.gz file and use this code

from six.moves import cPickle
f = open("path/data_batch_1", 'rb')
datadict = cPickle.load(f,encoding='latin1')
f.close()
X = datadict["data"]
Y = datadict['labels']

Solution 2:

Just extract your tar.gz file, you will get a folder of data_batch_1, data_batch_2, ...

After that just use, the code provided to load data into your project :

defunpickle(file):
    import pickle
    withopen(file, 'rb') as fo:
        dict = pickle.load(fo, encoding='bytes')
    returndict

dict = unpickle('data_batch_1')

Solution 3:

It seems like that you need to unzip *gz file and then unzip *tar file to get a folder of data_batches. Afterwards you could apply pickle.load() on these batches.

Solution 4:

I was facing the same problem using jupyter(vscode) and python3.8/3.7. I have tried to edit the source cifar.py cifar10.py but without success. the solution for me was run these two lines of code in separate normal .py file:

from tensorflow.keras.datasetsimport cifar10
cifar10.load_data()

after that it worked fine on Jupyter.

Post a Comment for "Unable To Load Cifar-10 Dataset: Invalid Load Key '\x1f'"