Professional Documents
Culture Documents
1 Perceptron1
1 Perceptron1
Synapse Dendrites
Each neuron has a very simple structure, but Axon
an army of such elements constitutes a Axon
tremendous processing power.
Soma Soma
Dendrites
A neuron consists of a cell body, soma, a Synapse
number of fibers called dendrites, and a single
long fiber called the axon.
Our brain can be considered as a highly complex, non-linear
and parallel information-processing system.
Middle Layer
Input Layer Output Layer
Analogy between biological and
artificial neural networks
x1
Y
w1
x2
w2
Neuron Y Y
wn
Y
xn
Diagram of a neuron
Input Signals Weights Output Signals
x1
Y
w1
x2
w2
Neuron Y Y
wn
Y
xn
■ The neuron's output, or , is determined by whether the weighted sum is less than or greater than some
threshold value. Just like the weights, the threshold is a real number which is a parameter of the neuron.
■ The neuron computes the weighted sum of the input signals and compares the result with a threshold
value, θ. If the net input is less than the threshold, the neuron output is –1. But if the net input is greater
than or equal to the threshold, the neuron becomes activated and its output attains a value +1.
Input Signals Weights Output Signals
wn
Y
xn In the example shown the perceptron has three inputs,
general it could have more or fewer inputs. Rosenblatt prop
■ That's the basic mathematical model. A way you canrule
simple think
to about thethe
compute perceptron is introduced
output. He that it's a weights,
device that makes decisions by weighing up evidence., real numbers expressing the importance of the r
inputs to the output. The neuron's output, or , is determi
■ The neuron uses the following transfer or activation
whether function:
the weighted sum is less than or greater tha
threshold value. Just like the weights, the threshold is a rea
number which is a parameter of the neuron. To put it in mo
n ⎧+ 1, if X ≥precise
θ algebraic terms:
X = ∑ xi wi Y =⎨
i =1 ⎩− 1, if X < θ
■ In 1958, Frank Rosenblatt introduced a training algorithm that provided the first
procedure for training a simple ANN: a perceptron.
■ The perceptron is the simplest form of a neural network. It consists of a single neuron
with adjustable synaptic weights and a hard limiter.
Inputs
x1 Linear Hard
w1 Combiner Limiter
Output
∑ Y
w2
θ
x2
Threshold
Single-layer two-input perceptron
Inputs
x1 Linear Hard
w1 Combiner Limiter
Output
∑ Y
w2
θ
x2
Threshold
Perceptron Example
(Chapter 1:pp 1-10)
Suppose the weekend is coming up, and you've heard that there's Now, suppose you absolutely adore cheese, so much so
going to be a cheese festival in your city. You like cheese, and are that you're happy to go to the festival even if your
trying to decide whether or not to go to the festival. You might make boyfriend or girlfriend is uninterested and the festival is
your decision by weighing up three factors: hard to get to. But perhaps you really loathe bad weather,
and there's no way you'd go to the festival if the weather
1. Is the weather good? is bad.
2. Does your boyfriend or girlfriend want to
accompany you? You can use perceptrons to model this kind of decision-
3. Is the festival near public transit? (You don't own a making.
car).
One way to do this is to choose a weight w1=6 for the
We can represent these three factors by corresponding binary weather, and w2=2 and w3=2 for the other conditions.
variables X1, X2 , and X3 .
The larger value of w1 indicates that the weather matters a
For instance, we'd have lot to you, much more than whether your boyfriend or
X1=1 if the weather is good, and X1=0 if the weather girlfriend joins you, or the nearness of public transit.
is bad.
Finally, suppose you choose a threshold of 5 for the
Similarly, perceptron. With these choices, the perceptron implements
X2=1 if your boyfriend or girlfriend wants to go, and the desired decision-making model, outputting whenever
X2=0 if not. the weather is good, and whenever the weather is bad. It
makes no difference to the output whether your boyfriend
similarly again for X3 and public transit. or girlfriend wants to go, or whether public transit is nearby.
X3=1 if the festival is near, X3=0 if not
The Perceptron
n
∑ xi wi − θ = 0
i =1
x2 x2
Class A1
1
2
1
x1
Class A2 x1
Inputs
x1 Linear Hard
w1 Combiner Limiter
Output
∑ Y
w2
θ
x2
Threshold
■ If at iteration p, the actual output is Y(p) and the desired output is Yd (p), then the
error is given by:
e( p) = Yd ( p) − Y ( p) where p = 1, 2, 3, . . .
Iteration p here refers to the pth training example presented to the perceptron.
■ If the error, e(p), is positive, we need to increase perceptron output Y(p), but if it is
negative, we need to decrease Y(p).
Inputs
x1 Linear Hard
w1 Combiner Limiter
Output
∑ Y
w2
θ
x2
Threshold
The perceptron learning rule
wi ( p + 1) = wi ( p) + α ⋅ xi ( p) ⋅ e( p)
where p = 1, 2, 3, . . .
α is the learning rate, a positive constant less than
unity.
Step 1: Initialisation
Set initial weights w1, w2,…, wn and threshold θ to random numbers
in the range [-0.5, 0.5].
Step 2: Activation
Activate the perceptron by applying inputs x1(p), x2(p),…, xn(p) and
desired output Yd (p). Calculate the actual output at iteration p = 1
⎡ n ⎤
Y ( p ) = step ⎢∑ xi ( p ) wi ( p ) − θ⎥
⎢ i =1
⎣ ⎥
⎦
Step 4: Iteration
Increase iteration p by one, go back to Step 2 and repeat the
process until convergence.
Example of perceptron learning: the logical operation AND
Inputs Desired Initial Actual Error Final
Epoch output weights output weights
x1 x2 Yd w1 w2 Y e w1 w2
1 0 0 0 0.3 −0.1 0 0 0.3 −0.1
0 1 0 0.3 −0.1 0 0 0.3 −0.1
1 0 0 0.3 −0.1 1 −1 0.2 −0.1
1 1 1 0.2 −0.1 0 1 0.3 0.0
2 0 0 0 0.3 0.0 0 0 0.3 0.0 Inputs
0 1 0 0.3 0.0 0 0 0.3 0.0
1 0 0 0.3 0.0 1 −1 0.2 0.0 x1 Linear Hard
1 1 1 0.2 0.0 1 0 0.2 0.0 Combiner Limiter
w1
3 0 0 0 0.2 0.0 0 0 0.2 0.0 Output
0 1 0 0.2 0.0 0 0 0.2 0.0 ∑ Y
1 0 0 0.2 0.0 1 −1 0.1 0.0
1 1 1 0.1 0.0 0 1 0.2 0.1 w2
4 0 0 0 0.2 0.1 0 0 0.2 0.1 θ
0 1 0 0.2 0.1 0 0 0.2 0.1 x2
1 0 0 0.2 0.1 1 −1 0.1 0.1 Threshold
1 1 1 0.1 0.1 1 0 0.1 0.1
5 0 0 0 0.1 0.1 0 0 0.1 0.1
0 1 0 0.1 0.1 0 0 0.1 0.1
1 0 0 0.1 0.1 0 0 0.1 0.1
1 1 1 0.1 0.1 1 0 0.1 0.1
Threshold: θ = 0.2; learning rate: α = 0.1
p LabTutorial (Phyton from scratch)
p Chapter 10: Perceptron (Pg80-88)
1 1 1
x1 x1 x1
0 1 0 1 0 1
Y Y Y Y
+1 +1 +1 +1
0 X 0 X 0 X 0 X
-1 -1 -1 -1