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="[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


Popular posts from this blog

Snake monochrome (JS1024)

What is 'this.' keyword in JavaScript

Open-graph meta data tags introdution

what is 'array.includes' function in JavaScript

How to create zip archives in nodejs