无法加载CIFAR-10数据集:无效的加载键'\x1f' [英] Unable to load CIFAR-10 dataset: Invalid load key '\x1f'
问题描述
我目前正在TensorFlow中使用一些神经网络-我决定尝试使用CIFAR-10数据集。我从网站下载了 CIFAR-10 python数据集: https:// www .cs.toronto.edu /〜kriz / cifar.html 。
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 website: https://www.cs.toronto.edu/~kriz/cifar.html.
在Python中,我还尝试直接复制提供的用于加载数据的代码:
In Python, I also tried directly copying the code that is provided to load the data:
def unpickle(file):
import pickle
with open(file, 'rb') as fo:
dict = pickle.load(fo, encoding='bytes')
return dict
但是,运行此命令时,出现以下错误: _pickle.UnpicklingError:无效的加载密钥'keyx1f'。
我ve还尝试使用gzip模块(和gzip.open(file,'rb')作为fo:
)打开文件,但这也不起作用。
However, when I run this, I end up with the following error: _pickle.UnpicklingError: invalid load key, '\x1f'.
I've also tried opening the file using the gzip module (with gzip.open(file, 'rb') as fo:
), but this didn't work either.
数据集是不是很糟糕,还是代码有问题?如果数据集不好,我在哪里可以获取CIFAR-10的正确数据集?
Is the dataset simply bad, or this an issue with code? If the dataset's bad, where can I obtain the proper dataset for CIFAR-10?
推荐答案
提取* .gz文件并使用这段代码
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']
这篇关于无法加载CIFAR-10数据集:无效的加载键'\x1f'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!