同学你好,你的python2还是python3?python2和python3的方式是不一样的。
py3:
def load_data(filename):
"""read data from data file."""
with open(filename, 'rb') as f:
data = pickle.load(f, encoding='bytes')
return data[b'data'], data[b'labels']
py2:
def load_data(filename):
"""read data from data file."""
with open(filename, 'rb') as f:
data = cPickle.load(f)
return data['data'], data['labels']