Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<script src="//unpkg.com/brain.js"></script>
<body>
<h1>Deep Learning with brain.js</h1>
<div id="demo"></div>
<script>
// Create a Neural Network
const net = new brain.NeuralNetwork();
// Train the Network with 4 input objects
net.train([
// White RGB(255, 255, 255)
{input:[255/255, 255/255, 255/255], output:{light:1}},
// Lightgrey (192,192,192)
{input:[192/255, 192/255, 192/255], output:{light:1}},
// Darkgrey (64, 64, 64)
{ input:[65/255, 65/255, 65/255], output:{dark:1}},
// Black (0, 0, 0)
{ input:[0, 0, 0], output:{dark:1}},
]);
// What is the expected output of Dark Blue (0, 0, 128)?
let result = net.run([0, 0, 128/255]);
// Display the probability of "dark" and "light"
document.getElementById("demo").innerHTML =
"Dark: " + result["dark"] + "<br>" + "Light: " + result["light"];
</script>
</body>
</html>