tensorflow /tfjs
A WebGL accelerated JavaScript library for training and deploying ML models.
★ 19,160⑂ 2,022👁 311⑃ 4,363● 4,338▤ 105
deep-learningtypescriptwebgljavascriptmachine-learningneural-networkdeep-neural-networkgpu-acceleration
More from this author
+0
Daily
19,160
stars
2,022
forks
311
watchers
4,363
prs
4,338
issues
105
releases
README
TensorFlow.js
TensorFlow.js is an open-source hardware-accelerated JavaScript library for
training and deploying machine learning models.
Develop ML in the Browser
Use flexible and intuitive APIs to build models from scratch using the low-level
JavaScript linear algebra library or the high-level layers API.
Develop ML in Node.js
Execute native TensorFlow with the same TensorFlow.js API under the Node.js
runtime.
Run Existing models
Use TensorFlow.js model converters to run pre-existing TensorFlow models right
in the browser.
Retrain Existing models
Retrain pre-existing ML models using sensor data connected to the browser or
other client-side data.
About this repo
This repository contains the logic and scripts that combine
several packages.
APIs:
- TensorFlow.js Core,
a flexible low-level API for neural networks and numerical computation.
- TensorFlow.js Layers,
a high-level API which implements functionality similar to
Keras.
- TensorFlow.js Data,
a simple API to load and prepare data analogous to
tf.data.
- TensorFlow.js Converter,
tools to import a TensorFlow SavedModel to TensorFlow.js
- TensorFlow.js Vis,
in-browser visualization for TensorFlow.js models
- TensorFlow.js AutoML,
Set of APIs to load and run models produced by
AutoML Edge.
Backends/Platforms:
- TensorFlow.js CPU Backend, pure-JS backend for Node.js and the browser.
- TensorFlow.js WebGL Backend, WebGL backend for the browser.
- TensorFlow.js WASM Backend, WebAssembly backend for the browser.
- TensorFlow.js WebGPU, WebGPU backend for the browser.
- TensorFlow.js Node, Node.js platform via TensorFlow C++ adapter.
- TensorFlow.js React Native, React Native platform via expo-gl adapter.
If you care about bundle size, you can import those packages individually.
If you are looking for Node.js support, check out the TensorFlow.js Node directory.
Examples
Check out our
examples repository
and our tutorials.
Gallery
Be sure to check out the gallery of all projects related to TensorFlow.js.
Pre-trained models
Be sure to also check out our models repository where we host pre-trained models
on NPM.
Benchmarks
Local benchmark tool. Use this webpage tool to collect the performance related metrics (speed, memory, etc) of TensorFlow.js models and kernels on your local device with CPU, WebGL or WASM backends. You can benchmark custom models by following this guide.
Multi-device benchmark tool. Use this tool to collect the same performance related metrics on a collection of remote devices.
Getting started
There are two main ways to get TensorFlow.js in your JavaScript project:
via script tags or by installing it from NPM
and using a build tool like Parcel,
WebPack, or Rollup.
via Script Tag
Add the following code to an HTML file:
html
// Notice there is no 'import' statement. 'tf' is available on the index-page
// because of the script tag above.
// Define a model for linear regression.
cTop issues
#3875ES6 Module Import of Tensorflow no longer works20 comments · 2020-09-03#8626tar (node-tar) < 7.5.7 has a security vulnerability17 comments · 2026-01-30#8570Memory leaks13 comments · 2025-07-02#8075React Native real time object detection is too slow 13 comments · 2023-11-18#7801Learning data too big to fit in memory at once, how to learn?12 comments · 2023-07-04#8323Unable to import tfjs-node-gpu possibly due to binding.gyp not found10 comments · 2024-07-04#8611file 404 when install @tensorflow/tfjs-node-gpu(https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.22.0/GPU-windows-4.22.0.zip)8 comments · 2025-12-22#8612@tensorflow/tfjs-tfdf dist/tf-tfdf.fesm.js is using __dirname which breaks usage in esm project7 comments · 2025-12-29
Latest release
tfjs-v4.22.0 tfjs-v4.22.0 2024-10-21Core (4.21.0 == 4.22.0) Misc - Update monorepo to 4.22.0. (8419). Thanks, @dbcp1. - Fix typos in the documentation strings of the tfjs-core directory (8413). Thanks, @gaikwadrahul8. Data (4.21.0 == 4.22.0) Misc - Update monorepo to 4.22.0. (8419). Thanks, @dbcp1. - [tfjs-data] support async generator (8408). Thanks, @tharvik. Layers (4.21.0 == 4.22.0) Misc - Update monorepo to 4.22.0. (8419). Thanks, @dbcp1. - Fix typos in the documentation strings of the tfjs-layers directory (8411). Thanks, @gaikwadrahul8. Converter (4.21.0 == 4.22.0) Misc - Update lockfile