Unit 1 Notes
Unit 1 Notes
1
St. Joseph’s Institute of Technology 4653 – Deep Learning
a. Fundamentals of ANN
Neural computing is an information processing paradigm, inspired by biological system,
composed of a large number of highly interconnected processing elements(neurons) working in
unison to solve specific problems.
Artificial neural networks (ANNs), like people, learn by example. An ANN is configured
for a specific application, such as pattern recognition or data classification, through a learning
process. Learning in biological systems involves adjustments to the synaptic connections that exist
between the neurons. This is true of ANNs as well.
b. The Biological Neuron
The human brain consists of a large number, more than a billion of neural cells that process
information. Each cell works like a simple processor. The massive interaction between all cells and
2
St. Joseph’s Institute of Technology 4653 – Deep Learning
their parallel processing only makes the brain’s abilities possible. Figure 1 represents a human
biological nervous unit. Various parts of biological neural network(BNN) is marked in Figure 1.
5
St. Joseph’s Institute of Technology 4653 – Deep Learning
Every input pattern that is used to train the network is associated with an output pattern which is
the target or the desired pattern.
A teacher is assumed to be present during the training process, when a comparison is made
between the network’s computed output and the correct expected output, to determine the [Link]
error can then be used to change network parameters, which result in an improvement in
performance.
[Link] Unsupervised learning:
In this learning method the target output is not presented to the [Link] is as if there is no
teacher to present the desired patterns and hence the system learns of its own by discovering and
adapting to structural features in the input patterns.
[Link] Reinforced learning:
In this method, a teacher though available, doesnot present the expected answer but only
indicates if the computed output correct or [Link] information provided helps the network in
the learning process.
[Link] Hebbian learning:
learning mechanism inspired by [Link] this, the input-output pattern pairs (𝑥𝑖, 𝑦𝑖) are
This rule was proposed by Hebb and is based on correlative weight [Link] is the oldest
Here 𝑦𝑖𝑇 is the transposeof the associated output vector 𝑦𝑖.Numerous variants of the rule have
been proposed.
[Link] Gradient descent learning:
This is based on the minimization of error E defined in terms of weights and activation function
of the [Link] it is required that the activation function employed by the network is
differentiable, as the weight update is dependent on the gradient of the error E.
Thus if ∆𝑤𝑖𝑗 is the weight update of the link connecting the 𝑖𝑡ℎ and 𝑗𝑡ℎ neuron of the two
neighbouring layers, then ∆𝑤𝑖𝑗 is defined as,
∆𝑤𝑖𝑗 =
𝛛𝐸ɳ
-----------eq(2)
𝛛𝑤
𝑖𝑗
𝛛𝐸
Where, ɳ is the learning rate parameter and
𝛛𝑤𝑖𝑗
weight 𝑤𝑖𝑗.
is the error gradient with reference to the
6
St. Joseph’s Institute of Technology 4653 – Deep Learning
1.5.1 Simple Perceptron for Pattern Classification
Perceptron network is capable of performing pattern classification into two or more
categories. The perceptron is trained using the perceptron learning rule. We will first consider
classification into two categories and then the general multiclass classification later. For
classification
7
St. Joseph’s Institute of Technology 4653 – Deep Learning
into only two categories, all we need is a single output neuron. Here we will use bipolar neurons.
The simplest architecture that could do the job consists of a layer of N input neurons, an output
layer with a single output neuron, and no hidden layers. This is the same architecture as we saw
before for Hebb learning. However, we will use a different transfer function here for the output
neurons as given below in eq (7). Figure 7 represents a single layer perceptron network.
eq (7)
Equation 7 gives the bipolar activation function which is the most common function used in
the perceptron networks. Figure 7 represents a single layer perceptron network. The inputs arising
from the problem space are collected by the sensors and they are fed to the aswociation
[Link] units are the units which are responsible to associate the inputs based on their
similarities. This unit groups the similar inputs hence the name association unit. A single input
from each group is given to the summing [Link] are randomnly fixed intially and assigned to
this inputs. The net value is calculate by using the expression
x = Σ wiai – θ eq(8)
This value is given to the activation function unit to get the final output [Link] actual
output is compared with the Target or desired .If they are same then we can stop training else the
weights haqs to be updated .It means there is error .Error is given as δ = b-s , where b is the desired
8
St. Joseph’s Institute of Technology 4653 – Deep Learning
/ Target output and S is the actual outcome of the machinehere the weights are updated based on the
perceptron Learning law as given in equation 9.
Weight change is given as Δw= η δ ai. So new weight is given as
Wi (new) = Wi (old) + Change in weight vector (Δw) eq(9)
1.5.2. Perceptron Algorithm
Step 1: Initialize weights and [Link] simplicity, set weights and bias to [Link] learning
rate in the range of zero to one.
• Step 2: While stopping condition is false do steps 2-6
• Step 3: For each training pair s:t do steps 3-5
• Step 4: Set activations of input units xi = ai
• Step 5: Calculate the summing part value Net = Σ aiwi-θ
• Step 6: Compute the response of output unit based on the activation functions
• Step 7: Update weights and bias if an error occurred for this pattern(if yis not equal to t)
Weight (new) = wi(old) + atxi , & bias (new) = b(old) + at
Else wi(new) = wi(old) & b(new) = b(old)
• Step 8: Test Stopping Condition
1.5.3. Limitations of single layer perceptrons:
• Uses only Binary Activation function
• Can be used only for Linear Networks
• Since uses Supervised Learning ,Optimal Solution is provided
• Training Time is More
• Cannot solve Linear In-separable Problem
9
St. Joseph’s Institute of Technology 4653 – Deep Learning
1. Initialize the weights (Wi) & Bias (B0) to small random values near Zero
2. Set learning rate η or α in the range of “0” to “1”
3. Check for stop condition. If stop condition is false do steps 3 to 7
4. For each Training pairs do step 4 to 7
5. Set activations of Output units: xi = si for i=1 to N
6. Calculate the output Response
yin = b0 + Σ xiwi
7. Activation function used is Bipolar sigmoidal or Bipolar Step functions
For Multi Layer networks, based on the number of layers steps 6 & 7 are repeated
8. If the Targets is (not equal to) = to the actual output (Y), then update weights and bias
based on Perceptron Learning Law
Wi (new) = Wi (old) + Change in weight vector
Change in weight vector = ηtixi
Where η = Learning Rate
ti = Target output of ith unit
xi = ith Input vector
b0(new) = b0 (old) + Change in Bias
Change in Bias = ηti
Else Wi (new) = Wi (old)
b0(new) = b0 (old)
10
St. Joseph’s Institute of Technology 4653 – Deep Learning
11
St. Joseph’s Institute of Technology 4653 – Deep Learning
1.6. linearly seperable & Linear in separable tasks:
Perceptron are successful only on problems with a linearly separable solution [Link] 9
represents both linear separable as well as linear in seperable [Link] cannot handle, in
particular, tasks which are not linearly separable.(Known as linear inseparable problem).Sets of
points in two dimensional spaces are linearly separable if the sets can be seperated by a straight
[Link], a set of points in n-dimentional space are that can be seperated by a straight
[Link] called Linear seperable as represented in figure 9.
Single layer perceptron can be used for linear [Link] AND [Link] it cant be
used for non linear ,inseparable problems.(Example XOR Gate).Consider figure 10.
12
St. Joseph’s Institute of Technology 4653 – Deep Learning
Convex regions can be created by multiple decision lines arising from multi layer
[Link] layer network cannot be used to solve inseparable [Link] we go for
multilayer network there by creating convex regions which solves the inseparable problem.
1.6.1 Convex Region:
Select any Two points in a region and draw a straight line between these two points. If the
points selected and the lines joining them both lie inside the region then that region is known as
convex regions.
1.6.2. Types of convex regions
(a) Open Convex region (b) Closed Convex region
Figure 9 A: Circle - Closed convex region Figure 9 B: Triangle - Closed convex region
1.7. Logistic Regression
Logistic regression is a probabilistic model that organizes the instances in terms of
probabilities. Because the classification is probabilistic, a natural method for optimizing the
parameters is to ensure that the predicted probability of the observed class for each training
occurrence is as large as possible. This goal is achieved by using the notion of maximumlikelihood
estimation in order to learn the parameters of the model. The likelihood of the training data is
defined as the product of the probabilities of the observed labels of each training instance. Clearly,
larger values of this objective function are better. By using the negative logarithm of this value, one
obtains a loss function in minimization form. Therefore, the output node uses the negative log-
likelihood as a loss function. This loss function replaces the squared error used in the Widrow-Hoff
method. The output layer can be formulated with the sigmoid activation function, which is very
common in neural network design.
13
St. Joseph’s Institute of Technology 4653 – Deep Learning
Logistic regression is another supervised learning algorithm which is
used to solve the classification problems. In classification problems, we
have dependent variables in a binary or discrete format such as 0 or 1.
14
St. Joseph’s Institute of Technology 4653 – Deep Learning
1.8. Support Vector Machines
Support Vector Machine or SVM is one of the most popular Supervised Learning
algorithms, which is used for Classification as well as Regression problems. However,
primarily, it is used for Classification problems in Machine Learning. The goal of the SVM
algorithm is to create the best line or decision boundary that can segregate n-dimensional space
into classes so that we can easily put the new data point in the correct category in the future.
This best decision boundary is called a hyperplane. SVM chooses the extreme points/vectors
that help in creating the hyperplane. These extreme cases are called as support vectors, and
hence algorithm is termed as Support Vector Machine. Consider the below diagram in which
there are two different categories that are classified using a decision boundary or hyperplane :
Non-linear SVM: Non-Linear SVM is used for non-linearly separated data, which means if a
dataset cannot be classified by using a straight line, then such data is termed as non-linear data
and classifier used is called as Non-linear SVM classifier
Support Vectors:
The data points or vectors that are the closest to the hyperplane and which affect the position of
the hyperplane are termed as Support Vector. Since these vectors support the hyperplane, hence
called a Support vector.
15
St. Joseph’s Institute of Technology 4653 – Deep Learning
16
St. Joseph’s Institute of Technology 4653 – Deep Learning
Gradient Descent is known as one of the most commonly used optimization algorithms to train
machine learning models by means of minimizing errors between actual and expected results.
Further, gradient descent is also used to train Neural Networks.
In mathematical terminology, Optimization algorithm refers to the task of minimizing/maximizing an
objective function f(x) parameterized by x. Similarly, in machine learning, optimization is the task of
minimizing the cost function parameterized by the model's parameters. The main objective of
gradient descent is to minimize the convex function using iteration of parameter updates. Once these
machine learning models are optimized, these models can be used as powerful tools for Artificial
Intelligence and various computer science applications.
In this tutorial on Gradient Descent in Machine Learning, we will learn in detail about gradient
descent, the role of cost functions specifically as a barometer within Machine Learning, types of
gradient descents, learning rates, etc.
What is Gradient Descent or Steepest Descent?
Gradient descent was initially discovered by "Augustin-Louis Cauchy" in mid of 18th
century. Gradient Descent is defined as one of the most commonly used iterative optimization
algorithms of machine learning to train the machine learning and deep learning models. It helps
in finding the local minimum of a function.
The best way to define the local minimum or local maximum of a function using gradient descent is
as follows:
o If we move towards a negative gradient or away from the gradient of the function at the
current point, it will give the local minimum of that function.
o Whenever we move towards a positive gradient or towards the gradient of the function at the
current point, we will get the local maximum of that function.
17
St. Joseph’s Institute of Technology 4653 – Deep Learning
This entire procedure is known as Gradient Ascent, which is also known as steepest descent. The
main objective of using a gradient descent algorithm is to minimize the cost function using
iteration. To achieve this goal, it performs two steps iteratively:
o Calculates the first-order derivative of the function to compute the gradient or slope of that
function.
o Move away from the direction of the gradient, which means slope increased from the current
point by alpha times, where Alpha is defined as Learning Rate. It is a tuning parameter in the
optimization process which helps to decide the length of the steps.
What is Cost-function?
The cost function is defined as the measurement of difference or error between actual values and
expected values at the current position and present in the form of a single real number. It helps to
increase and improve machine learning efficiency by providing feedback to this model so that it can
minimize error and find the local or global minimum. Further, it continuously iterates along the
direction of the negative gradient until the cost function approaches zero. At this steepest descent
point, the model will stop learning further. Although cost function and loss function are considered
synonymous, also there is a minor difference between them. The slight difference between the loss
function and the cost function is about the error within the training of machine learning models, as
loss function refers to the error of one training example, while a cost function calculates the average
error across an entire training set.
The cost function is calculated after making a hypothesis with initial parameters and modifying these
parameters using gradient descent algorithms over known data to reduce the cost function.
How does Gradient Descent work?
Before starting the working principle of gradient descent, we should know some basic concepts to
find out the slope of a line from linear regression. The equation for simple linear regression is given
as:
1. Y=mX+c
Where 'm' represents the slope of the line, and 'c' represents the intercepts on the y-axis.
18
St. Joseph’s Institute of Technology 4653 – Deep Learning
The starting point(shown in above fig.) is used to evaluate the performance as it is considered just as
an arbitrary point. At this starting point, we will derive the first derivative or slope and then use a
tangent line to calculate the steepness of this slope. Further, this slope will inform the updates to the
parameters (weights and bias).
The slope becomes steeper at the starting point or arbitrary point, but whenever new parameters are
generated, then steepness gradually reduces, and at the lowest point, it approaches the lowest point,
which is called a point of convergence.
The main objective of gradient descent is to minimize the cost function or the error between expected
and actual. To minimize the cost function, two data points are required:
o Direction & Learning Rate
These two factors are used to determine the partial derivative calculation of future iteration and allow
it to the point of convergence or local minimum or global minimum. Let's discuss learning rate
factors in brief;
Learning Rate:
It is defined as the step size taken to reach the minimum or lowest point. This is typically a small
value that is evaluated and updated based on the behavior of the cost function. If the learning rate is
high, it results in larger steps but also leads to risks of overshooting the minimum. At the same time,
a low learning rate shows the small step sizes, which compromises overall efficiency but gives the
advantage of more precision.
19
St. Joseph’s Institute of Technology 4653 – Deep Learning
Whenever the slope of the cost function is at zero or just close to zero, this model stops learning
further. Apart from the global minimum, there occur some scenarios that can show this slop, which is
saddle point and local minimum. Local minima generate the shape similar to the global minimum,
where the slope of the cost function increases on both sides of the current points.
21
St. Joseph’s Institute of Technology 4653 – Deep Learning
In contrast, with saddle points, the negative gradient only occurs on one side of the point, which
reaches a local maximum on one side and a local minimum on the other side. The name of a saddle
point is taken by that of a horse's saddle.
The name of local minima is because the value of the loss function is minimum at that point in a
local region. In contrast, the name of the global minima is given so because the value of the loss
function is minimum there, globally across the entire domain the loss function.
2. Vanishing and Exploding Gradient
In a deep neural network, if the model is trained with gradient descent and backpropagation, there
can occur two more issues other than local minima and saddle point.
Vanishing Gradients:
Vanishing Gradient occurs when the gradient is smaller than expected. During backpropagation, this
gradient becomes smaller that causing the decrease in the learning rate of earlier layers than the later
layer of the network. Once this happens, the weight parameters update until they become
insignificant.
Exploding Gradient:
Exploding gradient is just opposite to the vanishing gradient as it occurs when the Gradient is too
large and creates a stable model. Further, in this scenario, model weight increases, and they will be
represented as NaN. This problem can be solved using the dimensionality reduction technique, which
helps to minimize complexity within the model.
22
St. Joseph’s Institute of Technology 4653 – Deep Learning
BACKPROPAGATION:
23
St. Joseph’s Institute of Technology 4653 – Deep Learning
ARCHITECTURE:
24
St. Joseph’s Institute of Technology 4653 – Deep Learning
TRAINING ALGORITHM:
25
St. Joseph’s Institute of Technology 4653 – Deep Learning
26