{"id":21340148,"url":"https://github.com/piorosen/implement-mnist","last_synced_at":"2026-04-12T12:38:49.945Z","repository":{"id":243316133,"uuid":"812080316","full_name":"Piorosen/implement-mnist","owner":"Piorosen","description":"Keras H5 to deploy on \"Pure C++\"","archived":false,"fork":false,"pushed_at":"2025-03-10T12:18:21.000Z","size":230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T02:47:51.944Z","etag":null,"topics":["cpp","docker","h5","keras","mnist","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Piorosen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-06-07T23:15:08.000Z","updated_at":"2025-03-10T12:18:23.000Z","dependencies_parsed_at":"2025-03-16T02:41:41.542Z","dependency_job_id":"bed7fccb-2d06-4375-a9d7-08a7ab23024e","html_url":"https://github.com/Piorosen/implement-mnist","commit_stats":null,"previous_names":["piorosen/implement-mnist"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Piorosen/implement-mnist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piorosen%2Fimplement-mnist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piorosen%2Fimplement-mnist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piorosen%2Fimplement-mnist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piorosen%2Fimplement-mnist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Piorosen","download_url":"https://codeload.github.com/Piorosen/implement-mnist/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Piorosen%2Fimplement-mnist/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263264640,"owners_count":23439247,"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","docker","h5","keras","mnist","tensorflow"],"created_at":"2024-11-22T00:49:25.832Z","updated_at":"2026-04-12T12:38:44.906Z","avatar_url":"https://github.com/Piorosen.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MNIST for Pure C++ from H5 model on Keras\n\u003cpre\u003e\n ______  __       __  _______   __        ________  __       __  ________  __    __  ________      \n/      |/  \\     /  |/       \\ /  |      /        |/  \\     /  |/        |/  \\  /  |/        |     \n$$$$$$/ $$  \\   /$$ |$$$$$$$  |$$ |      $$$$$$$$/ $$  \\   /$$ |$$$$$$$$/ $$  \\ $$ |$$$$$$$$/      \n  $$ |  $$$  \\ /$$$ |$$ |__$$ |$$ |      $$ |__    $$$  \\ /$$$ |$$ |__    $$$  \\$$ |   $$ |        \n  $$ |  $$$$  /$$$$ |$$    $$/ $$ |      $$    |   $$$$  /$$$$ |$$    |   $$$$  $$ |   $$ |        \n  $$ |  $$ $$ $$/$$ |$$$$$$$/  $$ |      $$$$$/    $$ $$ $$/$$ |$$$$$/    $$ $$ $$ |   $$ |        \n _$$ |_ $$ |$$$/ $$ |$$ |      $$ |_____ $$ |_____ $$ |$$$/ $$ |$$ |_____ $$ |$$$$ |   $$ |        \n/ $$   |$$ | $/  $$ |$$ |      $$       |$$       |$$ | $/  $$ |$$       |$$ | $$$ |   $$ |        \n$$$$$$/ $$/      $$/ $$/       $$$$$$$$/ $$$$$$$$/ $$/      $$/ $$$$$$$$/ $$/   $$/    $$/         \n\n /  \\     /  |/  \\  /  |/      | /      \\ /        |\n $$  \\   /$$ |$$  \\ $$ |$$$$$$/ /$$$$$$  |$$$$$$$$/ \n $$$  \\ /$$$ |$$$  \\$$ |  $$ |  $$ \\__$$/    $$ |   \n $$$$  /$$$$ |$$$$  $$ |  $$ |  $$      \\    $$ |   \n $$ $$ $$/$$ |$$ $$ $$ |  $$ |   $$$$$$  |   $$ |   \n $$ |$$$/ $$ |$$ |$$$$ | _$$ |_ /  \\__$$ |   $$ |   \n $$ | $/  $$ |$$ | $$$ |/ $$   |$$    $$/    $$ |   \n $$/      $$/ $$/   $$/ $$$$$$/  $$$$$$/     $$/                                \n\u003c/pre\u003e\n\n# How to build and Test?\n\n```sh\n# if you have docker or other container.\n$ git clone https://github.com/Piorosen/implement-mnist.git\n$ cd implement-mnist \u0026\u0026 ./scripts/run.sh --all\n```\n\n# How do run it?\n\n#### Docker Build Time: about 40m ~ 60m\n\n```sh\n$ git clone https://github.com/Piorosen/implement-mnist.git\n# Follow below code, if you want to without building image.\n$ docker pull ghcr.io/piorosen/implement-mnist:1.0.0\n# following below code, if you want to build by your hand \n$ docker build -t ghcr.io/piorosen/implement-mnist:1.0.0 .\n\n$ docker run --rm -it ghcr.io/piorosen/implement-mnist:1.0.0 /bin/ash\n$ (container)$ ./mnist # you can see a list of samples in containers.\n$ (container)$ ./mnist file 4-0059.txt # need to select file in list.\n# Output 4\n$ (container)$ cat ./tests/4-0059.txt # if you want to see data.\n```\n\n# How do work?\n\nThe repository is structured to dynamically generate C++ code to respond to changing weight files.\n\nTherefore, if you try to build C++ without the prerequisites being satisfied, you will get an error in `main.cpp` on line 7 because `#include ‘weights.hpp’` is missing\n\nTherefore, we need to first run `./scripts/model_reproducibility.dockerfile`, a docker file that trains the deep learning model and converts it to C++ code, and import `weight.hpp` separately with `docker cp $container_id:/sources/output/weights.hpp .`.\n\nAfter that, you can build the `mnist`.\n\nIf you are not familiar with `docker`, `Linux`, or `CMakeLists`, you can run `./resources/mnist.cpp`.\n\nThe parameter to run is `./mnist file ‘${something file}’`, or you can enter the image directly into the standard input pipeline with `./mnist input`.\n\n## Output\n\nDescription|Image\n:---:|:---:\nh5 keras to cpp|![](/resources/img2.png)\nresult of execute|![](/resources/img4.png)\n\n## AI Model\n\n```\n Input (1 x 28 x 28) -\u003e \n Average Pooling (1 x 7 x 7) -\u003e\n Flatten (1 x 49) -\u003e\n Dense (1 x 49 x 30) -\u003e\n ReLu (Activate) -\u003e\n Dense (1 x 30 x 10) -\u003e\n Output (1 x 10) \n```\n\n## For Reproducibility\n\nTo ensure the reproducibility of the software, I experimented with the random seed value set to 142 in tensorflow. Additionally, when running through docker (same as run.sh --all), it is automatically set to 142. If you reading this does not need reproducibility, please change the argument value in `./scripts/model_reproducibility.dockerfile`. \n\n# [Algorithm Competition](http://ascode.org/problem.php?id=1450)\n\n## Example of Input\n\ninput is too long text. [[HERE]](/resources/example_input.txt)\n![](/resources/img1.png)\n\n### Input Description\n\n```\n1. read first line, test case (\u003c 100)\n2. read next line, size 28 x 28 array all of them is float and the range of [0, 1].\n3. repeat 2.\n```\n\n## Example of Output\n\n`5`\n\n### Output Description\n\n```\nPredict number from input data.\n```\n\n## Limit in Judge System\n\n```\n1. Don't install other library.\n2. The length of source code that can be written is limited. (about 30kb)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiorosen%2Fimplement-mnist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiorosen%2Fimplement-mnist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiorosen%2Fimplement-mnist/lists"}