Giter VIP home page Giter VIP logo

ameobea / neural-network-from-scratch Goto Github PK

View Code? Open in Web Editor NEW
117.0 6.0 11.0 1.73 MB

A neural network library written from scratch in Rust along with a web-based application for building + training neural networks + visualizing their outputs

Home Page: https://nn.ameo.dev

Rust 48.73% CSS 2.79% TypeScript 46.33% Handlebars 1.23% JavaScript 0.91%
neural-network rust webassembly gradient-descent backpropagation neural-networks neural-networks-from-scratch wasm-bindgen wasm simd

neural-network-from-scratch's Introduction

Neural Network from Scratch in the Browser

A screenshot of the neural network web application itself which shows the full UI, network response visualization, and cost plot

Try it yourself: https://nn-viz.ameo.design

About

The 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.

It 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.

The "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.

Technical Details

The neural network implementation itself is built in Rust and compiled to WebAssembly using Wasm SIMD to accelerate training.

The training takes place on a dedicated thread by using a web worker and the excellent Comlink library to communicate between the main/render thread and the training thread.

All the charts + visualizations are created using the excellent echarts library.

The UI is created using react-control-panel which is a React port of the excellent control-panel library for easy GUI creation.

Building + Developing

You'll need Rust nightly with WebAssembly support. You can install Rust via easily via rustup: https://rustup.rs/

Then, add the latest nightly toolchain + switch to it:

rustup default nightly

Add WebAssembly support:

rustup target add wasm32-unknown-unknown

This project uses the just command runner to simplify many tasks. Install it with:

cargo install just.

You'll also need wasm-bindgen:

cargo install wasm-bindgen --version=0.2.74

You'll need to install the wasm-opt tool from binaryen. You can download the executable from the Releases section on Github or build it yourself with CMake.

Then, 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: https://classic.yarnpkg.com/en/docs/install/

That should be all you need! To start the webpack dev server for hot-reloading and development, execute just run in the project root.

To create a release build, execute just build in the project root. That will produce a fully functional static website in the dist directory.

References

This is a list of some of the resources that I made use of while learning about neural networks and building this project:

neural-network-from-scratch's People

Contributors

ameobea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.