(filepath)
| 28 | |
| 29 | |
| 30 | def load_dataset(filepath): |
| 31 | with open(filepath, 'rb') as fd: |
| 32 | try: |
| 33 | cifar10 = pickle.load(fd, encoding='latin1') |
| 34 | except TypeError: |
| 35 | cifar10 = pickle.load(fd) |
| 36 | image = cifar10['data'].astype(dtype=np.uint8) |
| 37 | image = image.reshape((-1, 3, 32, 32)) |
| 38 | label = np.asarray(cifar10['labels'], dtype=np.uint8) |
| 39 | label = label.reshape(label.size, 1) |
| 40 | return image, label |
| 41 | |
| 42 | |
| 43 | def load_train_data(dir_path='/tmp/cifar-10-batches-py', num_batches=5): # need to save to specific local directories |
no test coverage detected