Repository navigation
Add C training driver plus worked MNIST example (closes #44) - #56
Merged
Merged
Conversation
driver.h/driver.c/driver_loop.c: nir_driver_t wires IDX loading, repeat/rate encoding, tape forward/backward, minibatch mean reduction, SGD/Adam steps with LR schedules, and checkpoint save/load with optimizer resume. Per-node accumulators and optimizer instances, seeded shuffle/encode streams, step counter persisted as checkpoint meta step. examples/mnist_train plus mnist_tiny_graph.json: 4-step LI network (Flatten 4->Affine 8->LI 8->Affine 10) trains the committed 2x2 3-sample fixture for 20 Adam epochs, printing loss/accuracy per epoch and saving a v2 checkpoint. Deterministic from seed 7: 2.39/0.000 to 1.16/0.667, step 40. Tests: test_driver asserts 20-epoch loss beats init by 0.5, checkpoint resume is bit-identical with matching step, SGD/rate/schedule smoke paths run finite, and config/data error paths fail cleanly. mnist_train_example runs the binary via ctest; CI also runs it with PATH=/nonexistent to prove zero Python at train time. Docs: README Training section with flow diagram, example invocation, expected output, and zero-Python proof; Scope marks tape/backward/minibatch/checkpoint/init/schedule/loss/driver done. train.h comment refresh for tape/driver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #44.
Driver (
driver.h/driver.c/driver_loop.c):nir_driver_twires the merged pieces with zero Python at train time — IDX (data.h), repeat/rate encoding (encode.h), tape forward/backward (tape.h), minibatch mean reduction (minibatch.h), SGD/Adam steps (train.h) with LR schedules (schedule.h), and v2 checkpoints with optimizer resume (checkpoint.h). Per-node accumulators plus one optimizer instance per weight/bias buffer; seeded shuffle/encode streams; step counter persisted as checkpoint meta step.Example (
examples/mnist_train+mnist_tiny_graph.json): 4-step LI network (Flatten 4→Affine 8→LI 8→Affine 10) trains the committed 2×2 3-sample fixture for 20 Adam epochs, printing loss/accuracy per epoch and saving a v2 checkpoint. Deterministic from seed 7: initial 2.387/0.000 → epoch 20 1.163/0.667, step 40.Acceptance:
Tests:
test_driver: decrease bound, bit-identical checkpoint resume with matching step, SGD/rate/schedule smoke, error paths.mnist_train_examplectest runs the binary; CI also runs it withPATH=/nonexistentto prove no Python dependency.-Wall -Wextra -Werror).Docs: README Scope marks #39-#47 done; train.h stale tape comment refreshed. No changes to merged tape/minibatch/checkpoint/backward modules.