python3.6 报错UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in

现象:

f = gzip.open('MNIST_data/mnist.pkl.gz', 'rb')
training_data, validation_data, test_data = cPickle.load(f)
f.close()

报错:

UnicodeDecodeError                        Traceback (most recent call last)
 in ()
      1 f = gzip.open('MNIST_data/mnist.pkl.gz', 'rb')
----> 2 training_data, validation_data, test_data = cPickle.load(f)
      3 f.close()

UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128)

解决办法:

training_data, validation_data, test_data = cPickle.load(f)

改为:

training_data, validation_data, test_data = cPickle.load(f,encoding='bytes')

参考:

https://blog.csdn.net/qq_41185868/article/details/79039604

你可能感兴趣的:(日常写bug,机器学习)