{"id":15493514,"url":"https://github.com/sinclairzx81/neuron","last_synced_at":"2025-04-22T20:12:23.045Z","repository":{"id":66034993,"uuid":"75782347","full_name":"sinclairzx81/neuron","owner":"sinclairzx81","description":"Neural network implemented in JavaScript","archived":false,"fork":false,"pushed_at":"2017-06-04T11:16:00.000Z","size":27,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T20:12:17.785Z","etag":null,"topics":["machine-learning","neural-network"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinclairzx81.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":"2016-12-07T00:00:52.000Z","updated_at":"2022-09-16T00:29:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"25ba716a-9385-457a-ae58-ba1a8aa86fb6","html_url":"https://github.com/sinclairzx81/neuron","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/sinclairzx81%2Fneuron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fneuron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fneuron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fneuron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/neuron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250316057,"owners_count":21410476,"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":["machine-learning","neural-network"],"created_at":"2024-10-02T08:07:39.994Z","updated_at":"2025-04-22T20:12:23.040Z","avatar_url":"https://github.com/sinclairzx81.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### neuron\n\nneural network implemented in javascript.\n\n### overview\n\nneuron is a javascript implementation of a multi layer perceptron network. The library allows one to quickly create fully connected feed forward networks and iteratively train them to approximate some desired output.\n\nneuron was written to allow for fast, interactive training in the browser for small networks. The library is offered as is for anyone who finds it useful, educational or just interesting.\n\n### building the project\n```\nnpm install typescript -g\nnpm install typescript-bundle -g\nnpm run build-test\nnode bin/test\n```\n\n### approximate xor\n\nthe following code sets up a network and iteratively trains it to approximate xor. This network is using tanh activation per each layer, with each layer given an additional bias neuron with a value of 1.0.\n\n```typescript\n//------------------------------------------------------\n//  network topology\n//\n//    0 0     \u003c--- input layer\n//  / /|\\ \\\n// 0 0 0 0 0  \u003c--- hidden layer 0\n//  \\ \\|/ /        \n//   0 0 0    \u003c--- hidden layer 1\n//    \\|/\n//     0      \u003c--- output layer\n//\n//------------------------------------------------------\nconst network = new neuron.Trainer(new neuron.Network([\n  new neuron.Tensor(2),\n  new neuron.Tensor(5, \"tanh\"),\n  new neuron.Tensor(3, \"tanh\"),\n  new neuron.Tensor(1, \"tanh\"),\n]))\n\n//------------------------------------------------------\n// train the network and report every 10,000 iterations.\n//------------------------------------------------------\nlet iteration = 0\nwhile(iteration \u003c 100000000) { // 100,000,000 iterations.\n\n  // train network against xor truth table. store mean error.\n  const error = (network.backward([0, 0], [0]) +\n                 network.backward([0, 1], [1]) +\n                 network.backward([1, 0], [1]) +\n                 network.backward([1, 1], [0])) / 4\n\n  // view approximation.\n  if(iteration % 10000 === 0) {\n    console.log(\"-\", iteration, error)\n    console.log(0, network.forward([0, 0]))\n    console.log(1, network.forward([0, 1]))\n    console.log(1, network.forward([1, 0]))\n    console.log(0, network.forward([1, 1]))\n  }\n  iteration++\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fneuron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Fneuron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fneuron/lists"}