Skip to content

Instantly share code, notes, and snippets.

@georgebyte
georgebyte / mnist.py
Last active July 31, 2019 13:46
Python: Mnist Reader
def get_data_and_labels(images_filename, labels_filename):
print("Opening files ...")
images_file = open(images_filename, "rb")
labels_file = open(labels_filename, "rb")
try:
print("Reading files ...")
images_file.read(4)
num_of_items = int.from_bytes(images_file.read(4), byteorder="big")
num_of_rows = int.from_bytes(images_file.read(4), byteorder="big")