PP&DS 5
PP&DS 5
• Deep learning is a subset of Machine learning, which on the other hand is a subset of
artificial intelligence.
• Artificial Intelligence (AI) is the branch of computer sciences that emphasizes the
development of intelligence machines, thinking and working like humans. For
example, speech recognition, problem-solving, learning and planning..etc
• Machine learning is a branch of artificial intelligence (AI) and computer science which
focuses on the use of data and algorithms to imitate the way that humans learn,
gradually improving its accuracy.
• Deep Learning is just a type of Machine Learning, inspired by the structure of a human
brain.
• In deep learning, nothing is programmed explicitly/clearly.
• Deep learning algorithms are used, especially when we have a huge no of inputs and
outputs.
• Deep learning is implemented with the help of Neural Networks, and the idea behind
the motivation of Neural Network is the biological neurons, which is nothing but a brain
cell.
• So basically, deep learning is implemented by the help of deep networks, which are
nothing but neural networks with multiple hidden layers.
In the example given above, we provide the raw data of images to the first layer of the input
layer.
After then, these input layers will determine the patterns of local contrast that means it will
differentiate on the basis of colours, luminosity, etc.
Then the 1st hidden layer will determine the face feature, i.e., it will fixate on eyes, nose, and
lips, etc.
And then, it will fixate those face features on the correct face template.
So, in the 2nd hidden layer, it will actually determine the correct face here as it can be seen in
the above image, after which it will be sent to the output layer.
Limitations
Advantages
Disadvantages
A typical learning algorithm for MLP networks is also called back propagation's algorithm.
A multilayer perceptron (MLP) is a feed forward artificial neural network that generates a set
of outputs from a set of inputs.
MLP uses back propagation for training the network. MLP is a deep learning method.
Back propagation
• Back propagation is one of the important concepts of a neural network.
• Back propagation is a technique used to train certain classes of neural networks it is
essentially a principal that allows the machine learning program to adjust itself
accordingly
• Back propagation is sometimes called the “back propagation of errors.”
5. Travel back from the output layer to the hidden layer to adjust the weights such that
the error is decreased.
loss function
• The loss function is the function that computes the distance between the current output
of the algorithm and the expected output.
• It’s a method to evaluate how your algorithm models the data.
• It can be categorized into two groups.
• One for classification and the other for regression.
•
Hyper parameter tuning
• Hyper parameter tuning works by running multiple trails in a single training job.
• A hyper parameter is a model argument whose value is set before the learning
process begins.
10.2M
Application of RNN
1. Machine Translation
We make use of Recurrent Neural Networks in the translation engines to translate the text
from one to another language. They do this with the combination of other models
like LSTM (Long short-term memory)s.
2. Speech Recognition
Recurrent Neural Networks has replaced the traditional speech recognition models that made
use of Hidden Markov Models. These Recurrent Neural Networks, along with LSTMs, are better
poised at classifying speeches and converting them into text without loss of context.
3. Automatic Image Tagger
RNNs, in conjunction with convolutional neural networks, can detect the images and provide
their descriptions in the form of tags.
For example, a picture of a fox jumping over the fence is better explained appropriately using
RNNs.
• A CNN network has an input and an output layer, as well as multiple hidden layers.
• The hidden layers of a CNN typically consist of a series of convolutional layers.
• ReLU is the typical activation function, which is normally followed by additional
operations such as pooling layers, fully connected layers and normalization layers.
• Backpropagation is used for error distribution and weight adjustment.
For example,
Consider the image below of Nature, upon first glance; we will see a lot of buildings and
colours.
The image is broken into 3 colours-channels which is Red, Green, and Blue.
Each of these colours channels is mapped to the image's pixel.
Edge Detection
• Every image has vertical and horizontal edges which actually combining to form an
image.
• Convolution operation is used with some filters for detecting edges.
Example-
• For this example, we are using 3*3 Prewitt filter as shown in the above image.
• As shown below, when we apply the filter to perform edge detection on the given
6*6 image
• The output image will contain
• ((a11*1) + (a12*0) + (a13*(-1))+(a21*1)+(a22*0)+(a23*(-))+(a31*1)+(a32*0)
+(a33*(-1))) in the purple square.
• We repeat the convolutions horizontally and then vertically to obtain the output
image.
• We would continue the above procedure to get the processed image after
edge-detection.
• But, in the real world, we deal with very high-resolution images for Artificial
Intelligence applications.
• Hence we opt for an algorithm to perform the convolutions, and even use
Deep Learning to decide on the best values of the filter.
Layers in CNN
There are five different layers in CNN
• Input layer
• Convo layer (Convo + ReLU)
• Pooling layer
• Fully connected(FC) layer
• Softmax/logistic layer
• Output layer
Input Layer
• Suppose you have image of dimension 28 x 28 =784, you need to convert it into 784 x 1
before feeding into input.
• If you have “m” training examples then dimension of input will be (784, m).
Convo Layer
• Convo layer is sometimes called feature extractor layer because features of the image
are get extracted within this layer.
• Then we slide the filter over the next receptive field of the same input image by a Stride
and do the same operation again.
• We will repeat the same process again and again until we go through the whole image.
The output will be the input for the next layer.
• Convo layer also contains ReLU activation to make all negative value to zero.
Pooling Layer
• Pooling layer is used to reduce the spatial volume of input image after convolution.
• If we apply FC after Convo layer without applying pooling or max pooling, then it will be
computationally expensive and we don’t want it.
• So, the max pooling is only way to reduce the spatial volume of input image.
• In the above example, we have applied max pooling in single depth slice with Stride of
2.
Output Layer
• Output layer contains the label which is in the form of one-hot encoded.
Keras Implementation
We will use CIFAR-10 dataset to build a CNN image classifier. CIFAR-10 dataset has 10
different labels
• Airplane
• Automobile
• Bird
• Cat
• Deer
• Dog
• Frog
• Horse
• Ship
• Truck
It has 50,000 training data and 10,000 testing image data. Image size in CIFAR-10 is 32 x 32
x 3. It comes with Keras library.
Long short-term memory (LSTM)
• Long short-term memory (LSTM) is an artificial recurrent neural network (RNN)
architecture used in the field of deep learning.
• RNNs process inputs in a sequential manner, where the context from the previous
input is considered when computing the output of the current step.
• This allows the neural network to carry information over different time steps rather
than keeping all the inputs independent of each other.
• RNNs are unable to work with longer sequences and hold on to long-term
dependencies, making them suffers from “short-term memory”.
• As we can see from the image, the difference lies mainly in the LSTM’s ability to
preserve long-term memory.
• This is especially important in the majority of Natural Language Processing (NLP) or
time-series and sequential tasks.
For example,
• Let’s say we have a network generating text based on some input given to us.
• At the start of the text, it is mentioned that the author has a “dog named Cliff”.
• After a few other sentences where there is no mention of a pet or dog, the author
brings up his pet again, and the model has to generate the next word to "However,
Cliff, my pet ____".
• As the word pet appeared right before the blank, a RNN can deduce that the next
word will likely be an animal that can be kept as a pet.
• However, due to the short-term memory, the typical RNN will only be able to use the
contextual information from the text that appeared in the last few sentences - which is
not useful at all.
• The RNN has no clue as to what animal the pet might be as the relevant information
from the start of the text has already been lost.
• On the other hand, the LSTM can retain the earlier information that the author has a
pet dog, and this will aid the model in choosing "the dog" when it comes to generating
the text at that point due to the contextual information from a much earlier time step.
• Long Short- Term Memory (LSTM) networks are a modified version of recurrent neural
networks, which makes it easier to remember past data in memory.
Healthcare
• The healthcare sector, especially, receives great benefits from data science
applications.
• Procedures such as detecting tumors, artery stenosis, organ delineation employ various
different methods and frameworks like MapReduce to find optimal parameters for tasks
like lung texture classification.
• It applies machine learning methods, support vector machines (SVM), content-based
medical image indexing, and wavelet analysis for solid texture classification.
Internet Search
• Now, this is probably the first thing that strikes your mind when you think Data Science
Applications.
• When we speak of search, we think ‘Google’.
• But there are many other search engines like Yahoo, Bing, Ask, AOL, and so on.
• All these search engines (including Google) make use of data science algorithms to
deliver the best result for our searched query in a fraction of seconds.
• Considering the fact that, Google processes more than 20 petabytes of data every day.
Targeted Advertising
• The entire digital marketing spectrum in now a day is depending on data science
Algorithms.
• Starting from the display banners on various websites to the digital billboards at the
airports – almost all of them are decided by using data science algorithms.
• This is the reason why digital ads have been able to get a lot higher CTR (Call-Through
Rate) than traditional advertisements.
• They can be targeted based on a user’s past behavior.
• This is the reason why you might see ads of Data Science Training Programs while I see
an ad of apparels in the same place at the same time.
Website Recommendations
• You upload your image with friends on Facebook and you start getting suggestions to
tag your friends.
• This automatic tag suggestion feature uses face recognition algorithm.
• In their latest update, Facebook has outlined the additional progress they’ve made in
this area, making specific note of their advances in image recognition accuracy and
capacity.
• In addition, Google provides you with the option to search for images by uploading
them.
• It uses image recognition and provides related search results.
Speech Recognition
• Some of the best examples of speech recognition products are Google Voice, Siri,
Cortana etc.
• Using speech-recognition feature, even if you aren’t in a position to type a message,
your life wouldn’t stop.
• Simply speak out the message and it will be converted to text.
• However, at times, you would realize, speech recognition doesn’t perform accurately.
• Southwest Airlines, Alaska Airlines are among the top companies who’ve Gaming
• Games are now designed using machine learning algorithms which improve/upgrade
themselves as the player moves up to a higher level.
• In motion gaming also, your opponent (computer) analyzes your previous moves and
accordingly shapes up its game.
• EA Sports, Pubg, Sony, Nintendo, Activision-Blizzard have led gaming experience to the
next level using data science.
Image Classification
Image classification is the process of taking an input (like a picture) and outputting a class (like
“cow”) or a probability that the input is a particular class (“there’s a 90% probability that this input
is a cow”).
We can look at a picture and know that we’re looking at a cow, but how can a computer learn
to do that?
You’ll notice them, but you won’t know exactly what object I’m referring to.
And another:
▪ You’ll recognize that I want you to recognize a “Mountain”.
▪ By showing you the first two images, I essentially trained your brain to recognize a
mountain in the third image.
▪ The process is (almost) the same for computers — our data needs to be in a specific
format.
▪ Our model will be trained on the images present in a “training”set and the label
predictions will happen on the testing set images.
Recommender systems
▪ Recommender systems are the systems that are designed to recommend things to the
user based on many different factors.
▪ These systems predict the most likely product that the users are most likely to
purchase and are of interest to.
▪ Companies like Netflix, Amazon, etc. use recommender systems to help their users to
identify the correct product or movies for them.
▪ The recommender system deals with a large volume of information present by filtering
the most important information based on the data provided by a user and other
factors that take care of the user’s preference and interest.
▪ It finds out the match between user and item and imputes the similarities between
users and items for recommendation.
▪ Both the users and the services provided have benefited from these kinds of systems.
The quality and decision-making process has also improved through these kinds of
systems.
▪ There are many different things that can be recommended by the system like movies,
books, news, articles, jobs, advertisements, etc.
▪ Netflix uses a recommender system to recommend movies & web-series to its users.
Similarly, YouTube recommends different videos.
There are many examples of recommender systems that are widely used today.
Classification model
The output can be either 0 or 1. If the user likes it then 1 and vice-versa.
3. Content-Based Recommendation System
▪ It is another type of recommendation system which works on the principle of similar
content.
▪ If a user is watching a movie, then the system will check about other movies of similar
content or the same genre of the movie the user is watching.
▪ There are various fundamentals attributes that are used to compute the similarity
while checking about similar content.
▪ To explain more about how exactly the system works, an example is stated below:
▪ Edges represent the connections between the nodes, and might hold properties as well
(such as weight representing the strength of the connection, direction in case of
asymmetric relation or time if applicable).
▪ These two basic elements can describe multiple phenomena, such as social
connections, virtual routing network, physical electricity networks, roads network,
biology relations network and many other relationships.
Real-world networks
Real-world networks and in particular social networks have a unique structure which often
differs them from random mathematical networks:
A social network graph is a graph where the nodes represent people and the lines between
nodes, called edges, represent social connections between them, such as friendship or working
together on a project.
For instance, Facebook can be described with an undirected graph since the friendship is
bidirectional, Alice and Bob being friends is the same as Bob and Alice being friends. On the
other hand, Twitter can be described with a directed graph: Alice can follow Bob without Bob
following Alice.
Social networks are important to social scientists interested in how people interact as well as
companies trying to target consumers for advertising.