Skip to content

Instantly share code, notes, and snippets.

@sararob
Created March 30, 2018 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sararob/4839f5b65e7076a090fed9efadb830be to your computer and use it in GitHub Desktop.
Save sararob/4839f5b65e7076a090fed9efadb830be to your computer and use it in GitHub Desktop.
Defining a TensorFlow.js model, see this blog post for details: https://medium.com/tensorflow/introducing-tensorflow-js-machine-learning-in-javascript-bf3eab376db
import * as tf from ‘@tensorflow/tfjs’;
const model = tf.sequential();
model.add(tf.layers.dense({inputShape: [4], units: 100}));
model.add(tf.layers.dense({units: 4}));
model.compile({loss: ‘categoricalCrossentropy’, optimizer: ‘sgd’});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment