Skip to content
Snippets Groups Projects
Commit e8b65f8d authored by Audard Lucile's avatar Audard Lucile
Browse files

Create read_cifar.py

parent e6bb3b4a
Branches
No related tags found
Loading
import pickle
import numpy as np
def unpickle(file):
with open(file, 'rb') as fo:
batch = pickle.load(fo, encoding='bytes')
return batch
def read_cifar_batch(path):
batch = unpickle(path)
data = batch[b'data']
labels = batch[b'labels']
return np.float32(data), np.int64(labels)
if __name__ == "__main__":
v1, v2 = read_cifar_batch("./data/cifar-10-batches-py/cifar-10-batches-py~/cifar-10-batches-py/data_batch_1")
print(v1)
print(v2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment