Description #
TensorFlow.js is a JavaScript library for training and deploying machine learning models directly in the browser or Node.js. It enables web developers to build AI-powered web applications without backend dependencies.
History #
Released by Google in 2018, TensorFlow.js extends the TensorFlow ecosystem to JavaScript, allowing developers to utilize GPU acceleration via WebGL and create client-side ML experiences.
Hello World Code #
import * as tf from '@tensorflow/tfjs';
const hello = tf.tensor(['Hello, TensorFlow.js!']);
hello.print();
How to Run #
Option 1: Online
Try TensorFlow.js on TensorFlow.js Playground.
Option 2: Local
- Install with npm:
npm install @tensorflow/tfjs
- Run in browser or Node.js environment with example code.
Key Concepts #
- Machine learning in JavaScript environments
- Supports training and inference on browser or server
- GPU acceleration with WebGL
- Pretrained models and transfer learning support
- Integration with web APIs (WebCam, Audio)
- Model conversion from TensorFlow Python ecosystem
- Data pipeline utilities
- Wide range of applications: image, text, speech
- Open source with active community
- Supports both client- and server-side ML
Try It Online #
Fun Facts #
- TensorFlow.js lets you build ML apps without server-side infrastructure.
- It powers real-time pose detection, object recognition, and speech commands in-browser.
- TensorFlow.js can convert Python TensorFlow models for web use.
- Developers use it for interactive educational ML demos.
- It supports training small models live in users’ browsers.