我正在尝试使用mnist_data进行手写数字识别。现在我尝试使用此代码加载数据。
import cPickle
import numpy as np
def load_data():
f = open('G:/thesis paper/data sets/mnist.pkl.gz', 'rb')
training_data, validation_data, test_data = cPickle.load(f)
f.close()
return (training_data, validation_data, test_data)
def load_data_nn():
training_data, validation_data, test_data = load_data()
inputs = [np.reshape(x, (784, 1)) for x in training_data[0]]
results = [vectorized_result(y) for y in training_data[1]]
training_data = zip(inputs, results)
test_inputs = [np.reshape(x, (784, 1)) for x in test_data[0]]
return (training_data, test_inputs, test_data[1])
def vectorized_result(j):
e = np.zeros((10, 1))
e[j] = 1.0
return e
if __name__ == '__main__':
tr_data,test_inp,test_data=load_data_nn()
但我收到了这个错误。
File "D:/NeuralNet/mnist_loader.py", line 42, in load_data
training_data, validation_data, test_data = cPickle.load(f) cPickle.UnpicklingError: invalid load key, ''.
我无法理解错误要说什么以及如何删除此错误..在此先感谢..