Narrow AI : trained to do specific thing like or even better than humans.
Machine Learning : An approach to AI where system learns from patterns.
Deep Learning : A technique to implement Machine Learning.
Reinforcement Learning : try to take actions to maximize its reward.
Transfer Learning : retrain existing models with new data.
How to train ML model :
Features and Attributes (color shape size weight position etc.)
Visualizing features
Choose an algorithm
TensoFlow.js :
Tensorflow.js is high level Layers API (like Keras(high level layers API for python)) which was build after deeplearn.js which was a low level mathematical Ops API which required more knowledge of ML and Math to run a model on browser.
Both Python and JavaScript code for Tensorflow.js are simply build on top of C++ core with the help of C/C++ bindings.
Models in Tensorflow.js can run on both client and server side.
Client side our hardware have many options and execution time of ML model is based on hardware of client.
While on server side hardware is fix and mostly of better quality and better scalability options
Client Side hardware options :
Tensors :
There are 6 dimensions / rank 6 tensors supported in Tensorflow.js
if you have 4 values in an array then an vector is 4d but tensor is 1d with 4 values in it therefore tensor is of rank 1.
import tensorflow as tfimport matplotlib.pyplot as pltimage = tf.io.read_file('./test.png')image = tf.image.decode_image(image, channels=3) # convert image to RGBgray_image = tf.image.rgb_to_grayscale(image)plt.figure(figsize=(12, 6))# Original imageplt.subplot(1, 2, 1)plt.imshow(image.numpy())plt.title("Original Image")plt.axis('off')# Grayscale imageplt.subplot(1, 2, 2)plt.imshow(gray_image.numpy(), cmap='gray')plt.title("Grayscale Image")plt.axis('off')plt.tight_layout()plt.show()
4 dimension / Rank 4 tensor : (Example: a video where we have series of rank 3 tensor RGB images and 4th dimension is time)
5 dimension / Rank 5 tensor : (Example: a batch of videos, Minecraft)
In 3d games like Minecraft data is called voxel (volume element in a 3D space), where each voxel, so each voxel can have composition of ((r,g,b), x, y, z, time) as a rank 5 tensor
6 dimension / Rank 6 tensor : (Example: a batch of voxel, like a batch a voxel with animations(6th dimension))
Attributes of a tensor :
Data Types (DType, dtype)
int8 === char stores 0-255
int16 === short stores 0-2^16 - 1
int32 === int stores 0-2^32 - 1
int64 === int stores 0-2^64 - 1
Shape
Number of elements in each of dimension / axis
Example: A Rank 3 with [4,5,8] will have
1st dimension will have 4 values in array
2nd dimension will have 5 values in array
3rd dimension will have 8 values in array
Rank / Axis
Rank is simply the number of axis / dimension in an tensor
Size
its the total number of elements an tensor can hold
Example: a rank 3 tensor of [4,5,8] can hold 4 * 5 * 8 = 160 elements