AI and ML are two things that are going to be the future of our day to day life. As for now, it is used in some of our daily activities like in our smartphones, computers/laptop, and browsers.TensorFlow is an open-source software library for high-performance numerical computation, for ML and also used for the neural network training. However, the software library came with a difficult installation process for desktops. To make it frictionless, developers can now deploy machine learning development services with "TensorFlow.js".
TensorFlow.js provides both low-level building blocks for machine learning and high-level, Keras-inspired API for constructing neural networks.
We can use TensorFlow.js to retrain pre-existing machine learning models with the data which is available at the client-side in the browser. E.g. We can use image data from the webcam.
Main building blocks in TensorFlow
Tensors: It is the central unit of data in TensorFlow. A tensor contains a set of numeric values that can be of any shape (dimensions).
const t1 = tf.tensor([1,2,3,4,2,4,6,8]), [2,4]);
Operations: Using TensorFlow operations we can manipulate data of a tensor. Because of the rigidness of tensor operations are always returning a new tensor with the resulting values.
const t3 = tf.tensor2d([1,2], [3, 4]);// tensor2d 2d is dimension
const t3_squared = t3.square();
Modules / Layers: Models and Layers are the two important building blocks in deep learning. Each model has one or more layers. For better understanding, we can say layers are used to build up neural networks (models) that can be trained with data and then used to predict further values based on the trained information.
There are some crazy things which we can do with TensorFlow.js like.
Real-time Human Position Estimation in the browser.
We can train our model using a webcam in our browser.
We can use concepts like Tensors, Layers, Optimizers and Loss Functions.
Now the best part how to install it in your browser.
it's simple as it is a js file you just need to import it that's all you need to do.
npm install @tensorflow/tfjs
import * as tf from '@tensorflow/tfjs';
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>