A basic machine learning project implementing a fully connected neural network from scratch to classify handwritten digits from the MNIST dataset.
The model is trained using gradient based optimization and backpropagation, updating weights after processing each individual image.
This project also includes a simple GUI that allows users to draw digits and see real-time predictions from the trained model.
- Fully connected neural network implemented from scratch
- Manual forward propagation and backpropagation
- Gradient calculation per image (stochastic style updates)
- Accuracy testing on 10.000 MNIST test images
- Interactive GUI built with Pygame for live digit prediction
- Input Layer: 784 neurons (28x28 pixels)
- Hidden Layers: 128 → 64 neurons
- Output Layer: 10 neurons (digit classes 0–9)
Install dependencies:
pip install -r requirements.txtMain libraries used:
- numpy
- pygame
- python-mnist
python3 main.pyThis launches an interactive window where you can draw digits and see real time predictions by running an epoch on the training dataset.
python3 lib.pyThis runs the trained model on the MNIST test set and prints the accuracy. After one training epoch the accuracy becomes approximately 96 %.
This project uses the MNIST handwritten digit dataset:
- 60.000 training images
- 10.000 test images
- 28x28 grayscale images
The goal of this project is to deeply understand:
- How neural networks work internally
- Backpropagation mechanics
- Gradient-based learning
- The relationship between model training and real time inference
This is an educational implementation focused on clarity and learning rather than using high level ML frameworks like TensorFlow or PyTorch.
