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

Update read_cifar.py

parent e8b65f8d
Loading
......@@ -11,9 +11,19 @@ def read_cifar_batch(path):
data = batch[b'data']
labels = batch[b'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__":
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)
data, labels = read_cifar("./data/cifar-10-python.tar/cifar-10-batches-py~/cifar-10-batches-py")
print(data)
print(labels)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment