MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / read_cifar

Function read_cifar

tensorpack/dataflow/dataset/cifar.py:40–58  ·  view source on GitHub ↗
(filenames, cifar_classnum)

Source from the content-addressed store, hash-verified

38
39
40def read_cifar(filenames, cifar_classnum):
41 assert cifar_classnum == 10 or cifar_classnum == 100
42 ret = []
43 for fname in filenames:
44 fo = open(fname, 'rb')
45 dic = pickle.load(fo, encoding='bytes')
46 data = dic[b'data']
47 if cifar_classnum == 10:
48 label = dic[b'labels']
49 IMG_NUM = 10000 # cifar10 data are split into blocks of 10000
50 else:
51 label = dic[b'fine_labels']
52 IMG_NUM = 50000 if 'train' in fname else 10000
53 fo.close()
54 for k in range(IMG_NUM):
55 img = data[k].reshape(3, 32, 32)
56 img = np.transpose(img, [1, 2, 0])
57 ret.append([img, label[k]])
58 return ret
59
60
61def get_filenames(dir, cifar_classnum):

Callers 2

__init__Method · 0.85
get_per_pixel_meanMethod · 0.85

Calls 2

appendMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…