tensorflow /tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.

★ 19,160⑂ 2,022👁 311⑃ 4,363● 4,338▤ 105
TypeScriptApache-2.0Created 2018-03-05js.tensorflow.org
下载:tfjs-v4.22.0tfjs-v4.22.0 ↓4.22.02024-10-21
+0
日增长
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.
      c

Top issues

Latest release

tfjs-v4.22.0 tfjs-v4.22.0 2024-10-21
Core (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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON