{"id":27334916,"url":"https://github.com/dmuth/neural-network","last_synced_at":"2025-04-12T14:46:38.298Z","repository":{"id":21229179,"uuid":"24544413","full_name":"dmuth/neural-network","owner":"dmuth","description":"A demo of how to use a Neural Network in Node.js","archived":false,"fork":false,"pushed_at":"2020-09-03T22:21:58.000Z","size":262,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-02T06:07:36.761Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmuth.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}},"created_at":"2014-09-27T22:39:42.000Z","updated_at":"2020-04-04T17:28:06.000Z","dependencies_parsed_at":"2022-09-06T03:12:12.472Z","dependency_job_id":null,"html_url":"https://github.com/dmuth/neural-network","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Fneural-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Fneural-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Fneural-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Fneural-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmuth","download_url":"https://codeload.github.com/dmuth/neural-network/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248585249,"owners_count":21128974,"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":[],"created_at":"2025-04-12T14:46:37.674Z","updated_at":"2025-04-12T14:46:38.290Z","avatar_url":"https://github.com/dmuth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neural Network\n\nA demo of how to use a Neural Network in Node.js\n\nI wanted to get into machine learning and decided that a good way to start would be to build a neural network that could be taugh the color red.\n\nAfter spending a few weeks trying to implement my own neural network, it was pointed out to me by friends that this is an awful idea, as the math is so complex that the chances of introducing a tiny error which renders the whole network unusable is near limitless.  Instead, I downloaded the excellent [Node Brain](https://github.com/harthur/brain) module which already implments a neural network.  If you haven't checked out Brain, please give it a try.\n\n\n## Prerequisites\n\nA relatively recent verison of Node.js.  You can find downloads for your platform [over here](http://nodejs.org/download/).\n\n\n## Usage\n\n- `docker run -p3000:3000 dmuth1/nodejs-neural-network`\n- Point your browser to [http://localhost:3000/](http://localhost:3000/)\n\n\n## Usage\n\nThe front page of the website will display a screen with a color, and a \"Yes\" and \"No\" button to tell the neural network whether the color is red or not.  After you answer at least once, you'll see two more buttons: \"Train Neural Network\" and \"Clear Neutral Network\".\n\nTry making about 10 guesses, then train the neural network.  Future page views will show a percentage bar which is the output of the neural network on that particular color.  Higher values mean a higher confidence that the color is red.  If you'd like to see the results of 1,000 guesses, click the \"Take Guesses\" button in the menu at the top of the screen.\n\n![Front page](./img/frontpage.png) \n\n\n## Hotkeys\n\n- **(H)** - Home\n- **(Y)** - Yes, the color is red\n- **(N)** - No, the color is not red\n- **(T)** - Train neural network\n- **(C)** - Clear neural network\n- **(G)** - Take 1,000 guesses on random colors\n- **(S)** - \"secret\" :-)  Create a random color that has the red value doubled and the blue and green values halved\n    - This is useful when getting false positives.  Keep mashing \"S\" until you get a color that's not red, \n    \tbut has a percentage higher than 10%. Then hit \"No\" and re-train the neural network.\n\n\n\n## Comments on neural networks in general\n\nWhile experimenting with this, I saw that a properly trained neural network could do a decent job of picking out the color red with as few as 10-20 gueses.  This is amazing.  Conversaly, a network fed poor quality data (lots of not-red colros) would still perform poorly despite having 50+ pieces of data in it.  As I learned, neureal networks are great at spotting **signals within a data set**.  If your data is poor quality and there is little signal, the output of your neural network will also be low quality.\n\n\n## Brain.js\n\nThe Node Brain module has been discontinued, in favor of \u003ca href=\"https://github.com/BrainJS/brain.js\"\u003ebrain.js\u003c/a\u003e.  I have no plans to use it at this time, however, as the install\nprocess is _insane_.  5 minutes plus of compiling, only to run into many problems on Alpine\nLinux with missing packages along the way.  My goal for build this app was to have it\ndeployed in a lightwight Docker container, and having to install dozens and dozens of packages\ngoes against that.  I may re-evaluate this decision in the future.\n\n\n## Development\n\n- `./bin/devel.sh` - Spin up a Docker Container with an interactive shell\n- `./bin/push.sh` - Push Docker container to Docker Hub\n\n\n# TODO\n\n- Migrate from Jade to Pug, but it seems to break the csrf module when I do that...\n- Clean up UI a little on main page, the buttons are kinda haphazard\n- Image rollover on guess page to enter data\n- /history page to get all training data from neural network and display original guess and current guess\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmuth%2Fneural-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmuth%2Fneural-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmuth%2Fneural-network/lists"}