Projects

Neural networks / Visualization / C

08 / 09

dr-ai

A two-layer MNIST digit classifier implemented from first principles in C, with configurable training and an interactive view into activations and predictions.

StatusWorking experiment
Period2022—2026
Built withC / Neural networks / D3D11
Interactive dr-ai window showing a drawn MNIST digit, hidden activations, and class confidence bars.
01 / In operation

A drawn digit moves through the same network used for evaluation, exposing both hidden activations and the final confidence distribution.

02 / Intent

The purpose of dr-ai was not to wrap an existing machine-learning package. It was to make the mechanics concrete: represent the data, perform the matrix operations, propagate activations forward, move error backward, and update the parameters directly.

The revived interface adds a second objective. Instead of reducing the result to one accuracy number, it makes the network inspectable while a user draws inputs of their own.

03 / Architecture

The program follows one explicit data path from binary dataset files to a prediction on screen.

01

MNIST input

Parses IDX headers and samples, reverses file endianness, normalizes pixels, and constructs target vectors.

02

Math layer

Supplies the vector and matrix operations used by training and inference without an external numerical library.

03

Network

Runs two fully connected sigmoid layers, computes error gradients, and applies weight and bias updates.

04

Visualizer

Captures drawn input and renders the input grid, hidden units, class confidence, and current prediction.

04 / Engineering decisions

01

Own the learning loop

Forward propagation, backpropagation, and parameter updates are ordinary C code. Keeping the network deliberately small makes the learning algorithm readable from end to end.

02

Measure a held-out split

Training and evaluation use separate portions of the loaded dataset. The current optimized build reproducibly reaches 91.32% on its held-out 10,000-sample split after one epoch with 16 hidden units.

03

Expose intermediate state

The interactive view renders more than the winning class. Hidden activations and the complete output distribution reveal how the network responds as the input changes.

05 / Current reality

dr-ai is an educational experiment, not a modern deep-learning system. It uses a small two-layer sigmoid network, a simple training loop, and no acceleration or established ML framework. The verified 91.32% result refers to the project’s own held-out split, not the official MNIST test dataset.