MCPcopy Create free account
hub / github.com/apache/singa / load_train_data

Function load_train_data

examples/cnn/data/cifar10.py:43–54  ·  view source on GitHub ↗
(dir_path='/tmp/cifar-10-batches-py', num_batches=5)

Source from the content-addressed store, hash-verified

41
42
43def 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
57def load_test_data(dir_path='/tmp/cifar-10-batches-py'): # need to save to specific local directories

Callers 1

loadFunction · 0.70

Calls 3

emptyMethod · 0.80
load_datasetFunction · 0.70
check_dataset_existFunction · 0.70

Tested by

no test coverage detected