2017-07-15 2262 views
0

我目前在TensorFlow中使用一些神經網絡 - 我決定嘗試使用CIFAR-10數據集。我從網站上下載了「CIFAR-10 python」數據集:https://www.cs.toronto.edu/~kriz/cifar.html無法加載CIFAR-10數據集:無效加載鍵' x1f'

在Python,我也直接試圖複製提供的是,代碼加載數據:

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:)打開文件,但這也不起作用。

數據集簡直是壞的,或者這是代碼問題?如果數據集不好,我可以在哪裏獲得CIFAR-10的正確數據集?

+0

嘗試刪除'encoding ='bytes''? –

+0

我試過了,同樣的錯誤仍然存​​在。 – MLavrentyev

+0

好的...你有keras嗎? –

回答

1

提取您的*。廣州文件,並使用此代碼

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'] 
0

好像你需要解壓* GZ文件,然後解壓* tar文件得到data_batches的文件夾中。之後你可以在這些批次上應用pickle.load()。