{"id":21457889,"url":"https://github.com/jackkimmins/alpha-digit","last_synced_at":"2026-05-10T02:14:27.208Z","repository":{"id":264204814,"uuid":"885940442","full_name":"jackkimmins/Alpha-Digit","owner":"jackkimmins","description":"C++ Feedforward Neural Network w/ WASM Inferencing \u0026 Vue3 UI for MNIST Digit Classification","archived":false,"fork":false,"pushed_at":"2024-11-22T15:38:21.000Z","size":6419,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T04:15:10.905Z","etag":null,"topics":["cpp","emscripten","feedforward-neural-network","gradient-descent","machine-learning","mnist","vue3","wasm"],"latest_commit_sha":null,"homepage":"https://alpha-digit.appserver.uk","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackkimmins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-11-09T19:45:22.000Z","updated_at":"2024-11-22T15:38:24.000Z","dependencies_parsed_at":"2024-11-22T16:43:09.177Z","dependency_job_id":null,"html_url":"https://github.com/jackkimmins/Alpha-Digit","commit_stats":null,"previous_names":["jackkimmins/alpha-digit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jackkimmins/Alpha-Digit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackkimmins%2FAlpha-Digit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackkimmins%2FAlpha-Digit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackkimmins%2FAlpha-Digit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackkimmins%2FAlpha-Digit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackkimmins","download_url":"https://codeload.github.com/jackkimmins/Alpha-Digit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackkimmins%2FAlpha-Digit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261978910,"owners_count":23239417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cpp","emscripten","feedforward-neural-network","gradient-descent","machine-learning","mnist","vue3","wasm"],"created_at":"2024-11-23T06:16:08.969Z","updated_at":"2026-05-10T02:14:27.174Z","avatar_url":"https://github.com/jackkimmins.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![AlphaDigit Project Logo](https://github.com/jackkimmins/Alpha-Digit/blob/main/web/favicons/apple-icon-180x180.png)\n\n# Alpha-Digit\n\nThis project implements a fully connected [Feedforward Neural Network (FNN)](https://en.wikipedia.org/wiki/Feedforward_neural_network) from scratch in C++ for digit classification on the [MNIST dataset](https://en.wikipedia.org/wiki/MNIST_database) - this is a continuation from my [previous attempt](https://github.com/jackkimmins/SimpleNN) at this. The network is optimised for web deployment through [WebAssembly (WASM)](https://webassembly.org/), allowing it to perform inference in the browser.\n\nmain_train.cpp:\n```cpp\n#include \"Database.h\"\n#include \"NeuralNetwork.h\"\n#include \"Evaluator.h\"\n#include \u003ciostream\u003e\n#include \u003cfilesystem\u003e\n\nconst unsigned int seed = 42;\n\nint main()\n{\n    std::string dataset_path = \"datasets/mnist_test.csv\";\n    std::string model_save_path = \"models/best_model.dat\";\n    std::filesystem::create_directories(\"models\");\n\n    // Load and split dataset into train, validation, and test sets\n    Database db(dataset_path, seed);\n    db.split_data(0.8);\n\n    // -=- Network Architecture -=- //\n    // Input: 784 (28x28 pixels)\n    // Hidden Layers: 128, 64\n    // Output: 10 (Digits 0-9)\n\n    int input_size = 784;\n    std::vector\u003cint\u003e hidden_layers = { 128, 64 };\n    int output_size = 10;\n\n    // -=- Network Architecture -=- //\n\n    // Init Neural Network\n    NeuralNetwork nn(input_size, hidden_layers, output_size, seed);\n\n    // Training Hyperparameters\n    int epochs = 50;\n    int batch_size = 32;\n    double initial_learning_rate = 0.001;\n    double decay_rate = 0.9;\n    int decay_steps = 10;\n    bool early_stopping = true;\n    int patience = 5;\n\n    // Train the neural network\n    nn.train(db.get_train_data(),\n             db.get_validation_data(),\n             epochs,\n             batch_size,\n             initial_learning_rate,\n             decay_rate,\n             decay_steps,\n             early_stopping,\n             patience);\n\n    // Save the trained model\n    nn.save_model(model_save_path);\n    std::cout \u003c\u003c \"Model saved to \" \u003c\u003c model_save_path \u003c\u003c std::endl;\n\n    // Evaluate on test data after training\n    Evaluator evaluator(nn, db.get_test_data());\n    evaluator.evaluate();\n\n    return 0;\n}\n```\n\n## Project Details\n- Feedforward Neural Network (FNN)\n- Mini-Batch Gradient Descent w/ Adam Optimiser\n- Early Stopping and Learning Rate Scheduling\n- Multithreaded Training\n- WebAssembly Module for Inferencing\n- Vue3 UI\n- High Classification Accuracy of **98.19%** *(on 7,000 image validation slice of the MNIST dataset)*\n\n\n## Requirements\n- C++20 or Later\n- g++\n- Emscripten (for WASM compilation)\n\n## Demo\nThe demo site can be found at the following link:\n[https://alpha-digit.appserver.uk/](https://alpha-digit.appserver.uk/)\n\n## Mentions and Thanks\nSpecial thanks to the following resources and individuals whose work greatly inspired and supported this project:\n\n- [3Blue1Brown](https://www.youtube.com/@3blue1brown) - For the amazing video demonstrations and intuitive explanations of neural networks, can't recommend his videos enough! 😇\n- Research Paper by Diederik P. Kingma and Jimmy Ba: Adam: A Method for Stochastic Optimization ([arXiv:1412.6980](https://arxiv.org/abs/1412.6980)).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackkimmins%2Falpha-digit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackkimmins%2Falpha-digit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackkimmins%2Falpha-digit/lists"}