Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_read_one_batch #22

Open
liruixl opened this issue Mar 21, 2018 · 1 comment
Open

_read_one_batch #22

liruixl opened this issue Mar 21, 2018 · 1 comment

Comments

@liruixl
Copy link

liruixl commented Mar 21, 2018

` fo = open(path, 'rb')
dicts = pickle.load(fo)
fo.close()

data = dicts['data']
if is_random_label is False:
label = np.array(dicts[b'labels'])
else:
labels = np.random.randint(low=0, high=10, size=10000)
label = np.array(labels)
return data, label`

  1. 当运行到 dicts = pickle.load(fo)时,报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6: ordinal not in range(128)。您没遇到过这种情况吗?

2.当修改成dicts = pickle.load(fo,encoding='bytes')程序可以继续运行,但是在data = dicts['data']报错:KeyError: 'data'。当我查看dicts.key()后,我发现结果是:dict_keys([b'data', b'labels', b'batch_label', b'filenames']),为什么每个键的前面会出现字母b?

@InstantWindy
Copy link

you can modify it to pickle.load(fo,encoding='iso-8859-1')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants