Ds Unit V Ann Perceptron
Ds Unit V Ann Perceptron
Unit-V
From: Tom M. Mitchell, Machine Learning, India Edition 2013, McGraw Hill
Education.
ARTIFICIAL NEURAL
NETWORKS 1
CONTEN
T
• Introduction
• Neural Network Representation
• Appropriate Problems for Neural Network Learning
• Perceptrons
• Multilayer Networks and BACKPROPAGATION Algorithms
• Remarks on the BACKPROPAGATION Algorithms
• Advanced Topics in Artificial Neural Networks.
• Case Study: Defeating a CAPTCHA
2
Introduction: How can we answer this problems?
Examples:
1. Speech phoneme recognition
2. Image classification
3. Financial perdition
4
INTRODUCTION
5
Biological Motivation
• The study of artificial neural networks (ANNs) has been inspired by the
observation that biological learning systems are built of very complex webs of
interconnected Neurons
• Human information processing system consists of brain neuron: basic building
block cell that communicates information to and from various parts of body
• Simplest model of a neuron: considered as a threshold unit –a processing element
(PE)
• Collects inputs & produces output if the sum of the input exceeds an internal
threshold value
6
Facts of Human Neurobiology
Properties of Neuron:
• Many neuron-like threshold switching units
• Many weighted interconnections among units
• Highly parallel, distributed process
• Emphasis on tuning weights automatically
• Input is a high-dimensional discrete or real-valued (e.g, sensor input)
7
Neuron
8
What Is an Artificial Neural Network (ANN)?
Structure of ANN:
9
Topological units of ANN:
Neural Network.
Is
a Mathematical model.
Inspired by Human biological neurons and now leading in
solving many real world problems
ANN topology Units include:
Neurons.
Layers.
Connecting Links.
Initial weights(on links)
10
Properties of ANNs
11
ANN Architecture:
Bias
b
x1 w1
Activation
Local function
Field
Output
x2 w2 v
y
Input
values
Summing
function
xm wm
weights
12
Activation Functions
13
Activation Functions:
14
Why nonlinear Activation function: (ex: sigmoid)
• Linear functions always do exhibit a constant slope.
• Slope as we know pictures the rate of change of the predictor variable (y)
with respect to the independent variable (x).
• Real-world problems emphasize on finding the points of minimal or
maximal change: may be minimization of loss or maximization of gain.
• If we take linear activation functions, these changes are constant and
cannot be distinguishable between points of minimal and maximal
changes.
• Nonlinear activation functions have gradients that vary between various
points.
• Based on these gradients descent or accent, we can address all the
minimization and maximization problems.
.
15
Why nonlinear Activation function: (ex: sigmoid)
• The nonlinear exponential function eX has a range between [0, ∞] and has
an infinite range.
• The gradients for the function eX exist between [0, ∞].
• To find the optimal gradients, it is quite difficult within this infinite range.
• Hence, such functions though nonlinear cannot be taken as activation
functions.
• Hence, the needs for activation functions which show active gradients
within shorter intervals are needed.
• One such is the sigmoid activation function which will analyze the
gradients between a small [0, 1] interval
16
• Input to neuron: x = (weight * input) + bias
17
Role of Bias:
18
Types of Activation functions
19
Types of Activation functions
20
Neural Networks representation
21
• Figure illustrates the neural network representation.
• The network is shown on the left side of the figure, with the input camera image depicted below it.
• Each node (i.e., circle) in the network diagram corresponds to the output of a
single network unit, and the lines entering the node from below are its inputs.
• There are four units that receive inputs directly from all of the 30 x 32 pixels in the image. These are called
"hidden" units because their output is available only within the network and is not available as part of the global
network output. Each of these four hidden units computes a single real-valued output based on a weighted
combination of its 960 inputs
• These hidden unit outputs are then used as inputs to a second layer of 30 "output"
units.
• Each output unit corresponds to a particular steering direction, and the output values of these units determine
which steering direction is recommended most strongly.
• The diagrams on the right side of the figure depict the learned weight values associated with one of the
four hidden units in this ANN.
• The large matrix of black and white boxes on the lower right depicts the weights from the 30 x 32
pixel inputs into the hidden unit. Here, a white box indicates a positive weight, a black box a negative weight,
and the size of the box indicates the weight magnitude.
• The smaller rectangular diagram directly above the large matrix shows the weights from this hidden unit
to each of the 30 output units.
22
APPROPRIATE PROBLEMS FOR NEURAL NETWORK LEARNING
23
Architectures of Artificial Neural Networks
An artificial neural network can be divided into three parts (layers), which are
known as:
• Input layer: This layer is responsible for receiving information (data), signals,
features, or measurements from the external environment. These inputs are usually
normalized within the limit values produced by activation functions
• Hidden, intermediate, or invisible layers: These layers are composed of neurons
which are responsible for extracting patterns associated with the process or system
being analysed. These layers perform most of the internal processing from a
network.
• Output layer : This layer is also composed of neurons, and thus is responsible for
producing and presenting the final network outputs, which result from the
processing performed by the neurons in the previous layers.
24
Architectures of Artificial Neural Networks
25
Single-Layer Feedforward Architecture
• This artificial neural network has just one input layer and a single neural layer, which is also the
output layer.
• Figure illustrates a simple-layer feedforward network composed of n inputs and m outputs.
• The information always flows in a single direction (thus, unidirectional), which is from the input
layer to the output layer
26
Multi-Layer Feedforward Architecture
• This artificial neural feedforward networks with multiple layers are composed of one or more
hidden neural layers.
• Figure shows a feedforward network with multiple layers composed of one input layer with n
sample signals, two hidden neural layers consisting of n1 and n2 neurons respectively, and, finally,
one output neural layer composed of m neurons representing the respective output values of the
problem being analyzed.
27
Recurrent or Feedback Architecture
• In these networks, the outputs of the neurons are used as feedback inputs for other neurons.
• Figure illustrates an example of a Perceptron network with feedback, where one of its
output
signals is fed back to the middle layer.
28
Mesh Architectures
• The main features of networks with mesh structures reside in considering the spatial arrangement
of neurons for pattern extraction purposes, that is, the spatial localization of the neurons is directly
related to the process of adjusting their synaptic weights and thresholds.
• Figure illustrates an example of the Kohonen network where its neurons are arranged within a two-
dimensional space
29
PERCEPTRONS
• Perceptron is a single layer neural network.
• A perceptron takes a vector of real-valued inputs, calculates a linear combination
of these inputs, then outputs a 1 if the result is greater than some threshold and -
1 otherwise
• Given inputs x1 through xn, the output O(x1, . . . , xn) computed by the perceptron
is
30
Sometimes, the perceptron function is written
as,
34
The Perceptron Training Rule
The learning problem is to determine a weight vector that causes the perceptron to
produce the correct + 1 or - 1 output for each of the given training examples.
35
• The role of the learning rate is to moderate the degree to which weights are
changed at each step. It is usually set to some small value (e.g., 0.1) and is
sometimes made to decay as the number of weight-tuning iterations increases
Drawback: The perceptron rule finds a successful weight vector when the training
examples are linearly separable, it can fail to converge if the examples are not
linearly separable. This can overcome with Gradient decent Delta rule
36
Perceptron Algorithm
37
38
39
40
41
42
Design perceptron model for Exclusive OR Gate
43
44
45
46
47
48
49
Exercises:
50
Gradient Descent and the Delta Rule
51
Gradient Descent and the Delta Rule
52
Gradient Descent and the Delta Rule
To derive a weight learning rule for linear units, specify a measure for the training
error of a hypothesis (weight vector), relative to the training examples.
Where,
• D is the set of training examples,
• td is the target output for training example d,
• od is the output of the linear unit for training example d
• E [ w ] is simply half the squared difference between the target
output td and the linear unit output od, summed over all training
examples.
53
Visualizing the Hypothesis Space
54
Visualizing the Hypothesis Space
• Given the way in which we chose to define E, for linear units this error surface must always
be parabolic with a single global minimum.
Gradient descent search determines a weight vector that minimizes E by starting with an
arbitrary
initial weight vector, then repeatedly modifying it in small steps.
At each step, the weight vector is altered in the direction that produces the steepest descent along
the error surface depicted in above figure. This process continues until the global minimum error is
55
reached.
Derivation of the Gradient Descent Rule
How to calculate the direction of steepest descent along the error surface?
The direction of steepest can be found by computing the derivative of E with respect
to each component of the vector w . This vector derivative is called the gradient of
E with respect to w , written as
56
• The gradient specifies the direction of steepest increase of E, the training rule for
gradient descent is
• Here η is a positive constant called the learning rate, which determines the
step
size in the gradient descent search.
• The negative sign is present because we want to move the weight vector in
the direction that decreases E
• This training rule can also be written in its component form
57
𝜕𝐸
Calculate the gradient at each step. The vector derivatives that form the gradient can be obtained
𝜕𝑤𝑖
of differentiating E from Equation (2), as by
58
GRADIENT DESCENT algorithm for training a linear unit
To summarize, the gradient descent algorithm for training linear units is as follows:
• Pick an initial random weight vector.
• Apply the linear unit to all training examples, then compute Δwi for each weight according to Equation (7).
• Update each weight wi by adding Δwi, then repeat this process 59
Features of Gradient Descent Algorithm
60
Stochastic Approximation to Gradient Descent
• The gradient descent training rule presented in Equation (7) computes weight
updates after summing over all the training examples in D
• The idea behind stochastic gradient descent is to approximate this gradient descent
search by updating weights incrementally, following the calculation of the error
for each individual example
where t, o, and xi are the target value, unit output, and ith input for the training
example in question
61
One way to view this stochastic gradient descent
is to consider a distincterror function Ed ( w ) for each
individual training example d as follows
Where, td and od are the target value and the unit output value for training example d.
• Stochastic gradient descent iterates over the training examples d in D, at each
iteration altering the weights according to the gradient with respect to Ed( w )
• The sequence of these weight updates, when iterated over all training examples,
provides a reasonable approximation to descending the gradient with respect to
our original error function Ed ( w )
• By making the value of η sufficiently small, stochastic gradient descent can
be made to approximate true gradient descent arbitrarily closely
62
The key differences between standard gradient descent and stochastic gradient
descent are
• In standard gradient descent, the error is summed over all examples before
updating weights, whereas in stochastic gradient descent weights are updated upon
examining each training example.
• Summing over multiple examples in standard gradient descent requires more
computation per weight update step. On the other hand, because it uses the true
gradient, standard gradient descent is often used with a larger step size per weight
update than stochastic gradient descent.
• In cases where there are multiple local minima with respect to stochastic gradient
descent can sometimes avoid falling into these local minima because it uses the
various 𝛻Ed ( w ) rather than 𝛻E ( w ) to guide its search
63
64
Types of Gradient descent
68
69