-
Notifications
You must be signed in to change notification settings - Fork 41
Tensorflow.js
Don Jayamanne edited this page Sep 1, 2021
·
8 revisions
TensorFlow.js is a JavaScript Library for training and deploying machine learning models in the browser and in Node.js.
- Render plots/tables using the tfjs-vis API (from within node.js)
- Not all of the tfjs-vis is supported.
- E.g. embedding images into the tfjs-vis Visor is not yet supported.
- Please file issues for missing/broken features.
Scatter plot
Model Summary
Scatter plot
2. Train a model in Tensorflow.js and view the Tensorboard in VS Code
- Train a model and generate data using the sample provided here
- Create two cell as follows
import * as tf from '@tensorflow/tfjs-node'
import * as path from 'path';
// Constructor a toy multilayer-perceptron regressor for demo purpose.
const model = tf.sequential();
model.add(
tf.layers.dense({ units: 100, activation: 'relu', inputShape: [200] }));
model.add(tf.layers.dense({ units: 1 }));
model.compile({
loss: 'meanSquaredError',
optimizer: 'sgd',
metrics: ['MAE']
});
// Generate some random fake data for demo purpose.
const xs = tf.randomUniform([10000, 200]);
const ys = tf.randomUniform([10000, 1]);
const valXs = tf.randomUniform([1000, 200]);
const valYs = tf.randomUniform([1000, 1]);
// Start model training process.
await model.fit(xs, ys, {
epochs: 10,
validationData: [valXs, valYs],
// Add the tensorBoard callback here.
callbacks: tf.node.tensorBoard(path.join(__dirname, 'tmp/fit_logs_1'))
});
- Train the model (by running the two code cells).
- Use the command
Python: Launch TensorBoard
to launch the tensorboard
4. Tensorflow Visualizations using @tensorflow/tfjs-vis
Home