{"id":25980514,"url":"https://github.com/naowalrahman/neural-network","last_synced_at":"2025-03-05T07:35:30.612Z","repository":{"id":258626819,"uuid":"874283502","full_name":"naowalrahman/neural-network","owner":"naowalrahman","description":"A neural network written in C++ with no external libraries.","archived":false,"fork":false,"pushed_at":"2025-01-02T16:45:49.000Z","size":431,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T17:42:44.411Z","etag":null,"topics":["backpropagation","cmake","cpp","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naowalrahman.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-10-17T14:56:07.000Z","updated_at":"2025-01-02T16:45:53.000Z","dependencies_parsed_at":"2024-11-15T15:37:41.933Z","dependency_job_id":"a47dc0ae-009e-4695-aa7d-e6dd7aa0004d","html_url":"https://github.com/naowalrahman/neural-network","commit_stats":null,"previous_names":["naowalrahman/neural-network"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naowalrahman%2Fneural-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naowalrahman%2Fneural-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naowalrahman%2Fneural-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naowalrahman%2Fneural-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naowalrahman","download_url":"https://codeload.github.com/naowalrahman/neural-network/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241989792,"owners_count":20053801,"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":["backpropagation","cmake","cpp","neural-network"],"created_at":"2025-03-05T07:35:30.035Z","updated_at":"2025-03-05T07:35:30.573Z","avatar_url":"https://github.com/naowalrahman.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neural Network\n\nThis is an attempt at implementing a neural network in purely C++ with no external libraries (only C++ STL). So far, I've completed the entire neural network structure, which uses [glorot uniform weight initialization](https://www.tensorflow.org/api_docs/python/tf/keras/initializers/GlorotUniform) and has multiple activation function support. Training is done via [backpropagation](https://en.wikipedia.org/wiki/Backpropagation) using [stochastic gradient descent](https://en.wikipedia.org/wiki/Stochastic_gradient_descent). \n\nI will document this project more extensively and give this README a more formal write-up once I finish implementation! For an explanation of backpropagation, see [backpropagation.md](./backpropagation.md).\n\n## XOR Performance\n\nThe following model achieves essentially 100% accuracy after training with $n = 1000$ random XOR samples, learning rate $\\eta = 0.3$, and 30 epochs.\n\n```txt\nLayer 1 (sigmoid):\n        Neuron 1: 1.7349 1.7117 [bias: -2.5654]\n        Neuron 2: -1.9663 -2.4515 [bias: 3.3307]\n        Neuron 3: -5.4436 -5.2983 [bias: 1.9498]\n        Neuron 4: 1.4488 0.54997 [bias: -0.98019]\nLayer 2 (sigmoid):\n        Neuron 1: 0.15555 0.86921 -1.9651 0.67768 [bias: 0.26103]\n        Neuron 2: 1.6101 -1.2021 2.1533 0.6044 [bias: -0.62403]\n        Neuron 3: 2.334 -3.3788 4.4697 1.6803 [bias: -0.53567]\n        Neuron 4: -2.0916 2.4694 -4.9442 -1.2314 [bias: 0.85497]\nLayer 3 (sigmoid):\n        Neuron 1: 1.8202 -3.0607 -6.5665 6.2184 [bias: 0.16765]\nAccuracy: 1.00000, loss: 0.00012206\n```\n\n## MNIST Performance\n\nThe model available at [mnist.txt](./mnist.txt) achieves 97.49% accuracy on the [MNIST handwritten digits dataset](https://yann.lecun.com/exdb/mnist/). It was trained with the [mean squared error](https://en.wikipedia.org/wiki/Mean_squared_error) loss function using a learning rate $\\eta = 0.1$ and 10 epochs.\n\n## Building\n\nEnsure `cmake` is installed on your system. For now, to build/run:\n\n```bash\ngit clone https://github.com/naowalrahman/neural-network.git\ncd neural-network\nchmod +x build.sh\n./build.sh Release\n```\n\nEdit `Main.cpp` to change the setup of the neural network :relaxed:.\n\n## To Do\n\n- [x] Feedforward ANN architecture\n- [x] Backpropagation algorithm to train models\n- [x] Train xor model\n- [x] MNIST classification model\n- [ ] Perspicuously document code\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaowalrahman%2Fneural-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaowalrahman%2Fneural-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaowalrahman%2Fneural-network/lists"}