(path)
| 64 | |
| 65 | |
| 66 | def 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 | |
| 78 | def normalize(train_x, val_x): |
no test coverage detected