An open API service indexing awesome lists of open source software.

https://github.com/mansurpro/digitrecognizer

DigitRecognizer is a simple, handcrafted neural network implemented with NumPy to classify handwritten digits from the MNIST dataset. This project demonstrates the foundational principles of neural networks, including forward propagation, backpropagation, and gradient descent, all built from scratch without relying on deep learning frameworks.
https://github.com/mansurpro/digitrecognizer

backpropagation custom-dataset data-visualization deep-learning from-scratch gradient-descent handwritten-digit-recognition machine-learning minimal-dependencies mnist neural-network numpy python

Last synced: 5 months ago
JSON representation

DigitRecognizer is a simple, handcrafted neural network implemented with NumPy to classify handwritten digits from the MNIST dataset. This project demonstrates the foundational principles of neural networks, including forward propagation, backpropagation, and gradient descent, all built from scratch without relying on deep learning frameworks.

Awesome Lists containing this project

README

          

# πŸ–ŠοΈ **DigitRecognizer**

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.

---

## πŸš€ **Features**

βœ… **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!

---

## πŸ“‚ **Project Structure**

```plaintext
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
```

---

## πŸ› οΈ **Getting Started**

### **1. Clone the Repository**

```bash
git clone https://github.com/MansurPro/DigitRecognizer.git
cd DigitRecognizer
```

### **2. Install Dependencies**

Ensure you have Python installed, then install NumPy and Matplotlib:

```bash
pip install -r requirements.txt
```

### **3. Train the Model**

Run the `main.py` script to train the neural network on the MNIST dataset:

```bash
python main.py
```

### **4. Test the Model**

Use `test.py` to interactively test the model with MNIST data or custom images:

```bash
python test.py
```

---

## 🎨 **Preview**

### Training Visualization:
![Training Visualization](demo/testing_demo.png)

### Interactive Testing (success):
![Interactive Testing](demo/success_demo.png)

### Interactive Testing (fail):
![Interactive Testing](demo/fail_demo.png)

---

## πŸ“Š **How It Works**

1. **Input Layer**: Processes 784-pixel flattened grayscale images.
2. **Hidden Layer**: Applies sigmoid activation for feature extraction.
3. **Output Layer**: Outputs predictions using sigmoid activation.
4. **Backpropagation**: Optimizes weights and biases to minimize error using gradient descent.

---

## πŸ§‘β€πŸ’» **Contributions**

We welcome contributions! Feel free to fork this repository, open issues, or submit pull requests.

---

## πŸ“œ **License**

This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.

---

## πŸ™Œ **Acknowledgments**

Special thanks to the creators of the MNIST dataset and the open-source community for their resources and support.