Published
Edited
Feb 27, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// (viewof num1[0].options.selectedIndex = )
Insert cell
[num1, operator, num2]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable currentCanvas='num1'
Insert cell
{
// viewof num1[0].selectedIndex = 5;
// return viewof num1[0];
}
Insert cell
Insert cell
imgFormatter = (name, w = 32, h = 32) => {
const canvas = DOM.canvas(w, h);
const ctx = canvas.getContext('2d');

//// Setting Up ////////////
canvas.className = 'sketch-pad ' + name;
ctx.fillStyle = '#333';

//////////// Function ////
canvas.clear = () => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
};
canvas.copyFrom = img => {
canvas.clear();
ctx.drawImage(img, 0, 0, w, h);
};
return canvas;
}
Insert cell
Insert cell
Insert cell
{
// loadModel();
// return "load model if there is any";
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof num1 = {
const a = select(['0', "1", "2", "3", "4", '5', '6', '7', '8', '9']);
return a;
}
Insert cell
viewof num2 = select(['0',"1", "2", "3", "4",'5','6','7','8','9','0'])
Insert cell
viewof operator = select(["+", "-", "x", "÷"])
Insert cell
Insert cell
tf.tensor([2, 3, 4])
Insert cell
md`### import`
Insert cell
import { button, slider, select } from "@jashkenas/inputs"
Insert cell
tf = require('@tensorflow/tfjs')
Insert cell
knnClassifier = require("https://cdn.jsdelivr.net/npm/@tensorflow-models/knn-classifier")
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