Brain.js | |
Developer: | Open-source contributors |
Programming Language: | JavaScript, TypeScript |
Platform: | Node.js, Web browser |
Genre: | Neural Networking |
License: | MIT License |
Brain.js is a JavaScript library used for neural networking, which is released as free and open-source software under the MIT License.[1] It can be used in both the browser and Node.js backends.[2] [3]
Brain.js is most commonly used as a simple introduction to neural networking, as it hides complex mathematics and has a familiar modern JavaScript syntax.[4] [5] It is maintained by members of the Brain.js organization and open-source contributors.
Creating a feedforward neural network with backpropagation:
net.train([{ input: [0, 0], output: [0] },,,,]);
console.log(net.run([1, 0]));
Creating a recurrent neural network:
net.train([{ input: [0, 0], output: [0] },,,,]);
let output = net.run([0, 0]); // [0]output = net.run([0, 1]); // [1]output = net.run([1, 0]); // [1]output = net.run([1, 1]); // [0]
Train the neural network on RGB color contrast:
net.train([{ input: { r: 0.03, g: 0.7, b: 0.5 }, output: { black: 1 } }, { input: { r: 0.16, g: 0.09, b: 0.2 }, output: { white: 1 } }, { input: { r: 0.5, g: 0.5, b: 1.0 }, output: { white: 1 } } ]);
const output = net.run; //
console.log(output)