├── .github └── FUNDING.yml ├── assets ├── training.png ├── validation.png └── digit_recognizer_icon_web.png ├── .idea ├── vcs.xml ├── misc.xml ├── modules.xml ├── digit_recognizer.iml └── workspace.xml ├── LICENSE ├── .gitignore ├── README.md └── digit_recognizer.ipynb /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: gsurma 2 | -------------------------------------------------------------------------------- /assets/training.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsurma/digit_recognizer/HEAD/assets/training.png -------------------------------------------------------------------------------- /assets/validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsurma/digit_recognizer/HEAD/assets/validation.png -------------------------------------------------------------------------------- /assets/digit_recognizer_icon_web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsurma/digit_recognizer/HEAD/assets/digit_recognizer_icon_web.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/digit_recognizer.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Greg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Digit Recognizer 6 | 7 | Python Jupyter Notebook with **Convolutional Neural Network** digit recognizer implemented in **Keras**. It's [Google Colab](https://colab.research.google.com/) ready. 8 | 9 | Part of the [Kaggle competition](https://www.kaggle.com/c/digit-recognizer). 10 | 11 | Submitted [Kernel](https://www.kaggle.com/greg115/digit-recognizer-keras-cnn-0-995) with 0.995 score. 12 | 13 | Check out corresponding Medium article: 14 | 15 | [Digit Recognizer - Introduction to Kaggle Competitions with Image Classification Task (0.995)](https://towardsdatascience.com/digit-recognizer-introduction-to-kaggle-competitions-with-image-classification-task-0-995-268fa2b90e13) 16 | 17 | ## Data 18 | 19 | **Dataset:** [MNIST Handwritten digits](https://www.kaggle.com/c/digit-recognizer/data) 20 | 21 | **Description:** Classification of handwritten digits, 10 classes (0-9). 22 | 23 | **Training:** 37.8k (0.9) images 24 | 25 | **Validation:** 4.2k (0.1) images 26 | 27 | **Testing:** 28k images 28 | 29 | ## Model 30 | 31 | _________________________________________________________________ 32 | Layer (type) Output Shape Param # 33 | ================================================================= 34 | conv2d_22 (Conv2D) (None, 28, 28, 32) 832 35 | _________________________________________________________________ 36 | conv2d_23 (Conv2D) (None, 28, 28, 32) 25632 37 | _________________________________________________________________ 38 | max_pooling2d_11 (MaxPooling (None, 14, 14, 32) 0 39 | _________________________________________________________________ 40 | dropout_7 (Dropout) (None, 14, 14, 32) 0 41 | _________________________________________________________________ 42 | conv2d_24 (Conv2D) (None, 14, 14, 64) 18496 43 | _________________________________________________________________ 44 | conv2d_25 (Conv2D) (None, 14, 14, 64) 36928 45 | _________________________________________________________________ 46 | max_pooling2d_12 (MaxPooling (None, 7, 7, 64) 0 47 | _________________________________________________________________ 48 | dropout_8 (Dropout) (None, 7, 7, 64) 0 49 | _________________________________________________________________ 50 | flatten_4 (Flatten) (None, 3136) 0 51 | _________________________________________________________________ 52 | dense_8 (Dense) (None, 8192) 25698304 53 | _________________________________________________________________ 54 | dropout_9 (Dropout) (None, 8192) 0 55 | _________________________________________________________________ 56 | dense_9 (Dense) (None, 2048) 16779264 57 | _________________________________________________________________ 58 | dropout_10 (Dropout) (None, 2048) 0 59 | _________________________________________________________________ 60 | dense_10 (Dense) (None, 10) 20490 61 | ================================================================= 62 | Total params: 42,579,946 63 | Trainable params: 42,579,946 64 | Non-trainable params: 0 65 | _________________________________________________________________ 66 | 67 | ## Training 68 | 69 |

70 | 71 |

72 | 73 |

74 | 75 |

76 | 77 | ## Results 78 | 79 | Kaggle score: **0.995** 80 | 81 | ## Author 82 | 83 | **Greg (Grzegorz) Surma** 84 | 85 | [**PORTFOLIO**](https://gsurma.github.io) 86 | 87 | [**GITHUB**](https://github.com/gsurma) 88 | 89 | [**BLOG**](https://medium.com/@gsurma) 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 37 | 38 | 39 | 40 | 41 | true 42 | DEFINITION_ORDER 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |