A custom neural network implemented fully in C++ for recognizing handwritten digits, trained and tested on the Extended MNIST (EMNIST) dataset. It leverages OpenCL for parallel computation, achieving 90% accuracy without relying on external neural network libraries. The project focus was on memory management, utilization of performance boost via parallel programming and figuring out NN’s in general.
- Custom-built feedforward neural network with backpropagation.
- Fully implemented in C++
- OpenCL-based parallel computation for optimized performance.
- Trained and tested on the Extended MNIST (EMNIST) dataset.
- Efficient memory usage and buffer optimization to maximize speed.
Ensure your system meets the following requirements:
- C++ Compiler (C++20 support). You can use either: Visual Studio 2022+, MinGW-w64, etc.
- Install CMake (3.22 or newer) to configure and generate build files: https://cmake.org/download/
- GIT - If you don’t have Git, install: https://git-scm.com/downloads
- Install Vcpkg (Dependency Manager)
Open PowerShell and run:
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.batAdd Vcpkg to the system path (so you can use it globally):
[System.Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$PWD",[System.EnvironmentVariableTarget]::User)- Check if OpenCL is Installed.
Run the following command in PowerShell:
Get-Command OpenCL.dll | Format-List
If not installed, update your drivers manually via your GPU vendor, they should contain the openCL inside: 6. clone the repository:
git clone https://github.com/Rizame/openCLneural.git
cd openCLneuralThen try to compile and run!
the trainData folder is missing the main training file that is too large for github
(emnist-train-images-idx3-ubyte). This very file or all of them if needed can be downloaded from here:
https://www.kaggle.com/datasets/crawford/emnist?resource=download
After successful compilation you can run the program. This is basically an overview of its training process and continuous tuning, untill the end of training.
Each couple of seconds a "|" symbol will be printed which is an indicator of 10k processed images (training dataset has 240k). after all of them were processed, you will see this:
| | | | | | | | | | | | | | | | | | | | | | | | Done Epoch 0
percentage of guesses for epoch 0: n%
after the 3rd and 7th epochs a test dataset wil be processed to test the NN on unseen pictures.
By the end of program the accuracy has to go up to approximately 89-90%.
Thank you for attention!