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

Update read_cifar.py

parent e8b65f8d
No related merge requests found
...@@ -12,8 +12,18 @@ def read_cifar_batch(path): ...@@ -12,8 +12,18 @@ def read_cifar_batch(path):
labels = batch[b'labels'] labels = batch[b'labels']
return np.float32(data), np.int64(labels) return np.float32(data), np.int64(labels)
def read_cifar(folder_path):
data, labels = read_cifar_batch("./data/cifar-10-python.tar/cifar-10-batches-py~/cifar-10-batches-py/test_batch")
for i in range(1,5):
data = np.concatenate((data, read_cifar_batch(folder_path + "/data_batch_" + str(i))[0]))
labels = np.concatenate((labels, read_cifar_batch(folder_path + "/data_batch_" + str(i))[1]))
return data, labels
if __name__ == "__main__": if __name__ == "__main__":
v1, v2 = read_cifar_batch("./data/cifar-10-batches-py/cifar-10-batches-py~/cifar-10-batches-py/data_batch_1") data, labels = read_cifar("./data/cifar-10-python.tar/cifar-10-batches-py~/cifar-10-batches-py")
print(v1) print(data)
print(v2) print(labels)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment