A handcrafted neural network built from scratch using NumPy to classify handwritten digits from the MNIST dataset. Perfect for learning and experimenting with core neural network concepts like forward propagation, backpropagation, and gradient descent.
β
Custom Neural Network
A single hidden-layer network with sigmoid activation functions, trained entirely from scratch.
β
MNIST Dataset Integration
Seamlessly loads and preprocesses the MNIST dataset for efficient training and testing.
β
Interactive Testing
Test the model on MNIST data or your custom handwritten digits (custom.png
).
β
Training Visualization
Monitor the model's performance through loss and accuracy updates after every epoch.
β
Minimal Dependencies
Uses only Python, NumPy, and Matplotlibβno heavy frameworks required!
DigitRecognizer/
β
βββ main.py # Main script for training and testing
βββ test.py # Interactive testing script
βββ utils.py # Utility functions for loading the MNIST dataset
βββ mnist.npz # Preloaded MNIST dataset
βββ custom.png # Custom image for testing
βββ tests/
β βββ test2.png # Additional test image 1
β βββ test3.png # Additional test image 2
βββ demo/
β βββ demo # Directory for demo files
βββ .gitignore # Git ignore file for unnecessary files
βββ requirements.txt # List of required Python packages
βββ README.md # Repository documentation
git clone https://github.com/MansurPro/DigitRecognizer.git
cd DigitRecognizer
Ensure you have Python installed, then install NumPy and Matplotlib:
pip install -r requirements.txt
Run the main.py
script to train the neural network on the MNIST dataset:
python main.py
Use test.py
to interactively test the model with MNIST data or custom images:
python test.py
- Input Layer: Processes 784-pixel flattened grayscale images.
- Hidden Layer: Applies sigmoid activation for feature extraction.
- Output Layer: Outputs predictions using sigmoid activation.
- Backpropagation: Optimizes weights and biases to minimize error using gradient descent.
We welcome contributions! Feel free to fork this repository, open issues, or submit pull requests.
This project is licensed under the MIT License. See the LICENSE file for more details.
Special thanks to the creators of the MNIST dataset and the open-source community for their resources and support.