MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / load_mnist_data

Function load_mnist_data

samples/python/scripts/download_mnist_pgms.py:28–36  ·  view source on GitHub ↗
(buffer)

Source from the content-addressed store, hash-verified

26
27# Returns a numpy buffer of shape (num_images, 28, 28)
28def load_mnist_data(buffer):
29 raw_buf = np.fromstring(buffer, dtype=np.uint8)
30 # Make sure the magic number is what we expect
31 assert raw_buf[0:4].view(">i4")[0] == 2051
32 num_images = raw_buf[4:8].view(">i4")[0]
33 image_h = raw_buf[8:12].view(">i4")[0]
34 image_w = raw_buf[12:16].view(">i4")[0]
35 # Colors in the dataset are inverted vs. what the samples expect.
36 return np.ascontiguousarray(255 - raw_buf[16:].reshape(num_images, image_h, image_w))
37
38# Returns a list of length num_images
39def load_mnist_labels(buffer):

Callers 1

mainFunction · 0.85

Calls 1

viewMethod · 0.80

Tested by

no test coverage detected