Unable to load CIFAR-10 dataset: Invalid load key #39;x1f#39;(无法加载 CIFAR-10 数据集:加载键“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: invalid load key, 'x1f'.
我也尝试使用 gzip 模块打开文件(with gzip.open(file, 'rb') as 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"无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法加载 CIFAR-10 数据集:加载键“x1f"无效
基础教程推荐
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 筛选NumPy数组 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01