I am using the practising code of mnist data for deep learning in Python 3.4
The original code is
import _pickle as cPickle
def load_data():
f = gzip.open('../data/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_wrapper():
tr_d, va_d, te_d = load_data()
....
However, it causes the UnicodeDecodeError, according to the suggestions on the Internet, I change it cPickle.load(f)
to pickle.load(f, encoding='latin1')
And the same error occurs when I run in the shell
>>> training_data, validation_data, test_data = \
... mnist_loader.load_data_wrapper() \
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\E\Deep Learning Tutorial\neural-networks-and-deep-learning-master\src\mnist_loader.py", line 68, in load_data_wrapper
tr_d, va_d, te_d = load_data()
File "C:\E\Deep Learning Tutorial\neural-networks-and-deep-learning-master\src\mnist_loader.py", line 43, in load_data
And the error line traces back to:
f = gzip.open('../data/mnist.pkl.gz', 'rb')
With the same error as before, but only occurs in different line
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128)
How to fix this problem?