Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 2, 2026·3 min de lecture

TensorFlow.js — Machine Learning in JavaScript

A JavaScript library for training and deploying machine learning models in the browser and on Node.js with GPU acceleration via WebGL and WebGPU.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 17/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
Script
Installation
Stage only
Confiance
Confiance : Established
Point d'entrée
TensorFlow.js
Commande de staging sûr
npx -y tokrepo@latest install 584537ac-75ce-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

TensorFlow.js brings the TensorFlow ecosystem to JavaScript, letting you train models directly in the browser or on Node.js. It provides GPU-accelerated tensor operations through WebGL and WebGPU, making client-side ML inference fast enough for real-time applications.

What TensorFlow.js Does

  • Trains and runs ML models entirely in the browser with no server required
  • Converts existing TensorFlow and Keras models for JavaScript deployment
  • Accelerates tensor math via WebGL, WebGPU, and WASM backends
  • Provides pre-built models for image classification, object detection, pose estimation, and NLP
  • Supports transfer learning to fine-tune models on client-side data

Architecture Overview

The library has three layers: a low-level Ops API for tensor operations, a Layers API matching the Keras interface, and a high-level Model API for loading pre-trained models. Backends (WebGL, WebGPU, WASM, CPU) are pluggable and selected automatically based on browser capabilities. A converter tool transforms SavedModel and Keras H5 files into the TFJS format.

Self-Hosting & Configuration

  • Install the core package or use a CDN script tag for quick prototyping
  • Choose a backend explicitly or let the library auto-select the fastest available
  • Use the Node.js binding with tfjs-node for server-side training with native C++ acceleration
  • Convert Python models using the tensorflowjs_converter CLI tool
  • Host converted model files on any static file server or CDN

Key Features

  • Full training and inference loop runs in the browser with no backend calls
  • WebGPU backend delivers near-native GPU performance on supported browsers
  • Extensive pre-trained model zoo for vision, language, and audio tasks
  • Seamless model conversion from Python TensorFlow and Keras
  • Privacy-preserving ML since data never leaves the user device

Comparison with Similar Tools

  • ONNX Runtime Web — inference-only for ONNX models; TensorFlow.js supports both training and inference
  • Brain.js — simpler neural network API; TensorFlow.js offers the full TensorFlow ecosystem
  • PyTorch — Python-first; TensorFlow.js targets JavaScript runtimes natively
  • ml5.js — higher-level wrapper built on TensorFlow.js for beginners
  • Transformers.js — focuses on Hugging Face model inference; TensorFlow.js covers broader ML tasks

FAQ

Q: Can I train large models in the browser? A: Small to medium models train well. For large models, train in Python and convert for browser inference.

Q: Which backend should I use? A: WebGPU gives the best performance on supported browsers. WebGL is the most widely compatible fallback.

Q: Can I use pre-trained Hugging Face models? A: TensorFlow.js supports converted TF/Keras models. For Hugging Face transformers, consider Transformers.js.

Q: Does it work in Node.js? A: Yes. The tfjs-node package provides native C++ bindings for server-side performance.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires