Published
Edited
Dec 12, 2017
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
net = new brain.NeuralNetwork()
Insert cell
randomColor = () => ({ r: Math.random(), g: Math.random(), b: Math.random() })
Insert cell
colorToRgb = color => `rgb(${~~(color.r * 255)}, ${~~(color.g * 255)}, ${~~(color.b * 255)})`
Insert cell
Insert cell
ui = {
let styles = `width:49%;height:100px;line-height:100px;text-align:center;display:inline-block;`;
let data = [];
while (true) {
let testColor = randomColor();
let ui = html`<div><div id='black' style='background:${colorToRgb(testColor)};${styles}'>This one</div><div id='white' style='color:white;background:${colorToRgb(testColor)};${styles}'>This one</div></div>`;
yield ui;
yield new Promise(resolve => {
ui.childNodes[0].onclick = () => {
data.push({ input: testColor, output: { black: 1 }});
net.train(data);
resolve();
};
ui.childNodes[1].onclick = () => {
data.push({ input: testColor, output: { white: 1 }});
net.train(data);
resolve();
};
})
}
}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more