(dir_path='/tmp/cifar-10-batches-py', num_batches=5)
| 41 | |
| 42 | |
| 43 | def load_train_data(dir_path='/tmp/cifar-10-batches-py', num_batches=5): # need to save to specific local directories |
| 44 | labels = [] |
| 45 | batchsize = 10000 |
| 46 | images = np.empty((num_batches * batchsize, 3, 32, 32), dtype=np.uint8) |
| 47 | for did in range(1, num_batches + 1): |
| 48 | fname_train_data = dir_path + "/data_batch_{}".format(did) |
| 49 | image, label = load_dataset(check_dataset_exist(fname_train_data)) |
| 50 | images[(did - 1) * batchsize:did * batchsize] = image |
| 51 | labels.extend(label) |
| 52 | images = np.array(images, dtype=np.float32) |
| 53 | labels = np.array(labels, dtype=np.int32) |
| 54 | return images, labels |
| 55 | |
| 56 | |
| 57 | def load_test_data(dir_path='/tmp/cifar-10-batches-py'): # need to save to specific local directories |
no test coverage detected