{"id":29201116,"url":"https://github.com/raphaelsenn/neural-network-autograd-cpp","last_synced_at":"2026-02-04T00:05:06.305Z","repository":{"id":247048563,"uuid":"824860445","full_name":"raphaelsenn/neural-network-autograd-cpp","owner":"raphaelsenn","description":"A simple feed forward neural network (with autograd capabilities) in C++ (no external libarys).","archived":false,"fork":false,"pushed_at":"2024-08-23T09:24:07.000Z","size":4166,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T00:42:20.750Z","etag":null,"topics":["ai","algorithms","artificial-intelligence","artificial-neural-networks","backpropagation","cplusplus","deep-learning","machine-learning","machine-learning-algorithms","neural-network"],"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/raphaelsenn.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-07-06T06:34:31.000Z","updated_at":"2025-02-21T11:13:29.000Z","dependencies_parsed_at":"2024-08-23T10:10:15.597Z","dependency_job_id":null,"html_url":"https://github.com/raphaelsenn/neural-network-autograd-cpp","commit_stats":null,"previous_names":["raphsenn/neural-network-autograd-cpp","raphaelsenn/neural-network-autograd-cpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/raphaelsenn/neural-network-autograd-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelsenn%2Fneural-network-autograd-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelsenn%2Fneural-network-autograd-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelsenn%2Fneural-network-autograd-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelsenn%2Fneural-network-autograd-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raphaelsenn","download_url":"https://codeload.github.com/raphaelsenn/neural-network-autograd-cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphaelsenn%2Fneural-network-autograd-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29062485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T23:14:54.203Z","status":"ssl_error","status_checked_at":"2026-02-03T23:14:50.873Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ai","algorithms","artificial-intelligence","artificial-neural-networks","backpropagation","cplusplus","deep-learning","machine-learning","machine-learning-algorithms","neural-network"],"created_at":"2025-07-02T11:31:33.954Z","updated_at":"2026-02-04T00:05:06.290Z","avatar_url":"https://github.com/raphaelsenn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# neural-network-autograd-cpp\nA simple neural network (with autograd!) in C++ (no external libarys like Eigen).\n\n## Usage\n\n### Creating a NeuralNetwork\n\n#### OR-Gate problem\n\n```cpp\n#include \"./NeuralNetwork.h\"\n#include \u003ciostream\u003e\n\nint main() {\n    {\n    // This neural network learns how to solve the OR-Gate problem.\n\n    // Training data. \n    Matrix\u003cfloat\u003e X_train =\n        std::vector\u003cstd::vector\u003cfloat\u003e\u003e({{0, 0}, {0, 1}, {1, 0}, {1, 1}});\n\n    Matrix\u003cfloat\u003e y_train_or =\n        std::vector\u003cstd::vector\u003cfloat\u003e\u003e({{0}, {1}, {1}, {1}});\n    \n    // Create the neural net.\n    // w1= 2 x 1, activation sigmoid. \n    NeuralNetwork\u003cfloat\u003e orGate(std::vector\u003csize_t\u003e({2, 1}),\n                                std::vector\u003cActivation\u003e({Activation::sigmoid}),\n                                0.1f, InitState::RANDOM);\n    orGate.train(X_train, y_train_or, 0.1f, 10000, false);\n    orGate.act(X_train).print();\n    }\n}\n```\n##### Output\n\n```shell\nmatrix([[0.0205522],\n[0.989617],\n[0.989618],\n[0.999998]])\n```\n\n#### XOR-Gate problem\n\n```cpp\n#include \"./NeuralNetwork.h\"\n#include \u003ciostream\u003e\n\nint main() {\n    {\n    // This neural network learns how to solve the XOR-Gate problem.\n    \n    // Training data. \n    Matrix\u003cfloat\u003e X_train =\n        std::vector\u003cstd::vector\u003cfloat\u003e\u003e({{0, 0}, {0, 1}, {1, 0}, {1, 1}}); \n    Matrix\u003cfloat\u003e y_train =\n        std::vector\u003cstd::vector\u003cfloat\u003e\u003e({{0}, {1}, {1}, {0}});\n\n\n    // Create the neural net.\n    // w1 = 2 x 4 with relu\n    // w2 = 4 x 1 with sigmoid\n    NeuralNetwork\u003cfloat\u003e xorGate(\n        std::vector\u003csize_t\u003e({2, 4, 1}),\n        std::vector\u003cActivation\u003e({Activation::relu, Activation::sigmoid}),\n        0.88f, InitState::RANDOM);\n\n    xorGate.train(X_train, y_train_xor, 0.1f, 10000, false);\n    xorGate.act(X_train).print();\n    }\n}\n```\n###### The neural network would look like this.\n\n![image](./res/neuralnet.png)\n\n##### Output\n\n```shell\nmatrix([[0.0145205],\n[0.979574],\n[0.979554],\n[0.0177436]])\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphaelsenn%2Fneural-network-autograd-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphaelsenn%2Fneural-network-autograd-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphaelsenn%2Fneural-network-autograd-cpp/lists"}