【发布时间】:2018-09-25 10:52:21
【问题描述】:
我需要一些帮助来解决我的错误。我尝试加载 cifar10 数据集,但由于互联网不稳定,第一次无法完全下载,随后在稳定的互联网上重新运行代码会出现此错误:
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
我用代码加载了数据集:
from keras.datasets import cifar10
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
请帮我解决这个问题。
非常感谢。
【问题讨论】:
标签: python-3.x machine-learning keras