Skip to content

feat(examples): mnist_mlp — PyTorch + C MNIST dense-MLP parity demo#253

Merged
LeoBuron merged 8 commits into
developfrom
examples-mnist-mlp
Jun 26, 2026
Merged

feat(examples): mnist_mlp — PyTorch + C MNIST dense-MLP parity demo#253
LeoBuron merged 8 commits into
developfrom
examples-mnist-mlp

Conversation

@LeoBuron

Copy link
Copy Markdown
Member

What

Adds examples/mnist_mlp/ — a self-contained MNIST dense-MLP classifier demo with exact PyTorch ↔ C bit-parity, plus a shared examples/_shared/mnist_data.py loader. First of two MNIST examples (the conv twin mnist_cnn follows in a separate PR), replacing the deleted legacy example/MnistExperiment with the factory layer API.

Mirrors the canonical har_classifier/ pattern: prepare_data.pytrain_pytorch.py (reference + per-layer weight export) → train_c.c (factory-API trainer, two modes) → compare.py (informational) → README.md + CMakeLists.txt, wired into the c-bit-parity CI job.

Model: Flatten[1,28,28]→Linear(784→64)→ReLU→Linear(64→10)→Softmax, CrossEntropy (~51 K params). The framework is 1D-only (no Conv2d); the MLP's flatten consumes [1,28,28] directly (the channel-1 acts as batch), so no loader reshape is needed — matching the legacy MLP.

Verification

Notes

  • The train-from-scratch demo (compare.py) is informational, not a gate — independent random init, and the known C-vs-PyTorch training divergence is deferred. On full MNIST the C demo runs ~75 min (framework trains one sample at a time over 54k samples); the README documents this and points at the fast bit-parity check instead.
  • Spec: docs/superpowers/specs/2026-06-26-mnist-examples-design.md; plan: docs/superpowers/plans/2026-06-26-mnist-examples.md (both gitignored scratch).

🤖 Generated with Claude Code

@LeoBuron LeoBuron merged commit 92e1be8 into develop Jun 26, 2026
8 checks passed
@LeoBuron LeoBuron deleted the examples-mnist-mlp branch June 26, 2026 13:17
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.

1 participant