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

Function read_image_file

examples/singa_peft/examples/data/mnist.py:67–76  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

65
66
67def read_image_file(path):
68 with gzip.open(path, 'rb') as f:
69 data = f.read()
70 assert get_int(data[:4]) == 2051
71 length = get_int(data[4:8])
72 num_rows = get_int(data[8:12])
73 num_cols = get_int(data[12:16])
74 parsed = np.frombuffer(data, dtype=np.uint8, offset=16).reshape(
75 (length, 1, num_rows, num_cols))
76 return parsed
77
78
79def normalize(train_x, val_x):

Callers 1

load_datasetFunction · 0.70

Calls 3

readMethod · 0.80
get_intFunction · 0.70
reshapeMethod · 0.45

Tested by

no test coverage detected