一、错误代码及解决
def load_data(filename):
#read data form data file
with open(filename,'rb') as f:
data = pickle.load(f)
# print(type(data))
# print(data.keys())
# print(type(data[b'labels']))
return data[b'data'],data[b'labels']
会报如题错误,主要是编码方式不同引起的,改变一下pickle.load中的encoding如下即可
def load_data(filename):
#read data form data file
with open(filename,'rb') as f:
data = pickle.load(f,encoding='bytes')
# print(type(data))
# print(data.keys())
# print(type(data[b'labels']))
return data[b'data'],data[b'labels']