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

Function read_label_file

examples/cnn_ms/data/mnist.py:53–59  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

51
52
53def read_label_file(path):
54 with gzip.open(path, 'rb') as f:
55 data = f.read()
56 assert get_int(data[:4]) == 2049
57 length = get_int(data[4:8])
58 parsed = np.frombuffer(data, dtype=np.uint8, offset=8).reshape((length))
59 return parsed
60
61
62def get_int(b):

Callers 1

load_datasetFunction · 0.70

Calls 3

readMethod · 0.80
get_intFunction · 0.70
reshapeMethod · 0.45

Tested by

no test coverage detected