Published
Edited
Feb 18, 2018
1 fork
14 stars
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
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
model = {
const g = new dl.Graph();
let node;

const inputTensor = g.placeholder('input', [features.length]);
const labelTensor = g.placeholder('label', [labels.length]);

const weight0 = g.variable('weight', dl.Array2D.randNormal([numNeuronsInHiddenLayer, features.length]));
const bias0 = g.variable('bias', dl.Array1D.randNormal([numNeuronsInHiddenLayer]));
node = g.matmul(weight0, inputTensor);
node = g.add(node, bias0);
node = g.sigmoid(node);

const weight1 = g.variable('weight', dl.Array2D.randNormal([labels.length, numNeuronsInHiddenLayer]));
const bias1 = g.variable('bias', dl.Array1D.randNormal([labels.length]));
node = g.matmul(weight1, node);
node = g.add(node, bias1);
node = g.sigmoid(node);

const outputTensor = g.softmax(node);
const costTensor = g.softmaxCrossEntropyCost(node, labelTensor);
return {
graph: g,
inputTensor: inputTensor, labelTensor: labelTensor, outputTensor: outputTensor, costTensor: costTensor
};
}
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
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more