Python 3 keras: UnpicklingError: pickle data was truncated for partly downloaded keras cifar10 dataset
12,761
Remove the file ~/.keras/datasets/cifar-10-batches-py.tar.gz
and possibly the folder ~/.keras/datasets/cifar-10-batches-py
if it exists and try again, it should redownload the file, hopefully succeeding this time.
Related videos on Youtube
Author by
kebochiG
Updated on June 04, 2022Comments
-
kebochiG almost 2 years
I need some help to fix my errors. I tried to load the cifar10 dataset and it wasn't able to download completely the first time due to unstable internet, subsequently re-running the code with a stable internet gives this error:
UnpicklingError: Traceback (most recent call last) <ipython-input-16-9117078ebdb2> in <module>() 1 from keras.datasets import cifar10 ----> 2 (x_train, y_train), (x_test, y_test) = cifar10.load_data() c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site- packages\keras\datasets\cifar10.py in load_data(label_mode) 32 33 fpath = os.path.join(path, 'test_batch') ---> 34 x_test, y_test = load_batch(fpath) 35 36 y_train = np.reshape(y_train, (len(y_train), 1)) c:\users\keboc\anaconda3\envs\tensorflow_1.8\lib\site-packages\keras\datasets\cifar.py in load_batch(fpath, label_key) 25 d = cPickle.load(f, encoding='bytes') 26 # decode utf8 ---> 27 #d_decoded = {} 28 for k, v in d.items(): 29 d_decoded[k.decode('utf8')] = v UnpicklingError: pickle data was truncated
I loaded the dataset with the code:
from keras.datasets import cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data()
Please help me to fix this.
Thanks alot.
-
kebochiG over 5 yearsThe file and folder aren't present in that directory. Only the .py files (cifar10.py). So there's nothing to remove.
-
Dr. Snoopy over 5 years@kebochiG Are you sure you are looking in the right place? It sounds like you are looking inside keras' source code, I am talking about the ~/.keras folder, note the . (period) meaning it is a hidden folder in your home folder.
-
kebochiG over 5 yearsOh, okay. I'm probably not looking in the right place @Matias. I am currently looking at "C:\Users\username\Anaconda3\envs\tensorflow_1.8\Lib\site-packages\keras\datasets" directory. Please how can I get to the right place. I also see no hidden folder in my home folder ( where my .ipynb file is) and I have the view hidden folders option ticked.