Skip to content

Added working MNIST autograd engine#36

Merged
rowan-cake merged 11 commits into
mainfrom
danny-nosrati-b1
Mar 14, 2026
Merged

Added working MNIST autograd engine#36
rowan-cake merged 11 commits into
mainfrom
danny-nosrati-b1

Conversation

@Danny-Nosrati

Copy link
Copy Markdown
Collaborator

Created a basic Multi-Layer Perceptron (784-100-100-50-10) to classify handwritten digits.

@Danny-Nosrati
Danny-Nosrati requested a review from a team as a code owner March 14, 2026 19:10
@rowan-cake rowan-cake linked an issue Mar 14, 2026 that may be closed by this pull request

@rowan-cake rowan-cake left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Comment thread src/common/MNIST.py Outdated
Comment on lines +21 to +40
def read_images_labels(self, images_filepath, labels_filepath):
labels = []
with open(labels_filepath, 'rb') as file:
magic, size = struct.unpack(">II", file.read(8))
if magic != 2049:
raise ValueError('Magic number mismatch, expected 2049, got {}'.format(magic))
labels = array("B", file.read())

with open(images_filepath, 'rb') as file:
magic, size, rows, cols = struct.unpack(">IIII", file.read(16))
if magic != 2051:
raise ValueError('Magic number mismatch, expected 2051, got {}'.format(magic))
image_data = array("B", file.read())
images = []
for i in range(size):
images.append([0] * rows * cols)
for i in range(size):
img = np.array(image_data[i * rows * cols:(i + 1) * rows * cols])
img = img.reshape(28, 28)
images[i][:] = img

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow what's the magic here

Comment thread src/common/MNIST.py Outdated
Comment on lines +27 to +50
def read_images_labels(self, images_filepath, labels_filepath):
labels = []
with open(labels_filepath, "rb") as file:
magic, size = struct.unpack(">II", file.read(8))
if magic != 2049:
raise ValueError(
"Magic number mismatch, expected 2049, got {}".format(magic)
)
labels = array("B", file.read())

with open(images_filepath, "rb") as file:
magic, size, rows, cols = struct.unpack(">IIII", file.read(16))
if magic != 2051:
raise ValueError(
"Magic number mismatch, expected 2051, got {}".format(magic)
)
image_data = array("B", file.read())
images = []
for i in range(size):
images.append([0] * rows * cols)
for i in range(size):
img = np.array(image_data[i * rows * cols : (i + 1) * rows * cols])
img = img.reshape(28, 28)
images[i][:] = img

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting

@rowan-cake
rowan-cake merged commit ca60dd1 into main Mar 14, 2026
1 check passed
@rowan-cake
rowan-cake deleted the danny-nosrati-b1 branch March 14, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MNIST Dataset MLP Test

2 participants