Machine Learning
What is Machine Learning?
Machine Learning algorithms
enable the computers to learn
from data, and even improve
themselves, without being
explicitly programmed.
Types of ML
Machine learning can be
classified into 3 types of
algorithms.
Supervised Learning
Unsupervised Learning
Reinforcement Learning
Supervised ML
In Supervised learning, an AI system
is presented with data which is
labeled, which means that each
data tagged with the correct label.
The goal is to approximate the
mapping function so well that when
you have new input data (x) that
you can predict the output variables
(Y) for that data.
• As shown in the above example, we have initially taken
some data and marked them as ‘Spam’ or ‘Not Spam’. This
labeled data is used by the training supervised model, this
data is used to train the model.
• Once it is trained, we can test our model by testing it with
some test new mails and checking of the model is able to
predict the right output.
Types of Supervised
ML
Classification: A classification
problem is when the output
variable is a category, such as
“red” or “blue” or “disease” and
“no disease”.
Regression: A regression
problem is when the output
variable is a real value, such as
“dollars” or “weight”.
Unsupervised ML
In unsupervised learning, an AI
system is presented with
unlabeled, uncategorized data
and the system’s algorithms act
on the data without prior
training.
The output is dependent upon
the coded algorithms.
Subjecting a system to
unsupervised learning is one
• In the above example, we have given some
characters to our model which are ‘Ducks’ and
‘Not Ducks’. In our training data, we don’t provide
any label to the corresponding data.
• The unsupervised model is able to separate both
the characters by looking at the type of data and
models the underlying structure or distribution in
the data in order to learn more about it.
Types of Unsupervised learnin
Clustering: A clustering problem is where
you want to discover the inherent
groupings in the data, such as grouping
customers by purchasing behavior.
Association: An association rule learning
problem is where you want to discover
rules that describe large portions of your
data, such as people that buy X also tend
Reinforcement Learning
A reinforcement learning algorithm, or agent,
learns by interacting with its environment.
The agent receives rewards by performing
correctly and penalties for performing
incorrectly.
The agent learns without intervention from a
human by maximizing its reward and
minimizing its penalty. It is a type of dynamic
programming that trains algorithms using a
system of reward and punishment.
• In the above example, we can see that the agent is given 2 options
i.e. a path with water or a path with fire. A reinforcement algorithm
works on reward a system i.e. if the agent uses the fire path then
the rewards are subtracted and agent tries to learn that it should
avoid the fire path.
• If it had chosen the water path or the safe path then some points
would have been added to the reward points, the agent then would
try to learn what path is safe and what path isn’t.
Neural network and Deep
Learning
A neural network mimics the way the
biological neurons in the human brain
work, while a deep learning network
comprises several layers of neural
networks.
A neural network is a form of machine
learning that models the interconnected
neurons of the human brain
Neural network and Deep
Learning
In the human brain, each neuron interconnects
with another neuron to receive information,
process it, and pass it to other neurons.
In much the same way, neural networks
receive information in the input layer, process
it through at least one hidden layer, and then
pass the result to the output layer.
Therefore, in its simplest form, a neural
network comprises an input layer, a
hidden layer, and an output layer
Deep Learning
Deep learning, on the other hand, is
made up of several hidden layers of
neural networks that perform
complex operations on massive
amounts of structured (text) and
unstructured(images , voice) data.
In contrast, DL algorithms can identify
patterns in real-world data such as
images, text, sound, and time series.
Key Terms
Neuron — This is a basic building block
of a NN. It takes weighted values,
performs mathematical calculation and
produce output. It is also called a unit,
node or perceptron.
Input — This is the data/values passed
to the neurons.
Here’s what a 2-input neuron
looks like:
Deep Neural Network (DNN) — This is an ANN
with many hidden layers (layers between the
input (first) layer and the output (last) layer).
Weights — These values explain
the strength (degree of
importance) of the connection
between any two neurons. Bias —
is a constant value added to the
sum of the product between input
values and respective weights. It is
used to accelerate or delay the
activation of a given node.
The input is fed to the input layer,
the neurons perform a linear
transformation on this input using
the weights and biases.
x = (weight * input) + bias
Activation function — is a function
used to introduce the non-linearity
phenomenon into the NN system.
This property will allow the
network to learn more complex
patterns.
Note: weights and biases are the trainable
parameters in NN, that is, the network learns
patterns by tuning these parameters to get the best
Mathematical Operation
on one Neuron
An artificial neuron takes input values (it
can be several) with weights assigned to
them. Inside the node, the weighted inputs
are summed up, and an activation function
is applied to get the results.
The output of the node is passed on to the
other nodes or, in the case of the last layer
of the network, the output is the overall
output of the network.
A single neuron, like the one shown
above, performs the following
mathematical operation,
In the Equation, four things are happening —
input is multiplied with the respective
weights and added, bias is added to the
result, and then an activation function, g, is
applied so that the output of the neuron is
Neural Network Design
A Neural Network(NN) is made of several
neurons stacked into layers. For an n-
dimensional input, the first layer (also
called the input layer) will have n nodes and
the t-dimensional final/output layer will
have t neural units.
All intermediate layers are called hidden
layers, and the number of layers in a network
determines the depth of the model. The
Figure below shows a 3–4–4–1 NN.
The Figure below shows a 3–4–4–
1 NN.
A Neural network with 3 input features, two hidden layers
with 4 nodes each and one-value output. The nodes are
densely connected- each node is connected to all the
neurons in the immediate previous layer. Every node
performs the computation described above except the
Simplified Example
Let’s take a simple example of how
a single neuron work. In this
example, we assume 3 input
values and a bias of 0.
Neuron with 3 input
values 2, 1, -4 and
the weights 0.8,
0.12 and 0.3,
respectively. The
bias in this case is
In this example, we will consider a
commonly used activation function
called Sigmoid which is defined as :
As said before, four things are
happening inside the neuron. First,
the input values are weighted by
multiplying the input values with
corresponding weights.
Next, is to sum the weighted input
then add the bias,
and lastly, sigmoid activation
function is applied on the above
result
The output of the neuron is 0.627. If the given neuron is
in the hidden layer, then this output becomes the input of
the next neuron(s). On the other hand, if this value is the
output of the last layer, then it can be interpreted as the
final prediction of the model (it can be seen as the
probability of a given class)
Other activation functions
[Explore Yourself]
1. Tanh
2. ReLU
3. Leaky ReLU
4. Parameterised ReLU
5. Exponential Linear Unit
6. Swish
7. Softmax
Feedforward ANN and
Backpropagation
A feedforward Artificial Neural Network
(ANN) is a type of neural network in
which the information flows in only one
direction, from the input layer, through
one or more hidden layers, to the output
layer, without any feedback loops.
It is called "feedforward" because the
data only moves forward through the
network and never loops back on itself.
During training, the weights of the
connections between the neurons
are adjusted using
backpropagation to minimize the
error between the predicted output
and the actual output. Once the
network is trained, it can be used
to make predictions on new data.
Example
Calculate the value of y1,y2 and
total mean squared error for one
forward pass by using sigmoid
activation function.
Total mean squared error
After calculating the error, we must
back propagate to update the weights
(w1 to w8) by using gradient descent
algorithm and learning rate
parameter [Explore yourself (needs
knowledge of partial derivatives and
local minimum of a function)] for
minimizing error.
Repeat this process (Feed forward -
>Error Calculation ->Update weights by
back propagation) until error reduced
near to zero.
Types of neural networks popular
in deep learning
The different types of neural networks
in deep learning, such as
convolutional neural networks
(CNN), recurrent neural networks
(RNN), artificial neural networks
(ANN), etc. are changing the way we
interact with the world.
These different types of neural networks
are at the core of the deep learning
revolution, powering applications like
unmanned aerial vehicles, self-driving
What is an ANN and why
should you use it?
Artificial Neural Network, or ANN, is a group of multiple
neurons at each layer. ANN is also known as a Feed-
Forward Neural network because inputs are
processed only in the forward direction. It's suitable for
tabular data.
Problems in ANN
ANN loses the spatial features of an image.
Spatial features refer to the arrangement of
the pixels in an image.
In the case of a very deep neural network
(network with many hidden layers, used in
computer vision), the gradient vanishes can
occur. So, it will stuck at one point and will not
reduce the error further.
ANN cannot capture sequential information in
the input data which is required for dealing
with sequence data [Sequential data
includes text streams, audio clips, video clips,
time-series data and etc]
What is an RNN and why
should you use it?
A recurrent neural network (RNN)
is a type of artificial neural network
which uses sequential data or time
series data.
They are incorporated into popular
applications such as Siri, voice
search, and Google Translate
They are distinguished by their
“memory” as they take information
from prior inputs to influence the
current input and output
While traditional deep neural
networks assume that inputs and
outputs are independent of each
other, the output of recurrent neural
networks depend on the prior
As you can see here, the output (o1, o2, o3, o4) at each time step
depends not only on the current word but also on the previous
words.
Problem in RNN
Deep RNNs (RNNs with a large
number of time steps) also suffer
from the vanishing and exploding
gradient problem which is a
common problem in all the
different types of neural networks.
CNN
CNN models are being used across
different applications and domains,
and they’re especially prevalent in
image and video processing
projects.
The building blocks of CNNs
are filters a.k.a.
kernels. Kernels are used to
extract the relevant features from
CNN learns the filters automatically without
mentioning it explicitly. These filters help in
extracting the right and relevant features from
the input data
CNN captures the spatial
features from an image.
In the above image, we can easily identify that
its a human’s face by looking at specific
features like eyes, nose, mouth and so on. We
can also see how these specific features are
arranged in an image. That’s exactly what
CNNs are capable of capturing