{"id":31724940,"url":"https://github.com/mbeps/deep-convolutional-neural-network-digits-classifier","last_synced_at":"2026-04-11T21:34:44.940Z","repository":{"id":278264894,"uuid":"929387610","full_name":"mbeps/deep-convolutional-neural-network-digits-classifier","owner":"mbeps","description":"A deep learning model that classifies handwritten digits using a CNN architecture trained on multiple datasets, designed to generalize well to unseen handwriting styles. ‎‎‏‏‎This is a coursework for the Pattern Recognition, Neural Networks and Deep Learning (7CCSMPNN) module for King's College London. ","archived":false,"fork":false,"pushed_at":"2025-03-26T12:30:41.000Z","size":445,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-11T21:34:17.730Z","etag":null,"topics":["ai","artificial-intelligence","classification","deep-learning","deep-learning-algorithms","deep-neural-networks","kereas","machine-learning","neural-networks","pattern-recognition","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbeps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-08T12:37:36.000Z","updated_at":"2025-04-29T09:40:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"d49de6d0-8230-44df-9ecb-ccad9a4856b7","html_url":"https://github.com/mbeps/deep-convolutional-neural-network-digits-classifier","commit_stats":null,"previous_names":["mbeps/pattern-recognition-neural-network-coursework-1","mbeps/deep-convolutional-neural-network-digits-classifier"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mbeps/deep-convolutional-neural-network-digits-classifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fdeep-convolutional-neural-network-digits-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fdeep-convolutional-neural-network-digits-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fdeep-convolutional-neural-network-digits-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fdeep-convolutional-neural-network-digits-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbeps","download_url":"https://codeload.github.com/mbeps/deep-convolutional-neural-network-digits-classifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fdeep-convolutional-neural-network-digits-classifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31696743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T21:17:31.016Z","status":"ssl_error","status_checked_at":"2026-04-11T21:17:24.556Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","classification","deep-learning","deep-learning-algorithms","deep-neural-networks","kereas","machine-learning","neural-networks","pattern-recognition","tensorflow"],"created_at":"2025-10-09T05:16:25.201Z","updated_at":"2026-04-11T21:34:44.891Z","avatar_url":"https://github.com/mbeps.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deep Discriminant Neural Network for Digit Classification\n\nThis project implements a deep neural network for classifying handwritten digits. Built with Keras, the model learns to recognise hand-written digits. The network combines convolutional layers with batch normalization and dropout to achieve robust classification performance. Through data augmentation and a carefully structured CNN architecture, it aims to generalise effectively to new handwriting styles.\n\n\n\n# Implementation\n\n## Network Architecture\nThe network follows a progressive deepening structure, with each block increasing in complexity to learn more sophisticated features.\n\n### Block 1\n- Two Conv2D layers (32 filters, 3×3 kernel) - Captures basic edges and shapes\n- BatchNormalisation after each Conv2D - Stabilises training\n- MaxPooling (2×2) - Reduces spatial dimensions and computational load\n- SpatialDropout2D (20%) - Prevents feature map co-adaptation\n\n### Block 2\n- Two Conv2D layers (96 filters, 3×3 kernel) - Learns intermediate-level patterns\n- BatchNormalisation after each Conv2D - Maintains consistent feature scaling\n- MaxPooling (2×2) - Further dimension reduction\n- SpatialDropout2D (20%) - Continues regularisation\n\n### Block 3\n- Two Conv2D layers (128 filters, 3×3 kernel, 'same' padding) - Identifies complex digit features\n- BatchNormalisation after each Conv2D - Normalises deeper features\n- MaxPooling (2×2) - Final spatial reduction\n- SpatialDropout2D (20%) - Ensures robust feature learning\n\n### Dense Layers\n- Flatten layer - Converts 2D features to 1D\n- Dense layer (1050 units) with L2 regularisation - Rich feature combination\n- BatchNormalisation - Stabilises deep network training\n- Dropout (50%) - Prevents overfitting\n- Output layer (10 units, softmax) - Produces digit probabilities\n\n## Data Augmentation\n\n### Static Augmentation (Albumentations)\n- ElasticTransform - Simulates natural handwriting deformations\n- GaussNoise - Adds resilience to image noise\n- CoarseDropout - Improves robustness to missing parts\n- RandomBrightnessContrast - Handles varying image qualities\n- Image Inversion - Adapts to different digit colours\n\n### Real-time Augmentation (ImageDataGenerator)\n- Rotation - Handles tilted handwriting\n- Width/Height shifts - Accounts for different digit positions\n- Zoom range - Manages varying digit sizes\n\n## Training Strategy\n\n### Optimisation\n- Adam optimiser with gradient clipping - Prevents explosive gradients\n- Initial learning rate: 1e-3 - Balanced between speed and stability\n- Batch size: 384 - Provides stable gradient estimates\n\n### Training Callbacks\n- Early Stopping - Prevents overfitting by monitoring validation loss\n- Model Checkpoint - Preserves best model during training\n- ReduceLROnPlateau - Adapts learning rate when progress plateaus\n\n### Regularisation Techniques\n- BatchNormalisation - Stabilises training throughout the network\n- SpatialDropout2D - Specifically designed for convolutional features\n- Standard Dropout - Prevents dense layer overfitting\n- L2 regularisation - Controls weight growth\n\n## Dataset Management\n- Multiple dataset combination - Increases training diversity\n- Image standardisation (28×28) - Ensures consistent input size\n- Value normalisation [0,1] - Stabilises network training\n- 90-10 split - Provides sufficient validation data\n- Fixed random seed - Ensures reproducible results\n\n\n\n# Tech Stack\n\n- [Python](https://www.python.org/) - Core programming language\n- [TensorFlow](https://www.tensorflow.org/) - Deep learning framework\n- [Keras](https://keras.io/) - Neural network API\n- [NumPy](https://numpy.org/) - Numerical computing library\n- [Albumentations](https://albumentations.ai/) - Image augmentation library\n- [OpenCV](https://opencv.org/) - Computer vision library\n- [PIL (Pillow)](https://python-pillow.org/) - Image processing library\n- [scikit-learn](https://scikit-learn.org/) - Machine learning utilities\n- [scikit-image](https://scikit-image.org/) - Image processing algorithms\n- [Matplotlib](https://matplotlib.org/) - Data visualization\n\n\n\n# Project Setup\n\nYou can set up this project using either Conda or Poetry.\n\n## Using Conda\n\nCreate a new conda environment:\n```bash\nconda create -n digit-classifier python=3.9\n```\n\nActivate the environment\n```bash\nconda activate digit-classifier\n```\n\nInstall dependencies\n```bash\nconda install tensorflow-gpu\nconda install numpy\nconda install -c conda-forge albumentations\nconda install -c conda-forge opencv\nconda install pillow\nconda install scikit-learn\nconda install scikit-image\nconda install matplotlib\n```\n\n## Using Poetry\n\nInstall all the project dependencies using:\n\n```bash\npoetry install\n```\n\n# Datasets\n\nBelow are the datasets that have been using for this project. \nDatasets marked with `*` need to be downloaded manually. \nKaggle not implemented. \n\n- [MNIST](https://www.kaggle.com/datasets/hojjatk/mnist-dataset)\n- *[EMNIST](https://www.kaggle.com/datasets/hojjatk/mnist-dataset)\n- *[USPS](https://www.kaggle.com/datasets/bistaumanga/usps-dataset)\n- *[Handwritten Digits Dataset (not in MNIST)](https://www.kaggle.com/datasets/jcprogjava/handwritten-digits-dataset-not-in-mnist)\n\nDownload these and extract them into a folder called `data` within the project directory.\nName the folders with the dataset as shown below:\n- `emnist` \u003c- EMNIST\n- `handwritten-digits-not-mnist`\n- `usps` \u003c- USPS\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbeps%2Fdeep-convolutional-neural-network-digits-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbeps%2Fdeep-convolutional-neural-network-digits-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbeps%2Fdeep-convolutional-neural-network-digits-classifier/lists"}