MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / getCIFAR10

Function getCIFAR10

keras_examples/util.py:49–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 return Xtrain, Ytrain, Xtest, Ytest
48
49def getCIFAR10():
50 Xtrain = np.zeros((50000, 32, 32, 3), dtype=np.uint8)
51 Ytrain = np.zeros(50000, dtype=np.uint8)
52
53 # train data
54 for i in range(5):
55 fn = 'data_batch_%s.mat' % (i+1)
56 d = loadmat('../large_files/cifar-10-batches-mat/' + fn)
57 x = d['data']
58 y = d['labels'].flatten()
59 x = x.reshape(10000, 3, 32, 32)
60 x = np.transpose(x, (0, 2, 3, 1))
61 Xtrain[i*10000:(i+1)*10000] = x
62 Ytrain[i*10000:(i+1)*10000] = y
63
64 # test data
65 d = loadmat('../large_files/cifar-10-batches-mat/test_batch.mat')
66 x = d['data']
67 y = d['labels'].flatten()
68 x = x.reshape(10000, 3, 32, 32)
69 x = np.transpose(x, (0, 2, 3, 1))
70 Xtest = x
71 Ytest = y
72
73 return Xtrain, Ytrain, Xtest, Ytest
74

Callers 1

cnn_cifar.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected