SlideShare a Scribd company logo
1 of 19
Download to read offline
1
Lecture 2: Single Layer Perceptrons
Kevin Swingler
kms@cs.stir.ac.uk
2
Recap: McCulloch-Pitts Neuron
• This vastly simplified model of real neurons is also known as a Threshold
Logic Unit:
1. A set of synapses (i.e. connections) brings in activations from other
neurons
2. A processing unit sums the inputs, and then applies a non-linear
activation function
3. An output line transmits the result to other neurons
I1
∑
Wj1
Wjn
I2
I3
In
Aj Yj
3
Networks of McCulloch-Pitts Neurons
One neuron can’t do much on its own. Usually we will have many neurons
labelled by indices k, i, j and activation flows between via synapses with
strengths wki, wij:
)
sgn(
1
i
n
k
ki
i I
Y θ
−
= ∑
=
ki
k
ki w
Y
I ⋅
= ij
i
ij w
Y
I ⋅
=
I1i
I2i
I3i
Iki
Neuron i
Yi
Synapse ij
Iij
Neuron j
θi
wij
∑
Neuron k
W1i
4
The Perceptron
We can connect any number of McCulloch-Pitts neurons together in
any way we like
An arrangement of one input layer of McCulloch-Pitts neurons feeding
forward to one output layer of McCulloch-Pitts neurons is known as
a Perceptron.
)
sgn(
1
j
ij
n
i
i
j w
Y
Y θ
−
⋅
= ∑
=
:
:
:
:
i j
wij
1
2
N
1
2
M
θ1
θ2
θM
5
Implementing Logic Gates with MP Neurons
We can use McCulloch-Pitts neurons to implement the basic logic
gates (e.g. AND, OR, NOT).
It is well known from logic that we can construct any logical function
from these three basic logic gates.
All we need to do is find the appropriate connection weights and neuron
thresholds to produce the right outputs for each set of inputs.
We shall see explicitly how one can construct simple networks that
perform NOT, AND, and OR.
6
Implementation of Logical NOT, AND, and OR
0
1
1
0
out
in
NOT
NOT
1
1
1
0
0
1
0
1
0
0
0
0
out
in2
in1
AND
AND
1
1
1
1
0
1
1
1
0
0
0
0
out
in2
in1
OR
OR
?
? ?
Problem: Train network to calculate the appropriate weights and thresholds in
order to classify correctly the different classes (i.e. form decision boundaries
between classes).
7
Decision Surfaces
Decision surface is the surface at which the output of the unit is
precisely equal to the threshold, i.e. ∑wiIi=θ
In 1-D the surface is just a point:
I1=θ/w1
Y=0 Y=1
I1
In 2-D, the surface is
0
2
2
1
1 =
−
⋅
+
⋅ θ
w
I
w
I
which we can re-write as
1
2
1
2
2 I
w
w
w
I −
=
θ So, in 2-D the decision boundaries are
always straight lines.
8
Decision Boundaries for AND and OR
We can now plot the decision boundaries of our logic gates
1
1
1
0
0
1
0
1
0
0
0
0
out
I2
I1
AND
AND
I1
I2
(0, 0) (0, 1)
(1, 0)
(1, 1)
I1
I2
(1, 1)
(0, 1)
(0, 0)
(1, 0)
1
1
1
1
0
1
1
1
0
0
0
0
out
I2
I1
OR
OR
AND
AND
w1=1, w2=1, θ=1.5
OR
OR
w1=1, w2=1, θ=0.5
9
Decision Boundary for XOR
The difficulty in dealing with XOR is rather obvious. We need two straight
lines to separate the different outputs/decisions:
I1
I2
0
1
1
1
0
1
1
1
0
0
0
0
out
I2
I1
XOR
XOR
I1
I2
Solution: either change the transfer function so that it has more than one
decision boundary, or use a more complex network that is able to generate
more complex decision boundaries.
10
ANN Architectures
Mathematically, ANNs can be represented as weighted directed graphs. The
most common ANN architectures are:
Single-Layer Feed-Forward NNs: One input layer and one output layer of
processing units. No feedback connections (e.g. a Perceptron)
Multi-Layer Feed-Forward NNs: One input layer, one output layer, and one or
more hidden layers of processing units. No feedback connections (e.g. a
Multi-Layer Perceptron)
Recurrent NNs: Any network with at least one feedback connection. It may, or
may not, have hidden units
Further interesting variations include: sparse connections, time-delayed
connections, moving windows, …
11
Examples of Network Architectures
Single Layer Multi-Layer Recurrent
Feed-Forward Feed-Forward Network
12
Types of Activation/Transfer Function
Threshold Function



<
≥
=
0
0
0
1
)
(
x
if
x
if
x
f
f(x)
x
Piecewise-Linear Function
Sigmoid Function





≤
≤
≤
−
+
≥
=
5
.
0
0
5
.
0
5
.
0
5
.
0
5
.
0
1
)
(
x
if
x
if
x
x
if
x
f
f(x)
x
x
e
x
f −
+
=
1
1
)
(
f(x)
x
13
The Threshold as a Special Kind of Weight
The basic Perceptron equation can be simplified if we consider that the
threshold is another connection weight:
j
nj
n
j
j
j
ij
n
i
i w
I
w
I
w
I
w
I θ
θ −
⋅
+
+
⋅
+
⋅
=
−
⋅
∑
=
K
2
2
1
1
1
If we define w0j=-θj and I0=1 then
ij
n
i
i
j
nj
n
j
j
j
ij
n
i
i w
I
w
I
w
I
w
I
w
I
w
I ⋅
=
⋅
+
⋅
+
+
⋅
+
⋅
=
−
⋅ ∑
∑
=
= 0
0
0
2
2
1
1
1
K
θ
The Perceptron equation then becomes
)
sgn(
)
sgn(
0
1
ij
n
i
i
j
ij
n
i
i
j w
I
w
I
Y ⋅
=
−
⋅
= ∑
∑
=
=
θ
So, we only have to compute the weights.
14
Example: A Classification Task
A typical neural network application is classification. Consider the simple example of
classifying trucks given their masses and lengths:
How do we construct a neural network that can classify any Lorry and Van?
Lorry
9
5.0
Lorry
8
15.0
Lorry
7
10.0
Lorry
6
3.0
Van
5
2.0
Van
5
2.0
Van
4
5.0
Lorry
5
20.0
Lorry
6
10.0
Class
Length
Mass
15
Cookbook Recipe for Building Neural Networks
Formulating neural network solutions for particular problems is a multi-stage
process:
1. Understand and specify the problem in terms of inputs and required
outputs
2. Take the simplest form of network you think might be able to solve your
problem
3. Try to find the appropriate connection weights (including neuron
thresholds) so that the network produces the right outputs for each input
in its training data
4. Make sure that the network works on its training data and test its
generalization by checking its performance on new testing data
5. If the network doesn’t perform well enough, go back to stage 3 and try
harder
6. If the network still doesn’t perform well enough, go back to stage 2 and
try harder
7. If the network still doesn’t perform well enough, go back to stage 1 and
try harder
8. Problem solved – or not
16
Building a Neural Network (stages 1 & 2)
For our truck example, our inputs can be direct encodings of the masses and
lengths. Generally we would have one output unit for each class, with
activation 1 for ‘yes’ and 0 for ‘no’. In our example, we still have one output
unit, but the activation 1 corresponds to ‘lorry’ and 0 to ‘van’ (or vice versa).
The simplest network we should try first is the single layer Perceptron. We
can further simplify things by replacing the threshold by an extra weight as
we discussed before. This gives us:
1 Mass Length
w0
w2
w1
Class=sgn(w0+w1.Mass+w2.Length)
17
Training the Neural Network (stage 3)
Whether our neural network is a simple Perceptron, or a much
complicated multi-layer network, we need to develop a systematic
procedure for determining appropriate connection weights.
The common procedure is to have the network learn the appropriate
weights from a representative set of training data.
For classifications a simple Perceptron uses decision boundaries (lines
or hyperplanes), which it shifts around until each training pattern is
correctly classified.
The process of “shifting around” in a systematic way is called learning.
The learning process can then be divided into a number of small steps.
18
Supervised Training
1. Generate a training pair or pattern:
- an input x = [ x1 x2 … xn]
- a target output ytarget (known/given)
2. Then, present the network with x and allow it to generate an
output y
3. Compare y with ytarget to compute the error
4. Adjust weights, w, to reduce error
5. Repeat 2-4 multiple times
19
Perceptron Learning Rule
1. Initialize weights at random
2. For each training pair/pattern (x, ytarget)
- Compute output y
- Compute error, δ=(ytarget – y)
- Use the error to update weights as follows:
∆w = w – wold=η*δ*x or wnew = wold + η*δ*x
where η is called the learning rate or step size and it determines how
smoothly the learning process is taking place.
3. Repeat 2 until convergence (i.e. error δ is zero)
The Perceptron Learning Rule is then given by
wnew = wold + η*δ*x
where
δ=(ytarget – y)

More Related Content

Similar to 2-Perceptrons.pdf

soft computing
soft computingsoft computing
soft computingAMIT KUMAR
 
Unsupervised-learning.ppt
Unsupervised-learning.pptUnsupervised-learning.ppt
Unsupervised-learning.pptGrishma Sharma
 
Multilayer perceptron
Multilayer perceptronMultilayer perceptron
Multilayer perceptronsmitamm
 
Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)Amit Kumar Rathi
 
ACUMENS ON NEURAL NET AKG 20 7 23.pptx
ACUMENS ON NEURAL NET AKG 20 7 23.pptxACUMENS ON NEURAL NET AKG 20 7 23.pptx
ACUMENS ON NEURAL NET AKG 20 7 23.pptxgnans Kgnanshek
 
Two algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networksTwo algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networksESCOM
 
Neural network 20161210_jintaekseo
Neural network 20161210_jintaekseoNeural network 20161210_jintaekseo
Neural network 20161210_jintaekseoJinTaek Seo
 
8_Neural Networks in artificial intelligence.ppt
8_Neural Networks in artificial intelligence.ppt8_Neural Networks in artificial intelligence.ppt
8_Neural Networks in artificial intelligence.pptssuser7e63fd
 
The Perceptron and its Learning Rule
The Perceptron and its Learning RuleThe Perceptron and its Learning Rule
The Perceptron and its Learning RuleNoor Ul Hudda Memon
 
10 Backpropagation Algorithm for Neural Networks (1).pptx
10 Backpropagation Algorithm for Neural Networks (1).pptx10 Backpropagation Algorithm for Neural Networks (1).pptx
10 Backpropagation Algorithm for Neural Networks (1).pptxSaifKhan703888
 

Similar to 2-Perceptrons.pdf (20)

soft computing
soft computingsoft computing
soft computing
 
Unsupervised-learning.ppt
Unsupervised-learning.pptUnsupervised-learning.ppt
Unsupervised-learning.ppt
 
Lec10
Lec10Lec10
Lec10
 
Capstone paper
Capstone paperCapstone paper
Capstone paper
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
Nn ppt
Nn pptNn ppt
Nn ppt
 
Multilayer perceptron
Multilayer perceptronMultilayer perceptron
Multilayer perceptron
 
Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)Back Propagation Network (Soft Computing)
Back Propagation Network (Soft Computing)
 
ACUMENS ON NEURAL NET AKG 20 7 23.pptx
ACUMENS ON NEURAL NET AKG 20 7 23.pptxACUMENS ON NEURAL NET AKG 20 7 23.pptx
ACUMENS ON NEURAL NET AKG 20 7 23.pptx
 
Unit iii update
Unit iii updateUnit iii update
Unit iii update
 
Two algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networksTwo algorithms to accelerate training of back-propagation neural networks
Two algorithms to accelerate training of back-propagation neural networks
 
Neural network 20161210_jintaekseo
Neural network 20161210_jintaekseoNeural network 20161210_jintaekseo
Neural network 20161210_jintaekseo
 
ann-ics320Part4.ppt
ann-ics320Part4.pptann-ics320Part4.ppt
ann-ics320Part4.ppt
 
ann-ics320Part4.ppt
ann-ics320Part4.pptann-ics320Part4.ppt
ann-ics320Part4.ppt
 
Nn3
Nn3Nn3
Nn3
 
8_Neural Networks in artificial intelligence.ppt
8_Neural Networks in artificial intelligence.ppt8_Neural Networks in artificial intelligence.ppt
8_Neural Networks in artificial intelligence.ppt
 
The Perceptron and its Learning Rule
The Perceptron and its Learning RuleThe Perceptron and its Learning Rule
The Perceptron and its Learning Rule
 
6
66
6
 
Neural network
Neural networkNeural network
Neural network
 
10 Backpropagation Algorithm for Neural Networks (1).pptx
10 Backpropagation Algorithm for Neural Networks (1).pptx10 Backpropagation Algorithm for Neural Networks (1).pptx
10 Backpropagation Algorithm for Neural Networks (1).pptx
 

Recently uploaded

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...shivangimorya083
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
Predicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationPredicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationBoston Institute of Analytics
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 

Recently uploaded (20)

VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
Predicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationPredicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project Presentation
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 

2-Perceptrons.pdf

  • 1. 1 Lecture 2: Single Layer Perceptrons Kevin Swingler kms@cs.stir.ac.uk
  • 2. 2 Recap: McCulloch-Pitts Neuron • This vastly simplified model of real neurons is also known as a Threshold Logic Unit: 1. A set of synapses (i.e. connections) brings in activations from other neurons 2. A processing unit sums the inputs, and then applies a non-linear activation function 3. An output line transmits the result to other neurons I1 ∑ Wj1 Wjn I2 I3 In Aj Yj
  • 3. 3 Networks of McCulloch-Pitts Neurons One neuron can’t do much on its own. Usually we will have many neurons labelled by indices k, i, j and activation flows between via synapses with strengths wki, wij: ) sgn( 1 i n k ki i I Y θ − = ∑ = ki k ki w Y I ⋅ = ij i ij w Y I ⋅ = I1i I2i I3i Iki Neuron i Yi Synapse ij Iij Neuron j θi wij ∑ Neuron k W1i
  • 4. 4 The Perceptron We can connect any number of McCulloch-Pitts neurons together in any way we like An arrangement of one input layer of McCulloch-Pitts neurons feeding forward to one output layer of McCulloch-Pitts neurons is known as a Perceptron. ) sgn( 1 j ij n i i j w Y Y θ − ⋅ = ∑ = : : : : i j wij 1 2 N 1 2 M θ1 θ2 θM
  • 5. 5 Implementing Logic Gates with MP Neurons We can use McCulloch-Pitts neurons to implement the basic logic gates (e.g. AND, OR, NOT). It is well known from logic that we can construct any logical function from these three basic logic gates. All we need to do is find the appropriate connection weights and neuron thresholds to produce the right outputs for each set of inputs. We shall see explicitly how one can construct simple networks that perform NOT, AND, and OR.
  • 6. 6 Implementation of Logical NOT, AND, and OR 0 1 1 0 out in NOT NOT 1 1 1 0 0 1 0 1 0 0 0 0 out in2 in1 AND AND 1 1 1 1 0 1 1 1 0 0 0 0 out in2 in1 OR OR ? ? ? Problem: Train network to calculate the appropriate weights and thresholds in order to classify correctly the different classes (i.e. form decision boundaries between classes).
  • 7. 7 Decision Surfaces Decision surface is the surface at which the output of the unit is precisely equal to the threshold, i.e. ∑wiIi=θ In 1-D the surface is just a point: I1=θ/w1 Y=0 Y=1 I1 In 2-D, the surface is 0 2 2 1 1 = − ⋅ + ⋅ θ w I w I which we can re-write as 1 2 1 2 2 I w w w I − = θ So, in 2-D the decision boundaries are always straight lines.
  • 8. 8 Decision Boundaries for AND and OR We can now plot the decision boundaries of our logic gates 1 1 1 0 0 1 0 1 0 0 0 0 out I2 I1 AND AND I1 I2 (0, 0) (0, 1) (1, 0) (1, 1) I1 I2 (1, 1) (0, 1) (0, 0) (1, 0) 1 1 1 1 0 1 1 1 0 0 0 0 out I2 I1 OR OR AND AND w1=1, w2=1, θ=1.5 OR OR w1=1, w2=1, θ=0.5
  • 9. 9 Decision Boundary for XOR The difficulty in dealing with XOR is rather obvious. We need two straight lines to separate the different outputs/decisions: I1 I2 0 1 1 1 0 1 1 1 0 0 0 0 out I2 I1 XOR XOR I1 I2 Solution: either change the transfer function so that it has more than one decision boundary, or use a more complex network that is able to generate more complex decision boundaries.
  • 10. 10 ANN Architectures Mathematically, ANNs can be represented as weighted directed graphs. The most common ANN architectures are: Single-Layer Feed-Forward NNs: One input layer and one output layer of processing units. No feedback connections (e.g. a Perceptron) Multi-Layer Feed-Forward NNs: One input layer, one output layer, and one or more hidden layers of processing units. No feedback connections (e.g. a Multi-Layer Perceptron) Recurrent NNs: Any network with at least one feedback connection. It may, or may not, have hidden units Further interesting variations include: sparse connections, time-delayed connections, moving windows, …
  • 11. 11 Examples of Network Architectures Single Layer Multi-Layer Recurrent Feed-Forward Feed-Forward Network
  • 12. 12 Types of Activation/Transfer Function Threshold Function    < ≥ = 0 0 0 1 ) ( x if x if x f f(x) x Piecewise-Linear Function Sigmoid Function      ≤ ≤ ≤ − + ≥ = 5 . 0 0 5 . 0 5 . 0 5 . 0 5 . 0 1 ) ( x if x if x x if x f f(x) x x e x f − + = 1 1 ) ( f(x) x
  • 13. 13 The Threshold as a Special Kind of Weight The basic Perceptron equation can be simplified if we consider that the threshold is another connection weight: j nj n j j j ij n i i w I w I w I w I θ θ − ⋅ + + ⋅ + ⋅ = − ⋅ ∑ = K 2 2 1 1 1 If we define w0j=-θj and I0=1 then ij n i i j nj n j j j ij n i i w I w I w I w I w I w I ⋅ = ⋅ + ⋅ + + ⋅ + ⋅ = − ⋅ ∑ ∑ = = 0 0 0 2 2 1 1 1 K θ The Perceptron equation then becomes ) sgn( ) sgn( 0 1 ij n i i j ij n i i j w I w I Y ⋅ = − ⋅ = ∑ ∑ = = θ So, we only have to compute the weights.
  • 14. 14 Example: A Classification Task A typical neural network application is classification. Consider the simple example of classifying trucks given their masses and lengths: How do we construct a neural network that can classify any Lorry and Van? Lorry 9 5.0 Lorry 8 15.0 Lorry 7 10.0 Lorry 6 3.0 Van 5 2.0 Van 5 2.0 Van 4 5.0 Lorry 5 20.0 Lorry 6 10.0 Class Length Mass
  • 15. 15 Cookbook Recipe for Building Neural Networks Formulating neural network solutions for particular problems is a multi-stage process: 1. Understand and specify the problem in terms of inputs and required outputs 2. Take the simplest form of network you think might be able to solve your problem 3. Try to find the appropriate connection weights (including neuron thresholds) so that the network produces the right outputs for each input in its training data 4. Make sure that the network works on its training data and test its generalization by checking its performance on new testing data 5. If the network doesn’t perform well enough, go back to stage 3 and try harder 6. If the network still doesn’t perform well enough, go back to stage 2 and try harder 7. If the network still doesn’t perform well enough, go back to stage 1 and try harder 8. Problem solved – or not
  • 16. 16 Building a Neural Network (stages 1 & 2) For our truck example, our inputs can be direct encodings of the masses and lengths. Generally we would have one output unit for each class, with activation 1 for ‘yes’ and 0 for ‘no’. In our example, we still have one output unit, but the activation 1 corresponds to ‘lorry’ and 0 to ‘van’ (or vice versa). The simplest network we should try first is the single layer Perceptron. We can further simplify things by replacing the threshold by an extra weight as we discussed before. This gives us: 1 Mass Length w0 w2 w1 Class=sgn(w0+w1.Mass+w2.Length)
  • 17. 17 Training the Neural Network (stage 3) Whether our neural network is a simple Perceptron, or a much complicated multi-layer network, we need to develop a systematic procedure for determining appropriate connection weights. The common procedure is to have the network learn the appropriate weights from a representative set of training data. For classifications a simple Perceptron uses decision boundaries (lines or hyperplanes), which it shifts around until each training pattern is correctly classified. The process of “shifting around” in a systematic way is called learning. The learning process can then be divided into a number of small steps.
  • 18. 18 Supervised Training 1. Generate a training pair or pattern: - an input x = [ x1 x2 … xn] - a target output ytarget (known/given) 2. Then, present the network with x and allow it to generate an output y 3. Compare y with ytarget to compute the error 4. Adjust weights, w, to reduce error 5. Repeat 2-4 multiple times
  • 19. 19 Perceptron Learning Rule 1. Initialize weights at random 2. For each training pair/pattern (x, ytarget) - Compute output y - Compute error, δ=(ytarget – y) - Use the error to update weights as follows: ∆w = w – wold=η*δ*x or wnew = wold + η*δ*x where η is called the learning rate or step size and it determines how smoothly the learning process is taking place. 3. Repeat 2 until convergence (i.e. error δ is zero) The Perceptron Learning Rule is then given by wnew = wold + η*δ*x where δ=(ytarget – y)