0% found this document useful (0 votes)
11 views17 pages

Perceptron

The document describes designing a perceptron to implement an AND gate. It shows the inputs, outputs, weights, bias and threshold over multiple epochs as the weights and bias are adjusted using the perceptron learning rule until the perceptron correctly implements the AND function.

Uploaded by

gaminghardy4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views17 pages

Perceptron

The document describes designing a perceptron to implement an AND gate. It shows the inputs, outputs, weights, bias and threshold over multiple epochs as the weights and bias are adjusted using the perceptron learning rule until the perceptron correctly implements the AND function.

Uploaded by

gaminghardy4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Soft Computing

300 (3)
Dr. Lekshmi R. R.
Asst. Prof.
Department of Electrical & Electronics
Engineering
Amrita School of Engineering 1
Perceptron
Introduction
• More powerful learning rule
• Has 3 layers
– Sensory unit
– Associative unit
– Response unit
1 𝑖𝑓 𝑦𝑖𝑛 > 𝜃
𝑦 = ቐ 0 𝑖𝑓 −𝜃 ≤ 𝑦𝑖𝑛 ≤ 𝜃
−1 𝑖𝑓 𝑦𝑖𝑛 < −𝜃
• Weights adjusted using perceptron learning rule
𝑤𝑛𝑒𝑤 = 𝑤𝑜𝑙𝑑 + ∆𝑤
∆𝑤 = 𝛼𝑡𝑥𝑖
• 𝑡: target
• 𝛼 : learning rate
• 𝑥𝑖 : input
Architecture
1
𝑏
Application
𝑥1 𝑋1 𝑤1 Classification
y
𝑤2 𝑌
𝑥2
𝑋2
Perceptron Learning
Step 1: Initialize weights and bias. Step 7: Adjust the weights and bias if error exist
Set learning rate α (0< α<1) (y≠t) new

Step 2: While termination condition is false, do 𝑤𝑖 = 𝑤𝑖 𝑜𝑙𝑑 + 𝛼𝑡𝑥𝑖


steps 3 - 8 𝑏new = 𝑏𝑜𝑙𝑑 + 𝛼𝑡
Step 3: For each training pair, do steps 4-7
Step 4: Set input activation functions; xi=si Else new
𝑤𝑖 = 𝑤𝑖 𝑜𝑙𝑑
Step 5: Compute response of system
𝑛 𝑏new = 𝑏𝑜𝑙𝑑
𝑦𝑖𝑛 = 𝑏 + ෍ 𝑥𝑖 𝑤𝑖
𝑖=1
Step 8: Test stopping condition
Step 6: Set output activation functions
1 𝑖𝑓 𝑦𝑖𝑛 > 𝜃 – If no weights are changed, stop
𝑦 = ቐ 0 𝑖𝑓 −𝜃 ≤ 𝑦𝑖𝑛 ≤ 𝜃 – Else continue
−1 𝑖𝑓 𝑦𝑖𝑛 < −𝜃
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 1 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 𝛼=1 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


0 0 0
1 1 1 1 0 0 N 1 1 1 1 1 1
1 0 1 -1 2 1 N -1 0 -1 0 1 0
0 1 1 -1 1 1 N 0 -1 -1 0 0 -1
0 0 1 -1 -1 -1 Y 0 0 0 0 0 -1
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 2 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


0 0 -1
1 1 1 1 -1 -1 N 1 1 1 1 1 0
1 0 1 -1 1 1 N -1 0 -1 0 1 -1
0 1 1 -1 0 0 N 0 -1 -1 0 0 -2
0 0 1 -1 -2 -1 Y 0 0 0 0 0 -2
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 3 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


0 0 -2
1 1 1 1 -2 -1 N 1 1 1 1 1 -1
1 0 1 -1 0 0 N -1 0 -1 0 1 -2
0 1 1 -1 -1 -1 Y 0 0 0 0 1 -2
0 0 1 -1 -2 -1 Y 0 0 0 0 1 -2
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 4 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


0 1 -2
1 1 1 1 -1 -1 N 1 1 1 1 2 -1
1 0 1 -1 0 0 N -1 0 -1 0 2 -2
0 1 1 -1 0 0 N 0 -1 -1 0 1 -3
0 0 1 -1 -3 -1 Y 0 0 0 0 1 -3
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 5 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


0 1 -3
1 1 1 1 -2 -1 N 1 1 1 1 2 -2
1 0 1 -1 -1 -1 Y 0 0 0 1 2 -2
0 1 1 -1 0 0 N 0 -1 -1 1 1 -3
0 0 1 -1 -3 -1 Y 0 0 0 1 1 -3
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 6 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


1 1 -3
1 1 1 1 -1 -1 N 1 1 1 2 2 -2
1 0 1 -1 0 0 N -1 0 -1 1 2 -3
0 1 1 -1 -1 -1 Y 0 0 0 1 2 -3
0 0 1 -1 -3 -1 Y 0 0 0 1 2 -3
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 7 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


1 2 -3
1 1 1 1 -1 -1 N 1 1 1 2 3 -2
1 0 1 -1 1 1 N -1 0 -1 1 3 -3
0 1 1 -1 0 0 N 0 -1 -1 1 2 -4
0 0 1 -1 -4 -1 Y 0 0 0 1 2 -4
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 8 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


1 2 -4
1 1 1 1 -2 -1 N 1 1 1 2 3 -3
1 0 1 -1 -2 -1 Y 0 0 0 2 3 -3
0 1 1 -1 0 0 N 0 -1 -1 2 2 -4
0 0 1 -1 -4 -1 Y 0 0 0 2 2 -4
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 9 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


2 2 -4
1 1 1 1 0 0 N 1 1 1 3 3 -3
1 0 1 -1 0 0 N -1 0 -1 2 3 -4
0 1 1 -1 -1 -1 Y 0 0 0 2 3 -4
0 0 1 -1 -4 -1 Y 0 0 0 2 3 -4
Design a Perceptron to implement AND gate
No. of inputs: 3 Weight Value
x1 x2 1 t
𝑤1 0
1 1 1 1 No. of outputs:1
𝑤2 0
1 0 1 -1
b 0
0 1 1 -1
0 0 1 -1 1 𝑖𝑓 𝑦𝑖𝑛 > 0.2
Epoch 10 𝑦 = ቐ 0 𝑖𝑓 −0.2 ≤ 𝑦𝑖𝑛 ≤ 0.2
𝜃 = 0.2 −1 𝑖𝑓 𝑦𝑖𝑛 < −0.2

x1 x2 1 t yin y Y=t? Δw1 Δw2 Δb w1 w2 b


2 3 -4
1 1 1 1 1 1 Y 0 0 0 2 3 -4
1 0 1 -1 -1 -1 Y 0 0 0 2 3 -4
0 1 1 -1 -1 -1 Y 0 0 0 2 3 -4
0 0 1 -1 -4 -1 Y 0 0 0 2 3 -4
Design a nn for the following truth table
w1=2; w2=3; b=-4 𝑥1 𝑤1 + 𝑥2 𝑤2 + 𝑏 = ±𝜃
𝑥2 0 1.4 2𝑥1 + 3𝑥2 − 4 = 0.2
𝑥1 2.1 0
2𝑥1 + 3𝑥2 = 4.2
𝑥2 0 1.27
2𝑥1 + 3𝑥2 − 4 = −0.2
𝑥1 1.9 0
2𝑥1 + 3𝑥2 = 3.8

Activaton function: Bipolar Threshold: 1


x1 x2 1 t x1w1 x2 w 2 b yin y
1 1 1 -1 2 3 -4 1 1
1 0 1 -1 2 0 -4 -2 -1
0 1 1 -1 0 3 -4 -1 -1
0 0 1 1 0 0 -4 -4 -1
Thank you

You might also like