Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

js neural networks and classifiers

branch: crossvalidate

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 LICENSE
Octocat-spinner-32 package.json


brain is a javascript neural network library. An example, training the XOR bitwise operation: var net = new brain.NeuralNetwork(); net.train([{input: [0, 0], output: [0]}, {input: [0, 1], output: [1]}, {input: [1, 0], output: [1]}, {input: [1, 1], output: [0]}]);

var output =[1, 0]);

The output will be [0.987] or something close like that. There's no reason to use a neural network to figure out XOR, but it's a small example (-:

using in the browser

Download the latest brain.js. If you can you should train the network offline (or on a Worker) and use the toFunction() or toJSON() options to plug the trained network in to your website.

using as a commonJS package

To use this as a commonJS package (node/narwhal) checkout or download the code, it is a commonJS package. If you have node and npm you can:

npm install brain@latest


var brain = require("brain");
var net = new brain.NeuralNetwork();

If you didn't install with npm, you can specify the path to the brain.js file, like require("./lib/brain").



Running the tests requires node.js:

node test/runtests.js


There are many things to be done: wiki todo list

Something went wrong with that request. Please try again.