Published
Edited
Aug 12, 2020
Insert cell
md`# Playing with Tensorflow.js`
Insert cell
Insert cell
{
const net = tf.sequential();
net.add(tf.layers.dense({
units: 2,
inputShape: [3],
activation: 'sigmoid'
}));
net.compile({
loss: 'meanSquaredError',
optimizer: 'sgd'
});

const xs = tf.tensor2d([
[0.03, 0.7, 0.5],
[0.16, 0.09, 0.2],
[0.5, 0.5, 1.0]
]);
const ys = tf.tensor2d([
[1, 0],
[0, 1],
[0, 1]
]);

await net.fit(xs, ys);
const xPredict = tf.tensor2d([
[1.0, 0.4, 0.0]
]);

const prediction = net.predict(xPredict);
prediction.print();
}
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