{"id":17798697,"url":"https://github.com/ameobea/neural-network-from-scratch","last_synced_at":"2025-04-05T17:08:20.435Z","repository":{"id":40525631,"uuid":"390865764","full_name":"Ameobea/neural-network-from-scratch","owner":"Ameobea","description":"A neural network library written from scratch in Rust along with a web-based application for building + training neural networks + visualizing their outputs","archived":false,"fork":false,"pushed_at":"2024-10-06T05:55:23.000Z","size":1814,"stargazers_count":133,"open_issues_count":0,"forks_count":12,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T16:09:27.753Z","etag":null,"topics":["backpropagation","data-visualization","gradient-descent","neural-network","neural-networks","neural-networks-from-scratch","rust","simd","wasm","wasm-bindgen","webassembly"],"latest_commit_sha":null,"homepage":"https://nn.ameo.dev","language":"Rust","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/Ameobea.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":"2021-07-29T22:33:07.000Z","updated_at":"2025-02-22T12:34:25.000Z","dependencies_parsed_at":"2024-11-24T06:03:08.395Z","dependency_job_id":null,"html_url":"https://github.com/Ameobea/neural-network-from-scratch","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"7473699ddc5cfe415cdc0c26a076499a36db1b24"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ameobea%2Fneural-network-from-scratch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ameobea%2Fneural-network-from-scratch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ameobea%2Fneural-network-from-scratch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ameobea%2Fneural-network-from-scratch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ameobea","download_url":"https://codeload.github.com/Ameobea/neural-network-from-scratch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"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","data-visualization","gradient-descent","neural-network","neural-networks","neural-networks-from-scratch","rust","simd","wasm","wasm-bindgen","webassembly"],"created_at":"2024-10-27T12:01:17.930Z","updated_at":"2025-04-05T17:08:20.397Z","avatar_url":"https://github.com/Ameobea.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neural Network from Scratch in the Browser\n\n![A screenshot of the neural network web application itself which shows the full UI, network response visualization, and cost plot](https://ameo.link/u/97k.png)\n\n**Try it yourself**: \u003chttps://nn-viz.ameo.design\u003e\n\n## About\n\nThe goal of this project was to understand neural networks better by building them from the ground up.  I wanted to be able to see dynamically how choosing different network architectures + training parameters affects network performance and how well networks can various functions.\n\nIt allows users to define a neural network infrastructure by adding hidden layers, picking neuron counts + activation function types, and setting training parameters like learning rate.  The network then learns one of a variety of selectable target functions from which examples are randomly sampled to train it.\n\nThe \"response\" of the network over the entire range of possible inputs is then plotted as a 3D surface along with the target function to show how well the network has learned.\n\n### Technical Details\n\nThe neural network implementation itself is built in Rust and compiled to WebAssembly using Wasm SIMD to accelerate training.\n\nThe training takes place on a dedicated thread by using a web worker and the excellent [Comlink](https://github.com/GoogleChromeLabs/comlink) library to communicate between the main/render thread and the training thread.\n\nAll the charts + visualizations are created using the excellent [echarts](https://echarts.apache.org/en/index.html) library.\n\nThe UI is created using [react-control-panel](https://github.com/ameobea/react-control-panel) which is a React port of the excellent [`control-panel`](https://github.com/freeman-lab/control-panel) library for easy GUI creation.\n\n## Building + Developing\n\nYou'll need Rust nightly with WebAssembly support.  You can install Rust via easily via rustup: \u003chttps://rustup.rs/\u003e\n\nThen, add the latest nightly toolchain + switch to it:\n\n`rustup default nightly`\n\nAdd WebAssembly support:\n\n`rustup target add wasm32-unknown-unknown`\n\nThis project uses the [`just` command runner](https://github.com/casey/just) to simplify many tasks.  Install it with:\n\n`cargo install just`.\n\nYou'll also need [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen):\n\n`cargo install wasm-bindgen --version=0.2.74`\n\nYou'll need to install the `wasm-opt` tool from [`binaryen`](https://github.com/WebAssembly/binaryen).  You can download the executable from the Releases section on Github or build it yourself with CMake.\n\nThen, you'll need tools for the web stack.  I use yarn for node package management, and you can either update the `Justfile` to change `yarn` to `npm` or install yarn 1.0 from here: \u003chttps://classic.yarnpkg.com/en/docs/install/\u003e\n\nThat should be all you need!  To start the webpack dev server for hot-reloading and development, execute `just run` in the project root.\n\nTo create a release build, execute `just build` in the project root.  That will produce a fully functional static website in the `dist` directory.\n\n## References\n\nThis is a list of some of the resources that I made use of while learning about neural networks and building this project:\n\n* \u003chttps://machinelearningmastery.com/implement-backpropagation-algorithm-scratch-python/\u003e\n* \u003chttps://mlfromscratch.com/neural-networks-explained/#/\u003e\n* [MIT 6.S094: Recurrent Neural Networks for Steering Through Time](https://www.youtube.com/watch?v=nFTQ7kHQWtc\u0026t=475s) \u003c- Really helped me break through the wall of understanding some of the core concepts behind neural networks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fameobea%2Fneural-network-from-scratch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fameobea%2Fneural-network-from-scratch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fameobea%2Fneural-network-from-scratch/lists"}