Skip to content

alirostami1/handwriting-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handwriting Recognition in C++

Welcome to the Handwriting Recognition project, an educational initiative to explore neural networks using the MNIST dataset in modern C++. This project demonstrates memory-safe programming practices and leverages state-of-the-art C++ features. For an in-depth look at the underlying memory models and safety mechanisms, check out my blog post on C++ memory models.

Table of Contents

Overview

This project aims to:

  • Familiarize with neural networks and handwriting recognition.
  • Utilize modern C++ for enhanced performance and memory safety.
  • Provide a modular and maintainable codebase that leverages best practices in C++.

The project uses the popular MNIST dataset to train and test a neural network that recognizes handwritten digits.

Features

  • Modern C++ Implementation: Built with modern C++ standards for robust and efficient code.
  • Memory Safety: Focus on secure memory management and performance.
  • Configurable Training: Easily adjustable parameters via a configuration file.
  • OpenMP Support: Optional OpenMP support for enhanced parallelism during training.

Build Instructions

This project uses CMake as its build system. Follow these steps to build the project:

  1. Generate the Build Files

    cmake -S . -B build
  2. Available Build Parameters

    • DCMAKE_BUILD_TYPE: Set the build type. Options: Debug or Release (default: Release).
    • DENABLE_VERBOSE: Enable verbose logging. Options: ON or OFF (default: OFF).
    • DENABLE_OPENMP: Enable OpenMP support for parallel processing. Options: ON or OFF (default: ON).
  3. Compile the Project

    cmake --build build

Running the Application

To train and test the neural network, execute the compiled binary and provide a configuration file as an argument:

build/neural_network input.example.config

The configuration file specifies training parameters, paths to datasets, and other essential settings.

Configuration

Below is an example configuration file (input.example.config):

num_epochs = 5
batch_size = 100
hidden_size = 500
learning_rate = 1E-3
rel_path_train_images = mnist-datasets/train-images.idx3-ubyte
rel_path_train_labels = mnist-datasets/train-labels.idx1-ubyte
rel_path_test_images = mnist-datasets/t10k-images.idx3-ubyte
rel_path_test_labels = mnist-datasets/t10k-labels.idx1-ubyte
rel_path_log_file = log_predictions.txt

Feel free to adjust these parameters to experiment with different training configurations.

Contributing

Contributions are welcome! If you have suggestions or improvements, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes with clear commit messages.
  4. Open a pull request detailing your changes and the reasoning behind them.

License

This project is open-source. Please refer to the LICENSE file for more details.

About

A modern C++ project for handwriting recognition using the MNIST dataset

Resources

License

Stars

Watchers

Forks

Contributors