MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / check_image_file_header

Function check_image_file_header

tensorflow/lite/tutorials/dataset.py:41–54  ·  view source on GitHub ↗

Validate that filename corresponds to images for the MNIST dataset.

(filename)

Source from the content-addressed store, hash-verified

39
40
41def check_image_file_header(filename):
42 """Validate that filename corresponds to images for the MNIST dataset."""
43 with tf.gfile.Open(filename, 'rb') as f:
44 magic = read32(f)
45 read32(f) # num_images, unused
46 rows = read32(f)
47 cols = read32(f)
48 if magic != 2051:
49 raise ValueError('Invalid magic number %d in MNIST file %s' % (magic,
50 f.name))
51 if rows != 28 or cols != 28:
52 raise ValueError(
53 'Invalid MNIST file %s: Expected 28x28 images, found %dx%d' %
54 (f.name, rows, cols))
55
56
57def check_labels_file_header(filename):

Callers 1

datasetFunction · 0.85

Calls 2

read32Function · 0.85
OpenMethod · 0.45

Tested by

no test coverage detected