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

Function read_image_file

examples/cnn/data/mnist.py:66–75  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

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