How to install tfjs JavaScript library


Tensorflow is a hardware accelerated JavaScript library for building, training, testing and deploying machine learning models on a JavaScript runtime environment.

Installation through html script tag
For use within the browser you can link to jsdelivr content delivery network using an html script tag as follows;

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>

Installation through npm package manager
Alternatively you can install a self hosted version of tensorflow from npm, in your terminal type;

npm install '@tensorflow/tfjs'

Installation for tfjs-node on npm
tensorflow has two nodejs packages made specifically for nodejs

Installation for '@tensorflow/tfjs-node'
This version is a cpu only version it doesn't utilize gpu to do the computing, install tfjs node by typing;

npm install '@tensorflow/tfjs-node'

Installation for '@tensorflow/tfjs-node-gpu'
This version is arguably faster than the other two packages combined it utilizes gpu to compute machine learning algorithms,

The only drawback however is it's only supported on Linux systems with a NAVIDIA graphics card with cuba support install it from npm by typing;

npm install '@tensorflow/tfjs-node-gpu'

once installed you can test the installation by opening an interactive nodejs shell type in the following command;

import * as tf from '@tensorflow/node'

If installation succeed you wont get any warnings in from the interactve shell

Comments

Popular posts from this blog

Open-graph meta data tags introdution

What is 'this.' keyword in JavaScript

what is 'array.includes' function in JavaScript

How to use canvas context rect method for drawing rectangles

=== or == JavaScript comparison operator