tensorflow/tfjs-examples

Examples built with TensorFlow.js

JavaScript

6,787

746 commits

updated Sep 22, 2026

See the code

README

TensorFlow.js Examples

This repository contains a set of examples implemented in TensorFlow.js.

Each example directory is standalone so the directory can be copied to another project.

Overview of Examples

Example nameDemo linkInput data typeTask typeModel typeTrainingInferenceAPI typeSave-load operations
abalone-nodeNumericLoading data from local file and training in Node.jsMultilayer perceptronNode.jsNode.jsLayersSaving to filesystem and loading in Node.js
addition-rnnπŸ”—TextSequence-to-sequenceRNN: SimpleRNN, GRU and LSTMBrowserBrowserLayers
addition-rnn-webworkerTextSequence-to-sequenceRNN: SimpleRNN, GRU and LSTMBrowser: Web WorkerBrowser: Web WorkerLayers
angular-predictive-prefetchingNumericMulticlass predictorDNNBrowser: Service WorkerLayers
baseball-nodeNumericMulticlass classificationMultilayer perceptronNode.jsNode.jsLayers
boston-housingπŸ”—NumericRegressionMultilayer perceptronBrowserBrowserLayers
cart-poleπŸ”—Reinforcement learningPolicy gradientBrowserBrowserLayersIndexedDB
chrome-extensionImage(Deploying TF.js in Chrome extension)ConvnetBrowser
custom-layerπŸ”—(Defining a custom Layer subtype)BrowserLayers
data-csvπŸ”—Building a tf.data.Dataset from a remote CSV
data-generatorπŸ”—Building a tf.data.Dataset using a generatorRegressionBrowserBrowserLayers
date-conversion-attentionπŸ”—TextText-to-text conversionAttention mechanism, RNNNode.jsBrowser and Node.jsLayersSaving to filesystem and loading in browser
electronImage(Deploying TF.js in Electron-based desktop apps)ConvnetNode.js
fashion-mnist-vaeImageGenerativeVariational autoencoder (VAE)Node.jsBrowserLayersExport trained model from tfjs-node and load it in browser
interactive-visualizersImageMulticlass classification, object detection, segmentationBrowser
irisπŸ”—NumericMulticlass classificationMultilayer perceptronBrowserBrowserLayers
iris-fitDatasetπŸ”—NumericMulticlass classificationMultilayer perceptronBrowserBrowserLayers
jena-weatherπŸ”—SequenceSequence-to-predictionMLP and RNNsBrowser and NodeBrowserLayers
lstm-text-generationπŸ”—TextSequence predictionRNN: LSTMBrowserBrowserLayersIndexedDB
mnistπŸ”—ImageMulticlass classificationConvolutional neural networkBrowserBrowserLayers
mnist-acganπŸ”—ImageGenerative Adversarial Network (GAN)Convolutional neural network; GANNode.jsBrowserLayersSaving to filesystem from Node.js and loading it in the browser
mnist-coreπŸ”—ImageMulticlass classificationConvolutional neural networkBrowserBrowserCore (Ops)
mnist-nodeImageMulticlass classificationConvolutional neural networkNode.jsNode.jsLayersSaving to filesystem
mnist-transfer-cnnπŸ”—ImageMulticlass classification (transfer learning)Convolutional neural networkBrowserBrowserLayersLoading pretrained model
mobilenetπŸ”—ImageMulticlass classificationConvolutional neural networkBrowserLayersLoading pretrained model
polynomial-regressionπŸ”—NumericRegressionShallow neural networkBrowserBrowserLayers
polynomial-regression-coreπŸ”—NumericRegressionShallow neural networkBrowserBrowserCore (Ops)
quantizationVariousDemonstrates the effect of post-training weight quantizationVariousNode.jsNode.jsLayers
sentimentπŸ”—TextSequence-to-binary-predictionLSTM, 1D convnetNode.js or PythonBrowserLayersLoad model from Keras and tfjs-node
simple-object-detectionπŸ”—ImageObject detectionConvolutional neural network (transfer learning)Node.jsBrowserLayersExport trained model from tfjs-node and load it in browser
snake-dqnπŸ”—Reinforcement learningDeep Q-Network (DQN)Node.jsBrowserLayersExport trained model from tfjs-node and load it in browser
translationπŸ”—TextSequence-to-sequenceLSTM encoder and decoderNode.js or PythonBrowserLayersLoad model converted from Keras
tsne-mnist-canvasDimension reduction and data visualizationtSNEBrowserBrowserCore (Ops)
webcam-transfer-learningπŸ”—ImageMulticlass classification (transfer learning)Convolutional neural networkBrowserBrowserLayersLoading pretrained model
website-phishingπŸ”—NumericBinary classificationMultilayer perceptronBrowserBrowserLayers

Dependencies

Except for getting_started, all the examples require the following dependencies to be installed.

How to build an example

cd into the directory

If you are using yarn:

cd mnist-core
yarn
yarn watch

If you are using npm:

cd mnist-core
npm install
npm run watch

Details

The convention is that each example contains two scripts:

  • yarn watch or npm run watch: starts a local development HTTP server which watches the filesystem for changes so you can edit the code (JS or HTML) and see changes when you refresh the page immediately.

  • yarn build or npm run build: generates a dist/ folder which contains the build artifacts and can be used for deployment.

Contributing

If you want to contribute an example, please reach out to us on Github issues before sending us a pull request as we are trying to keep this set of examples small and highly curated.

Running Presubmit Tests

Before you send a pull request, it is a good idea to run the presubmit tests and make sure they all pass. To do that, execute the following commands in the root directory of tfjs-examples:

yarn
yarn presubmit

The yarn presubmit command executes the unit tests and lint checks of all the exapmles that contain the yarn test and/or yarn lint scripts. You may also run the tests for individual exampls by cd'ing into their respective subdirectory and executing yarn, followed by yarn test and/or yarn lint.

tensorflow/tfjs-examples

Examples built with TensorFlow.js

JavaScript

6,787

746 commits

updated Sep 22, 2026

See the code

README

TensorFlow.js Examples

This repository contains a set of examples implemented in TensorFlow.js.

Each example directory is standalone so the directory can be copied to another project.

Overview of Examples

Example nameDemo linkInput data typeTask typeModel typeTrainingInferenceAPI typeSave-load operations
abalone-nodeNumericLoading data from local file and training in Node.jsMultilayer perceptronNode.jsNode.jsLayersSaving to filesystem and loading in Node.js
addition-rnnπŸ”—TextSequence-to-sequenceRNN: SimpleRNN, GRU and LSTMBrowserBrowserLayers
addition-rnn-webworkerTextSequence-to-sequenceRNN: SimpleRNN, GRU and LSTMBrowser: Web WorkerBrowser: Web WorkerLayers
angular-predictive-prefetchingNumericMulticlass predictorDNNBrowser: Service WorkerLayers
baseball-nodeNumericMulticlass classificationMultilayer perceptronNode.jsNode.jsLayers
boston-housingπŸ”—NumericRegressionMultilayer perceptronBrowserBrowserLayers
cart-poleπŸ”—Reinforcement learningPolicy gradientBrowserBrowserLayersIndexedDB
chrome-extensionImage(Deploying TF.js in Chrome extension)ConvnetBrowser
custom-layerπŸ”—(Defining a custom Layer subtype)BrowserLayers
data-csvπŸ”—Building a tf.data.Dataset from a remote CSV
data-generatorπŸ”—Building a tf.data.Dataset using a generatorRegressionBrowserBrowserLayers
date-conversion-attentionπŸ”—TextText-to-text conversionAttention mechanism, RNNNode.jsBrowser and Node.jsLayersSaving to filesystem and loading in browser
electronImage(Deploying TF.js in Electron-based desktop apps)ConvnetNode.js
fashion-mnist-vaeImageGenerativeVariational autoencoder (VAE)Node.jsBrowserLayersExport trained model from tfjs-node and load it in browser
interactive-visualizersImageMulticlass classification, object detection, segmentationBrowser
irisπŸ”—NumericMulticlass classificationMultilayer perceptronBrowserBrowserLayers
iris-fitDatasetπŸ”—NumericMulticlass classificationMultilayer perceptronBrowserBrowserLayers
jena-weatherπŸ”—SequenceSequence-to-predictionMLP and RNNsBrowser and NodeBrowserLayers
lstm-text-generationπŸ”—TextSequence predictionRNN: LSTMBrowserBrowserLayersIndexedDB
mnistπŸ”—ImageMulticlass classificationConvolutional neural networkBrowserBrowserLayers
mnist-acganπŸ”—ImageGenerative Adversarial Network (GAN)Convolutional neural network; GANNode.jsBrowserLayersSaving to filesystem from Node.js and loading it in the browser
mnist-coreπŸ”—ImageMulticlass classificationConvolutional neural networkBrowserBrowserCore (Ops)
mnist-nodeImageMulticlass classificationConvolutional neural networkNode.jsNode.jsLayersSaving to filesystem
mnist-transfer-cnnπŸ”—ImageMulticlass classification (transfer learning)Convolutional neural networkBrowserBrowserLayersLoading pretrained model
mobilenetπŸ”—ImageMulticlass classificationConvolutional neural networkBrowserLayersLoading pretrained model
polynomial-regressionπŸ”—NumericRegressionShallow neural networkBrowserBrowserLayers
polynomial-regression-coreπŸ”—NumericRegressionShallow neural networkBrowserBrowserCore (Ops)
quantizationVariousDemonstrates the effect of post-training weight quantizationVariousNode.jsNode.jsLayers
sentimentπŸ”—TextSequence-to-binary-predictionLSTM, 1D convnetNode.js or PythonBrowserLayersLoad model from Keras and tfjs-node
simple-object-detectionπŸ”—ImageObject detectionConvolutional neural network (transfer learning)Node.jsBrowserLayersExport trained model from tfjs-node and load it in browser
snake-dqnπŸ”—Reinforcement learningDeep Q-Network (DQN)Node.jsBrowserLayersExport trained model from tfjs-node and load it in browser
translationπŸ”—TextSequence-to-sequenceLSTM encoder and decoderNode.js or PythonBrowserLayersLoad model converted from Keras
tsne-mnist-canvasDimension reduction and data visualizationtSNEBrowserBrowserCore (Ops)
webcam-transfer-learningπŸ”—ImageMulticlass classification (transfer learning)Convolutional neural networkBrowserBrowserLayersLoading pretrained model
website-phishingπŸ”—NumericBinary classificationMultilayer perceptronBrowserBrowserLayers

Dependencies

Except for getting_started, all the examples require the following dependencies to be installed.

How to build an example

cd into the directory

If you are using yarn:

cd mnist-core
yarn
yarn watch

If you are using npm:

cd mnist-core
npm install
npm run watch

Details

The convention is that each example contains two scripts:

  • yarn watch or npm run watch: starts a local development HTTP server which watches the filesystem for changes so you can edit the code (JS or HTML) and see changes when you refresh the page immediately.

  • yarn build or npm run build: generates a dist/ folder which contains the build artifacts and can be used for deployment.

Contributing

If you want to contribute an example, please reach out to us on Github issues before sending us a pull request as we are trying to keep this set of examples small and highly curated.

Running Presubmit Tests

Before you send a pull request, it is a good idea to run the presubmit tests and make sure they all pass. To do that, execute the following commands in the root directory of tfjs-examples:

yarn
yarn presubmit

The yarn presubmit command executes the unit tests and lint checks of all the exapmles that contain the yarn test and/or yarn lint scripts. You may also run the tests for individual exampls by cd'ing into their respective subdirectory and executing yarn, followed by yarn test and/or yarn lint.

Project health

Overall

3.2/10

Maintained

0/10

Code review

10/10
OpenSSF Scorecard

Significant stargazers

(top 24 of 25)

justheuristic

497 followers Β· starred Aug 2020

bitbrain

691 followers Β· starred May 2024

ι«˜δΊ‘ ε’¨ζ™Ί

1,514 followers Β· starred Apr 2022

Gyandeep Singh

109 followers Β· starred Sep 2018