Kick picon UnicodeDecodeError

I am trying to download a mnist character dataset (following the guide given here: http://neuralnetworksanddeeplearning.com/chap1.html )

when I run the load_data_wrapper function, I get an error.

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

Code Run:

 import numpy as np import gzip def load_data(): f = gzip.open('../data/mnist.pkl.gz', 'rb') training_data, validation_data, test_data = pickle.load(f) f.close() return (training_data, validation_data, test_data) def load_data_wrapper(): tr_d, va_d, te_d = load_data() training_inputs = [np.reshape(x, (784,1)) for x in tr_d[0]] training_results = [vectorized_result(y) for y in tr_d[1]] training_data = zip(training_inputs, training_results) validation_inputs = [np.reshape(x,(784, 1))for x in va_d[0]] validation_data = zip(validation_inputs, va_d[1]) test_inputs = [np.reshape(x, (784, 1)) for x in te_d[0]] test_data = zip(test_inputs, te_d[1]) return(training_data, validation_data, test_data) def vectorized_result(j): e = np.zeros((10,1)) e[j] = 1.0 return e 

UPDATE: the problem is what I'm trying to uncover with python 3.6, which was pickled using python 2.x.

+7
python pickle mnist
source share
1 answer

As already mentioned, the main problem turned out to be incompatible between python 2.x cPickle and python 3.x pickle.

setting the encoding to "latin-1" seems to work.

 training_data, validation_data, test_data = pickle.load(f, encoding='latin1') 

The answer here really helped: Fuzzy compatibility of numpy arrays between Python 2 and 3

+11
source share

All Articles