Skip to content

Rizame/openCLneural

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural Network for Handwritten Digit Recognition (C++ & OpenCL)

Overview

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.

Features

  • 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.

Installation & Setup

Prerequisites

Ensure your system meets the following requirements:

  1. C++ Compiler (C++20 support). You can use either: Visual Studio 2022+, MinGW-w64, etc.
  2. Install CMake (3.22 or newer) to configure and generate build files: https://cmake.org/download/
  3. GIT - If you don’t have Git, install: https://git-scm.com/downloads
  4. Install Vcpkg (Dependency Manager) Open PowerShell and run:
git clone https://github.com/microsoft/vcpkg.git  
cd vcpkg  
.\bootstrap-vcpkg.bat

Add Vcpkg to the system path (so you can use it globally):

[System.Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$PWD",[System.EnvironmentVariableTarget]::User)
  1. 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 openCLneural

Then try to compile and run!

Important note

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

Running the program

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!

About

parallel computation Neural Network for handwritten digit recognition(C++ & OpenCL)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors