{"id":29516214,"url":"https://github.com/anthonyray/littlebrain","last_synced_at":"2025-07-16T14:42:18.754Z","repository":{"id":23926123,"uuid":"27306839","full_name":"anthonyray/littlebrain","owner":"anthonyray","description":"Multi-layer Neural Network in Javascript","archived":false,"fork":false,"pushed_at":"2015-01-09T17:21:11.000Z","size":780,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-15T09:15:23.623Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/anthonyray.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}},"created_at":"2014-11-29T15:53:28.000Z","updated_at":"2023-05-07T18:06:29.000Z","dependencies_parsed_at":"2022-07-10T10:20:36.003Z","dependency_job_id":null,"html_url":"https://github.com/anthonyray/littlebrain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/anthonyray/littlebrain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyray%2Flittlebrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyray%2Flittlebrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyray%2Flittlebrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyray%2Flittlebrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonyray","download_url":"https://codeload.github.com/anthonyray/littlebrain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyray%2Flittlebrain/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265518953,"owners_count":23781051,"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-07-16T14:42:07.899Z","updated_at":"2025-07-16T14:42:18.744Z","avatar_url":"https://github.com/anthonyray.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LittleBrain\n\nA simple implementation of a multi-layer neural network using backpropagation algorithm in javascript.\nSee this library in action [here](http://reinette.io/littlebrain) !\n## API\n\nTo instantiate a new neural network, just require the network class in the library.\n\n```javascript\nvar neural = require('../lib/network')\nvar network = new neural.Network()\n```\n\nNext, you can add layers to your neural network thanks to the ```addLayer``` method.\nThis method takes two parameters :\n- numNeurons : number of neurons to create for the given layer\n- numInputs : optional, determines the number of input for each given neurons in the layer. If this argument is not specified, the number of input will be the number of neurons from the previous layer.  \n\nFor instance :\n```javascript\nnetwork.addLayer(10, 20) // Hidden layer, 10 neurons, 20 inputs\nnetwork.addLayer(2)      // Output layer, 2 neurons\n```\n\nIt is now time to train the neural network with training data. The training method uses the backpropagation algorithm. Careful ! this method can take time ...\n\nTwo stop conditions are implemented :\n\n- The mean square error is below a threshold (errThreshold)\n- We iterated over 100 000 times\n\n```javascript\nnetwork.train([\n  // inputs   outputs\n  [  zero,    [0, 0]  ],\n  [  one,     [0, 1]  ],\n  [  two,     [1, 0]  ],\n  [  three,   [1, 1]  ]\n  ]);\n```\n\nOnce the neural network is trained, you can pass it input data and get the output with the process method :\n\n```javascript\nvar outputs = network.process(zero);\n```\n\n## Example\nI made a website that uses this neural network to predict a drawn digit between 0 and 3. You can check it out [here](http://reinette.io/littlebrain) !\n\n## Serialization\nInstead of training the neural network everytime, I added a function to serialize/deserialize the neural network for later use.\n\n```javascript\nnetwork.serialize();\n\n// The deserialization needs to know how many inputs the neural network has. This is the first argument of the method.\nnetwork.deserialize(20,data);\n```\n\n## About\nFeel free to contribute !\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonyray%2Flittlebrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonyray%2Flittlebrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonyray%2Flittlebrain/lists"}