Watch talks from the 2019 TensorFlow Dev Summit Watch now

Setup

Browser Setup

There are two main ways to get TensorFlow.js in your browser based projects: - Using script tags. - Installation 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@1.0.0/dist/tf.min.js"></script>

Installation from NPM

You can use either the npm cli tool or yarn to install TensorFlow.js.

yarn add @tensorflow/tfjs

or

npm install @tensorflow/tfjs

Node.js Setup

You can use either the npm cli tool or yarn to install TensorFlow.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 is the slowest option performance wise.

yarn add @tensorflow/tfjs

or

npm install @tensorflow/tfjs