Reputation: 43
I have an array W
containing float numbers.
W.dtype = float32
type(W) = <type 'numpy.ndarray'>
Then I pickle.dump()
it into a mr.pkl
file,
pickle.dump(W, open("/home/mr.pkl", "wb"))
but when I load it,
pickle.load(open("/home/mr.pkl","rb"))
an error occurs:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 1206: ordinal not in range(128)
I don't know why, I was confused about it for a week, can any one help me about this? any help is appreciated, thank you a lot!
Upvotes: 2
Views: 7298
Reputation: 3
OK, I find out a solution but only in console mode.
The steps are as followings.
But...
7. I still do not know why it is not workable in IPython.
Upvotes: 0
Reputation: 7856
I had the same problem, this code worked for me. The encoding='latin1' is the important part.
# read in data from pickle file created with Load_Data.py
pickle_file = 'mnist.pkl'
with open(pickle_file, 'rb') as f:
train_set, valid_set, test_set = pickle.load(f, encoding='latin1')
Upvotes: 8