Image for post
Image for post

Note : All code files will be available at
This blog post will cover some basic functions that will be repeatedly used a lot in tensorflow 2.


random.normal generates random values of the given shape, which follow normal distribution
and random.uniform generates random values in such a way that probability of choosing any number from the random bunch is almost uniform

#normal distribution
x1 = tf.random.normal(shape=(5,5),mean=0,stddev=1)
#normal distribution
output: tf.Tensor(
[[-1.1473149e+00 5.1616412e-01 -2.8656033e-01 …

Image for post
Image for post

What is Tensorlfow ?

Tensorflow is a DeepLearning library which has a lot of inbuilt classes and functions which allow you to perform these complex deep learning matrix multiplications and gradient calculations easily. The main Goal behind tensorflow is to make developing machine learning models easier and get it to a production environment.

Advantages of Tensorflow 2 over The first Version

As everyone already know, The updated version of tensorflow allows the user to create models easily whereas it was quite difficult with tensorflow’s first version.


You could directly use tensorflow from google colab (I prefer this) or type
“pip install tensorflow” for windows users and
“pip3 install tensorflow2” for linux users

Tensor Basics

Tensors are simply n-dimensional arrays. …

Image for post
Image for post


sorry for misspelling network , lol.
All the code files will be available at :

What are RNNs and LSTMs ?

Recurrence Neural Network are great for Sequence data and Time Series Data. Long short-term memory is an artificial recurrent neural network architecture used in the field of deep learning. LSTMs and RNNs are used for sequence data and can perform better for timeseries problems.

An LSTM is an advanced version of RNN and LSTM can remember things learnt earlier in the sequence using gates added to a regular RNN. Both LSTM’s and RNN’s working are similar in PyTorch. …

Image for post
Image for post

Note : All the code files will be available at :

What is Sentiment Analysis ?

Sentiment analysis in simple words is basically analysing how an user feels about an item or any other thing from the user’s activity such as reviews , tweets, etc.

Jumping to Code

  1. Importing the Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import nltk

2. Downloading NLTK

Use the nltk shell to download the english stopwords.

3. Importing the dataset

df = pd.read_csv('IMDB Dataset.csv')

output :

Image for post
Image for post

As you can see, there are some html tags in reviews

4. Beautiful Soup

#remove html tags
from bs4 import BeautifulSoup
for i in range(df.shape[0]):
df['review'][i] = BeautifulSoup(df['review'][i], "lxml").text …

Image for post
Image for post


Recommender systems are the systems that are designed to recommend things to the user based on many different factors

Pearson’s Correlation Coefficient is a very simple yet effective way to find how 1 variable linearly changes with respect to another. we can use this to our advantage and build a recommender system with this concept

Working of correlation coefficient

Image for post
Image for post

If correlation coefficient is closer to 1 for two variables, these variables are directly proportional to each other.

If it is closer to -1 , these variables are inversely proportional to each other.

If the magnitude of the correlation coefficient is lower or closer to 0, the variables are probably don’t have a strong dedpendency with respect to each other. …

Image for post
Image for post

Note: All the code files will be available at :

Going Merry is a chatbot that I created for a pirate recruitment process. It helps in recruitment of pirates all around the world. this answer user’s simple questions regarding the recruitment process, pre-requisites, etc.This same model can also be used for creating chatbots for any organization


A chatbot is a software application used to conduct an on-line chat conversation via text . In this blog post, I will show how to create a Simple Chatbot with tensorflow 2 for your organization.

Dataset Preparation

once, the dataset is built . half the work is already done. the way we structure the dataset is the main thing in chatbot. I have used a json file to create a the dataset. …

Image for post
Image for post

All the code files will be available at :

What is an Outlier ?

Anything that is unusual and deviates from the standard “normal” is called an Anomaly or an Outlier.
Detecting these anomalies in the given data is called as anomaly detection.

For more theoretical information about outlier or anomaly detection, Check out : How Anomaly Detection Works ?

Why do we need to remove outliers or detect them ?

Case 1 : Consider a situation where a big manufacturing company is manufacturing an airplane. An airplane has different parts and we don’t want any parts to behave in an unusual way. …

Image for post
Image for post

Before we begin about K-Means clustering, Let us see some things :
1. What is Clustering
2. Euclidean Distance
3. Finding the centre or Mean of multiple points
If you are already familiar with these things, feel free to skip to K-Means algorithm

What is Clustering ?

Image for post
Image for post
Figure 1.1

Clustering is nothing but grouping. We are given some data, we have to find some patterns in the data and group similar data together to form clusters . This is the basis of clustering.
This is done with the help of euclidean distance.

for example:
1. An athletic club might want to cluster their runners into 3 different clusters based on their speed ( 1 dimension )
2. A company might want to cluster their customers into 3 different clusters based on 2 factors : Number of items brought, no of items returned ( 2 dimensions…

Image for post
Image for post


In the previous post, we saw the introduction to opencv and some basic Image loading and stuff.
In this post, we are going to be creating our own images by drawing shapes and texts on an empty canvas

Let’s Jump right into the Code for better understanding

  1. Importing some libraries
Image for post
Image for post

2. Creating an empty canvas

Image for post
Image for post

pixels with low intensity are black and very high intensity are white. Since, we know that pictures can be represented in terms of matrices , we are initialising a 3 dimensional matrix full of element 1. So, that we get a plain white image.

0 → Black
1 → White

3. Drawing a line

before, we start using opencv’s functions, one thing I wanted to say is the all of opencv’s functions are executed inplace. …

Image for post
Image for post


This is the start of a new series called “The OpenCV for Beginners”. In this blog post , we will be seeing about the basics of images and how to handle them with cv2 module in python.
The access the code files , check my github profile : My Github profile.
The repository will be update after the completion of the entire series.



What is OpenCV ?

OpenCV is a computer vision library that has functionalities that can be used to handle image and video data.

Installing OpenCV

For Linux users:

pip3 install opencv-python

For windows users:

pip install opencv-python

Matrix Representation of Images

Images are also data. Hence, they can be represented in forms of matrices.
In your school days , you might have studied that mixing red, green and blue in different proportions will result in different colours and these 3 colours can be used to create every colour in this world. …


Ashwin Prasad

Machine Learning | Deep Learning | Data Science | Web Dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store