Hello all! My previous blog posts were entirely focused on getting you comfortable with the idea of ML.
I decided for a change to bring to you something fun in ML. Highlight an important aspect of it i.e. DEEP LEARNING! We will get started with the tensorflow basics here.
TENSORFLOW is an API developed by google brain team.
An open source library for graphical based computation. It is used for: model building and deployment.
Tensor: is a generalization of vectors and matrices to potentially higher dimensions.In simple words it is a collection of numbers arranged in a particular shape.
N dimensional tensors
IT’S TWO BASIC OBJECTS OF COMPUTATION ARE : CONSTANTS AND VARIABLES
Constants :
- Cannot change
- Cannot be trained
- Can have any dimension
Variables:
- Values can be changed with computation.
- Value is shared ,persistent and modifiable.
- Fixed data type and shape.
Basic operations of tensorflow
Tensorflow operation
Tf has a computational model that revolves around the use of graphs.
Tf graph has edges(tensors) and nodes(operations)
Add() operation to add two tensors
Matmul() operation to multiply two tensors.
Reduce_sum() operator sums over the dimensions of a tensor (all or one)
Sum operation can be done with + operator as it is overloaded.
Addition can be scalar,vector or matrix. Element wise addition takes place. Same shape required of 2 matrices is the pre-requisite condition.
MULTIPLY OPERATION
TWO TYPES:
ELEMENT WISE AND MATRIX MULTIPLICATION
FOR ELEMENT WISE
- USE MULTIPLY()
- MUST HAVE SAME SHAPE
- FOR MATRIX MULTIPLICATION
FOR MATRIX MULTIPLICATION
- USE MATMUL(A,B) TO MULTIPLY A TO B
- COLUMN NO. OF A SHOULD BE EQUAL TO ROW NO. OF B
Reduce_sum operator is used to perform summation over tensors , over all dimensions or one
Reduce_sum(A) all dimensions
Reduce_sum(A,i) over I dimension
Element-wise multiplication in TensorFlow is performed using two tensors with identical shapes. This is because the operation multiplies elements in corresponding positions in the two tensors. An example of an element-wise multiplication, denoted by the ⊙⊙ symbol, is shown below:
[1221]⊙[3215]=[3425]
ADVANCED OPERATION IN TF
- GRADIENT ()- FINDS THE SLOPE OF A TENSOR AT A PARTICULAR POINT
- RESHAPE()- RESFAPES THE TENSOR
- RANDOM()-GENERATES TENSOR OUTTA RANDOMLY DRAWN VALUES
FINDING OPTIMUM -MINIMUM OR MAXIMUM ,BASICALLY NEEDED TO MINIMIZE THE LOSS FUNCTION
HOW TO DO IT??
VIA GRADIENT OPERATION
PASS VALUES TO GRADIENT FUNCTION UNTIL A POINT WHERE GRADIENT IS 0.
Another gradient operation is
RESHAPING
Used extensively in image classification. Algorithms require to change matrices into vectors before classification.
Will be discussing image classification and some more cool content in the next blog. Be tuned!!
Please like, if you found this one helpful!