Skip to content
Mustafa Tarhan

Handwritten Digit Recognition in Plain C

A neural network with backpropagation written from scratch, with an OpenMP-parallel forward pass and a drawing app.

Machine learning · course project2023Complete
Role
Course project at HTW Berlin.
Network
784-64-10
Parallel
OpenMP
Stack
C, OpenMP, SDL2, Make, R (plots), GitLab CI

What it does

A fully connected network (784 → 64 → 10) implemented in C without any ML library: forward pass, backpropagation, weight loading and a learning-rate study. An SDL window lets you draw a digit with the mouse and classifies it live. A sequential and an OpenMP-parallel implementation share one interface.

  1. Input
    • 28×28 drawing
    • SDL window
  2. Network
    • 784 → 64 → 10
    • Backpropagation
  3. Output
    • Predicted digit
    • Learning-rate study

The hard part

Writing training and inference by hand (memory layout of layers and weights, gradients, learning rate) and then parallelising it.