今天准备用Keras跑一下LeNet的程序,结果总是编码出错
源代码是2.7写的,编码格式是utf-8。然后尝试网上各种方法不适用,最后还是解决了
源代码:
data = gzip.open(r‘C:\Users\Administrator\Desktop\Digit Recognizer\mnist.pkl.gz‘)
train_set,valid_set,test_set = cPickle.load(data)
修改后:
with gzip.open(r‘C:\Users\Administrator\Desktop\Digit Recognizer\mnist.pkl.gz‘) as f:
train_set, valid_set, test_set = pickle.load(f, encoding=‘latin1‘)
即可解决。
时间: 2024-11-19 06:49:29