DeepLearningPython
DeepLearningPython copied to clipboard
'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128)
python 3.6.5 Anaconda still gives this error for
f = gzip.open('mnist.pkl.gz', 'rb')
training_data, validation_data, test_data = pickle.load(f, encoding="latin1")
f.close()
Works fine.
I am facing the same problem. In fact code
f = gzip.open('neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb') training_data, validation_data, test_data = pickle.load(f,encoding='bytes') f.close()
OR
with gzip.open('neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb') as ff: u=pickle._Unpickler(ff) u.encoding='latin1'
training_data, validation_data, test_data=u.load()
both are giving the same following error
training_data , validation_data , test_data = mnist_loader.load_data_wrapper() Traceback (most recent call last): File "
", line 1, in File "C:\Users\rkd\Desktop\NN-DL\mnist_loader.py", line 61, in load_data_wrapper numpy.ndarry containing the input image, and y
is the File "C:\Users\rkd\Desktop\NN-DL\mnist_loader.py", line 39, in load_data # training_data, validation_data, test_data = pickle.load(f,encoding='bytes') UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128) I would appreciate your help in this regard.
best wishes Ritesh
How to resolve that issue @ppatel26 ?
Turns out that un-pickling in Python 3 needs some decoding. As explained here. Basically, after opening on gzip, try the following,
u = pickle._Unpickler( f )
u.encoding = 'latin1'
train, val, test = u.load()
lo que menciona shashankravi96 funciona perfecto! gracias
I am facing the same problem. In fact code
f = gzip.open('neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb') training_data, validation_data, test_data = pickle.load(f,encoding='bytes') f.close()
OR
with gzip.open('neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb') as ff: u=pickle._Unpickler(ff) u.encoding='latin1'
training_data, validation_data, test_data=u.load()
both are giving the same following error
training_data , validation_data , test_data = mnist_loader.load_data_wrapper() Traceback (most recent call last): File "", line 1, in File "C:\Users\rkd\Desktop\NN-DL\mnist_loader.py", line 61, in load_data_wrapper numpy.ndarry containing the input image, and
y
is the File "C:\Users\rkd\Desktop\NN-DL\mnist_loader.py", line 39, in load_datatraining_data, validation_data, test_data = pickle.load(f,encoding='bytes')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128) I would appreciate your help in this regard.
best wishes Ritesh
Hi yebud! I just started 'neural-networks-and-deep-learning' a few days ago and I am stuck right now. I saw you used this learning material as well, is there any chance I can contact you? I want to learn from your valuable experience.
All the best, Thank you!
Hi,
this is the one that works for me. I am using Python from Spyder from Anaconda...
El mar., 21 de abr. de 2020 a la(s) 03:19, Poramintrl ( [email protected]) escribió:
I am facing the same problem. In fact code
f = gzip.open('neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb') training_data, validation_data, test_data = pickle.load(f,encoding='bytes') f.close()
OR
with gzip.open('neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb') as ff: u=pickle._Unpickler(ff) u.encoding='latin1'
training_data, validation_data, test_data=u.load()
both are giving the same following error
training_data , validation_data , test_data = mnist_loader.load_data_wrapper() Traceback (most recent call last): File "", line 1, in File "C:\Users\rkd\Desktop\NN-DL\mnist_loader.py", line 61, in load_data_wrapper numpy.ndarry containing the input image, and y is the File "C:\Users\rkd\Desktop\NN-DL\mnist_loader.py", line 39, in load_data training_data, validation_data, test_data = pickle.load(f,encoding='bytes')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128) I would appreciate your help in this regard.
best wishes Ritesh
Hi yebud! I just started 'neural-networks-and-deep-learning' a few days ago and I am stuck right now. I saw you used this learning material as well, is there any chance I can contact you? I want to learn from your valuable experience.
All the best, Thank you!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MichalDanielDobrzanski/DeepLearningPython35/issues/15#issuecomment-617090137, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO7HKCCT4ICSLVW34HHCBN3RNVXLPANCNFSM4F23OOSA .
Turns out that un-pickling in Python 3 needs some decoding. As explained here. Basically, after opening on gzip, try the following,
u = pickle._Unpickler( f )
u.encoding = 'latin1'
train, val, test = u.load()
Works! Thank you :) @shashankravi96
The code provided by @ppatel26 is functional in Python 3.8.2.
Turns out that un-pickling in Python 3 needs some decoding. As explained here. Basically, after opening on gzip, try the following,
u = pickle._Unpickler( f )
u.encoding = 'latin1'
train, val, test = u.load()
brilliant, It works for me in Colab, thanks
I'm really lost, I'm relatively new to coding and whenever I try a solution for the mnist_loader file I get an error message that I don't understand. I don't suppose someone could put an example of a complete python file that I could just copy and paste? That would be amazing...
I'm really lost, I'm relatively new to coding and whenever I try a solution for the mnist_loader file I get an error message that I don't understand. I don't suppose someone could put an example of a complete python file that I could just copy and paste? That would be amazing...
Try codes below in Colab
!git clone https://github.com/mnielsen/neural-networks-and-deep-learning.git
import pickle
import gzip
import numpy as np
f = gzip.open("./neural-networks-and-deep-learning/data/mnist.pkl.gz")
training_data, validation_data, test_data = pickle.load(f, encoding="latin1")
print(training_data)
Try from this repo
!git clone https://github.com/MichalDanielDobrzanski/DeepLearningPython35.git
!ls
import pickle
import gzip
import numpy as np
f = gzip.open("./DeepLearningPython35/mnist.pkl.gz")
training_data, validation_data, test_data = pickle.load(f, encoding="latin1")
print(training_data)
Thankyou for your help shaopengwu!
Unfortunately I don't understand what this does - the output from Colab is:
Cloning into 'neural-networks-and-deep-learning'... remote: Enumerating objects: 1163, done. remote: Total 1163 (delta 0), reused 0 (delta 0), pack-reused 1163 Receiving objects: 100% (1163/1163), 20.42 MiB | 14.01 MiB/s, done. Resolving deltas: 100% (577/577), done. (array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], dtype=float32), array([5, 0, 4, ..., 8, 4, 8]))
What does this mean? How does this help me?
Try from this repo
!git clone https://github.com/MichalDanielDobrzanski/DeepLearningPython35.git !ls import pickle import gzip import numpy as np f = gzip.open("./DeepLearningPython35/mnist.pkl.gz") training_data, validation_data, test_data = pickle.load(f, encoding="latin1") print(training_data)
this worked well thank u so much
Try from this repo
!git clone https://github.com/MichalDanielDobrzanski/DeepLearningPython35.git !ls import pickle import gzip import numpy as np f = gzip.open("./DeepLearningPython35/mnist.pkl.gz") training_data, validation_data, test_data = pickle.load(f, encoding="latin1") print(training_data)
even after setting encoding as latin1, it's still giving the same
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128) somehow it's not recognizing the encoding that I set?
Try from this repo
!git clone https://github.com/MichalDanielDobrzanski/DeepLearningPython35.git !ls import pickle import gzip import numpy as np f = gzip.open("./DeepLearningPython35/mnist.pkl.gz") training_data, validation_data, test_data = pickle.load(f, encoding="latin1") print(training_data)
even after setting encoding as latin1, it's still giving the same
UnicodeDecodeError: 'ascii' codec can't decode byte 0x90 in position 614: ordinal not in range(128) somehow it's not recognizing the encoding that I set?
if you are working on notebook, please shutdown the project and reconnect and then run the code to see. It works for me after such refresh.
I dont know why not actualize the code for python3. After all why bother leave the book on line If you can use the code to study? The code worked only in the jupyter notebook! Paulo
Turns out that un-pickling in Python 3 needs some decoding. As explained here. Basically, after opening on gzip, try the following,
u = pickle._Unpickler( f )
u.encoding = 'latin1'
train, val, test = u.load()
This worked for me.
In python 3.9 you have to use named parameters like so:
import _pickle as cPickle imported = cPickle.Unpickler(file=f, encoding='latin1') training_data, validation_data, test_data = imported.load()
There are multiple issues on chapter 1 in respect of python2 -> 3:
- print "string" -> print("string")
- xrange(some list) -> range(some list)
- ...._data = zip(..._inputs) -> ...._data = list(zip(..._inputs)) Then it runs in 3.7
For the people, who still struggling with it, just change the code into: f = gzip.open('../data/mnist.pkl.gz', 'rb') u = cPickle.Unpickler(file=f, encoding='latin1') training_data, validation_data, test_data = u.load() f.close() return (training_data, validation_data, test_data) return (training_data, validation_data, test_data)
In python 3.9 you have to use named parameters like so:
import _pickle as cPickle imported = cPickle.Unpickler(file=f, encoding='latin1') training_data, validation_data, test_data = imported.load()
This worked for me. Thanks a lot!