TensorFlow.js

Setup TensorFlow.js

Browser setup

There are two main ways to get TensorFlow.js in your browser based projects: via script tags or by installing it from NPM and using a build tool like Parcel, WebPack, or Rollup.

If you are new to web development, or have never heard of tools like webpack or parcel, we recommend you use the script tag approach. If you are more experienced or want to write larger programs it might be worthwhile to explore using build tools.

Usage via Script Tag

Add the following script tag to your main HTML file.

          
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.14.1/dist/tf.min.js"></script>
          
        

Installation via NPM

yarn add @tensorflow/tfjs
or    
npm install @tensorflow/tfjs

Installation for Node.js

Option 1: Install TensorFlow.js with native C++ bindings.
yarn add @tensorflow/tfjs-node
or    
npm install @tensorflow/tfjs-node
Option 2: (Linux Only) If your system has a NVIDIA® GPU with CUDA support, use the GPU package even for higher performance.
yarn add @tensorflow/tfjs-node-gpu
or    
npm install @tensorflow/tfjs-node-gpu
Option 3: Install the pure JavaScript version. This will be the slowest option of these 3.
yarn add @tensorflow/tfjs
or    
npm install @tensorflow/tfjs