+ All Categories
Home > Documents > Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science...

Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science...

Date post: 29-Jun-2018
Category:
Upload: trinhthien
View: 218 times
Download: 0 times
Share this document with a friend
72
Dr. Mai Elshehaly Department of Computer Science Suez Canal University © Mai Elshehaly 1
Transcript
Page 1: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Dr. Mai Elshehaly

Department of Computer Science

Suez Canal University

© Mai Elshehaly

1

Page 2: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

People are so smart

We want a computer program that can learn from data

Artificial Neurons simulate part of the functionality of human brain

They are connected together to form networks

Neurons can make a decision

Neural networks can recognize handwritten characters

Activation function determines when a neuron is fired

Step function is not flexible for learning

Sigmoid function gives a smooth transition

© Mai Elshehaly 2

Page 3: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Q1: draw a neuron (with weights and bias for a step activation function) to implement a NOR gate

Q2: Use multiple neurons to build a neural network that realizes a half adder using NOR only gates (each NOR gate is a neuron).

A. Label weights and threshold on the diagram

B. How many layers exist in your network?

C. How many neurons in each layer?

Q3: Add a fourth layer to the network on slide 52 to transform the outputs (coming from layer 3) into binary format.

© Mai Elshehaly 3

Page 4: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

-1

A

B

-2

-2

© Mai Elshehaly 4

Page 5: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 5

Page 6: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Sum= 𝐴. 𝐵 + 𝐴. 𝐵

=( 𝐴. 𝐵 + 𝐴. 𝐵)

= ( 𝐴𝐵 . (𝐴 𝐵))

= ( 𝐴 + 𝐵 . ( 𝐴 + 𝐵))

= (𝐴 𝐴 + 𝐴𝐵 + 𝐴 𝐵 + 𝐵 𝐵)

= 𝐴. 𝐵 + 𝐴. 𝐵

= ( 𝐴 + 𝐵 + (𝐴 + 𝐵))

= ( (𝐴 + 𝐴) + (𝐵 + 𝐵) + (𝐴 + 𝐵))

© Mai Elshehaly 6

Page 7: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Carry = A.B

=𝐴. 𝐵

= ( 𝐴 + 𝐵)

= (𝐴 + 𝐴) + (𝐵 + 𝐵)

© Mai Elshehaly 7

Page 8: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

-1A

B

-2-1

-1

-2

-2

-2

-2

-2

-1

-1-2

-2

-2

-2

S

C

3 layers for sum

2 layers for carry

© Mai Elshehaly 8

Page 9: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 9

Page 10: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly

• Suppose the image is made up of 28 x 28 pixels

• Each pixel holds one value = intensity

• We can build a neural network to tell us whether or not

the number shown is 6

# neurons in input layer = 28 x 28 = 784

# neurons in output layer = 1 (yes or no)

# neurons in hidden layer(s) depends on the

design

10

Page 11: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 11

Page 12: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 12

Page 13: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

ONLY ONE

If the input was an image that represents the digit 0 then the first neuron in the hidden layer will output 1 .All other neurons in the third layer will output 0

If the image was an image that represents the digit 9 then the last neuron in the hidden layer will output 1. All other neurons in the third layer will output 0

The same for any given digit: only the neuron that represents this digit will be 1 and all others will be 0

© Mai Elshehaly 13

Page 14: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 14

Page 15: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Solution: We need to set the weights coming from each

digit to change the neurons in the output layer in a manner

consistent with this digit’s binary representation.

The weights of the desired digit are the only ones active at

this point because all others are not fired from the hidden

layer.

© Mai Elshehaly 15

Page 16: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

0

0

0

0

0

1

0

1

x3*w30 = 1*0 =

0

x3*w31 = 1*0 =

0

x3*w32 = 1*1 =

1

x3*w33 = 1*1 =

1

x3

© Mai Elshehaly 16

Page 17: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

0

0

0

0

x0

x1

x2

x3

x4

x5

x6

x7

x8

x9

0

0

0

0

0

1

0

0

© Mai Elshehaly 17

Page 18: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly

Course website: www.vaqua.org/mai/neural/

Email me: [email protected]

Email Eng. Noura: [email protected]

Office Hours: Mon. and Thu. 12:00 – 1:00

OR: Start a discussion on Moodle

18

Page 19: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

A Learning Management System (LMS)

All class communication will happen on it

Homeworks and class news

Go to: www.vaqua.org/mai/neural/

© Mai Elshehaly 19

Page 20: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

WWW.VAQUA.ORG/MAI/MOODLE

© Mai Elshehaly 20

Page 21: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 21

Page 22: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 22

Page 23: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 23

Page 24: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 24

Page 25: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 25

Page 26: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 26

Page 27: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Artificial Neural Networks

© Mai Elshehaly 27

Page 28: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Artificial Neural Networks

© Mai Elshehaly 28

Page 29: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 29

Perceptron

Decision Boundary

Cost Function

Supervised Learning

Gradient Descent

Least Mean Squares (LMS)

Page 30: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Remember Amr Diab?

© Mai Elshehaly 30

Amr Diab concert in Ismailia! Should you go or not?

x1: Is the weather good?

x2 : Is the ticket affordable?

x3 : Does your best friend want to go with you?

Page 31: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 31

∑ ƒ

x1

x2

x3

w2 n a

b

1

Inputs Weights Neuron

SummerNet input

Activation

functionOutput

Bia

s

Page 32: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 32

a = ƒ(n) = ƒ(w.x + b)

Page 33: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 33

Demuth, H. B., Beale, M. H., De Jess, O., & Hagan, M. T. (2014). Neural network design. Martin Hagan.

Page 34: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Two types of fruit: apples and oranges

Sensors can measure a number of features

The features act as inputs to the neural network

The neural network decides whether the fruit is an apple or an orange

Possible features:

Length

Weight

Roundness

Texture

© Mai Elshehaly 34

Page 35: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Let’s consider 2 features for input: length and weight

© Mai Elshehaly 35

∑ ƒ

x1

x2

n a

b

1

Page 36: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Fruit class Weight (grams) Length (cm)

Apple (C1) 121 16.8

Orange (C2) 210 9.4

Apple (C1) 114 15.2

Orange (C2) 195 8.1

© Mai Elshehaly 36

4

8

12

16

20

50 100 150 200 250

Page 37: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Fruit class Weight (grams) Length (cm)

Apple (C1) 121 16.8

Orange (C2) 210 9.4

Apple (C1) 114 15.2

Orange (C2) 195 8.1

© Mai Elshehaly 37

4

8

12

16

20

50 100 150 200 250

Linearly

separable

Page 38: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Fruit class Weight (grams) Length (cm)

Apple (C1) 121 16.8

Orange (C2) 210 9.4

Apple (C1) 114 15.2

Orange (C2) 195 8.1

© Mai Elshehaly 38

4

8

12

16

20

50 100 150 200 250

Which line?

Depends on

the weights

Page 39: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Let’s say we have:

Initial weight vector: w = [w1, w2] = [-30, 300]

Bias: b = - 1200

© Mai Elshehaly 39

∑ ƒ

x1

x2

n a

b

1

Page 40: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 40

𝑎 = ƒ(n) = ƒ(Wx + b) = ∑ wi xi + b

𝑎 = -30 x1 + 300 x2 – 1200

Set 𝑎 = 0

set 𝑥1 = 100

𝑥2 =30 𝑥

1+1200

300=

3000 +1200

300= 14

set 𝑥1 = 200

𝑥2 =30 𝑥

1+1200

300=

6000 +1200

300= 24

4

8

12

16

20

50 100 150 200 250

Is this a good

decision

boundary?

Page 41: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

ƒ(.) =

© Mai Elshehaly 41

Apple

Orange

Page 42: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 42

Fruit class Weight (grams) Length (cm)

Apple (C1) 121 16.8

Orange (C2) 210 9.4

Apple (C1) 114 15.2

Orange (C2) 195 8.1

𝑛 = -30 x1 + 300 x2 – 1200

= −30 ∗ 121 + 300 ∗ 16.8 − 1200 = 31,470 > 0𝑎 = ƒ(n) = 1

Correctly classified an apple so no weight adjustment needed at this training step

Page 43: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 43

Fruit class Weight (grams) Length (cm)

Apple (C1) 121 16.8

Orange (C2) 210 9.4

Apple (C1) 114 15.2

Orange (C2) 195 8.1

𝑛 = -30 x1 + 300 x2 – 1200

= −30 ∗ 210 + 300 ∗ 9.4 − 1200 = −4,680 < 0𝑎 = ƒ(n) = −1

Correctly classified an orange so no weight adjustment needed at this training step

Page 44: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 44

Fruit class Weight (grams) Length (cm)

Apple (C1) 121 16.8

Orange (C2) 210 9.4

Apple (C1) 114 15.2

Orange (C2) 195 8.1

𝑛 = -30 x1 + 300 x2 – 1200

= −30 ∗ 114 + 300 ∗ 15.2 − 1200 = −60 < 0𝑎 = ƒ(n) = −1

Wrong! The classifier decided that this is an orange, when in fact it is an apple

Page 45: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 45

𝑎 = ƒ(n) = ƒ(Wx + b) = ∑ wi xi + b

𝑎 = -30 x1 + 300 x2 – 1200

The weights need to be adjusted

slowly until we reach a better

decision boundary that clearly

separates the two classes. 4

8

12

16

20

50 100 150 200 250

Page 46: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 46

𝑎 = ƒ(n) = ƒ(Wx + b) = ∑ wi xi + b

𝑎 = -30 x1 + 300 x2 – 1200

A large adjustment step can create

another bad decision boundary

4

8

12

16

20

50 100 150 200 250

Page 47: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 47

𝑎 = ƒ(n) = ƒ(Wx + b) = ∑ wi xi + b

𝑎 = -30 x1 + 300 x2 – 1200

An adjustment in the opposite

direction will only make things

worse

4

8

12

16

20

50 100 150 200 250

Page 48: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

In the training dataset we know what the desired outcome is.

In the above example, we knew which fruits are apples and which are oranges

This information is used to decide when and how the weights of the ANN need to be adjusted in order to create a better decision boundary

The learning process needs to be gradual with small steps

© Mai Elshehaly 48

Page 49: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

𝑙𝑒𝑎𝑟𝑛𝑖𝑛𝑔 𝑠𝑡𝑒𝑝 = 𝒘 𝑡 + 1 − 𝒘 𝑡 = 𝜂 𝑑 − 𝑎 𝒙

𝒘 𝑡 + 1 = 𝒘 𝑡 + 𝜂 𝑑 − 𝑎 𝒙𝒘 0 = −30, 300,−1200 𝑇

𝒙 = 114, 15.2, +1 𝑇

𝒘 1 = −30, 300,−1200 𝑇 + 0.01 * (1 – (-1)) * 114, 15.2, +1 𝑇

𝒘 1 = [−27.72, 300.304,−1199.98]

𝑛 = -27.72 x1 + 300.304 x2 – 1199.98

= −27.72 ∗ 114 + 300.304 ∗ 15.2 − 1199.98 = 204.92 > 0

𝑎 = ƒ(n) = 1 Correctly classified as apple

© Mai Elshehaly 49

Page 50: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

We only needed one iteration for this example

Usually the program will iterate through a number of steps to reach an appropriate decision boundary that correctly classifies all the samples in the training set.

© Mai Elshehaly 50

Page 51: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

The operations we discussed so far are those of an adaptive filter

They consist of 2 main processes:

1. Filtering process: involves the computation of the actual output 𝑎 and an error term 𝑒 which is the difference between 𝑎 and the desired output 𝑑

2. Adaptive process: the automatic adjustment of synaptic weights of the neuron according to the error signal 𝑒

© Mai Elshehaly 51

Page 52: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Determines the manner in which the error signal 𝑒 controls the adjustments to the neuron’s synaptic weights

We can define the cost function to be a function that tells us how large is the error signal 𝑒

More error (misclassified samples) means the classifier is not doing a good job and weights need to be adjusted

Closely related to optimization problems

© Mai Elshehaly 52

Page 53: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

We want to modify the weights w in a way that minimizes the cost function

We want to find an optimal solution w* that satisfies:

© Mai Elshehaly 53

Page 54: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 54

Page 55: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 55

Page 56: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

The adjustments made to the weights vector are in the direction of steepest descent of the cost function

That is the direction opposite to

Define the gradient vector:

Steepest descent:

© Mai Elshehaly 56

Page 57: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

In going from iteration n to iteration n+1 the algorithm applies the correction:

© Mai Elshehaly 57

Learning

rate

Page 58: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 58

Cost

functionError

function

Page 59: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 59

Page 60: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Rate of change: Differentiating the cost function w.r.t. the weights vector w yields:

© Mai Elshehaly 60

Page 61: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 61

Recall:

Hence:

and:

Page 62: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

We use the latter as an estimate for the gradient

Substitute in the equation of the steepest descent (3.12):

© Mai Elshehaly 62

Page 63: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

𝑙𝑒𝑎𝑟𝑛𝑖𝑛𝑔 𝑠𝑡𝑒𝑝 = 𝒘 𝑡 + 1 − 𝒘 𝑡 = 𝜂 𝑑 − 𝑎 𝒙

𝒘 𝒕 + 𝟏 = 𝒘 𝒕 + 𝜼 𝒅 − 𝒂 𝒙𝒘 0 = −30, 300,−1200 𝑇

𝒙 = 114, 15.2, +1 𝑇

𝒘 1 = −30, 300, −1200 𝑇 + 0.01 * (1 – (-1)) * 114, 15.2, +1 𝑇

𝒘 1 = [−27.72, 300.304,−1199.98]

𝑛 = -27.72 x1 + 300.304 x2 – 1199.98

= −27.72 ∗ 114 + 300.304 ∗ 15.2 − 1199.98 = 204.92 > 0

𝑎 = ƒ(n) = 1 Correctly classified as apple

© Mai Elshehaly 63

Page 64: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Download PyCharm (Community Edition): https://www.jetbrains.com/pycharm/download/#section=windows

Getting started tutorial (optional): https://confluence.jetbrains.com/display/PYH/Getting+Started+with+PyCharm

Perceptron code: https://datasciencelab.wordpress.com/2014/01/10/machine-learning-classics-the-perceptron/

© Mai Elshehaly 64

Page 65: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 65

Add this to your

code

Page 66: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

66© Mai Elshehaly

Page 67: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 67

Page 68: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 68

Page 69: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 69

Page 70: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Reimplement the perceptron class in the example given in this class to use the Mean Least Squares (MLS) cost function and the steepest descent adjustment algorithm.

© Mai Elshehaly 70

Page 71: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

Details of the code example

Assistance for PyCharm installation

Questions on steepest descent and LMS

How to submit HW on Moodle

© Mai Elshehaly 71

Page 72: Dr. Mai Elshehaly Department of Computer Science …. Mai Elshehaly Department of Computer Science ... Use multiple neurons to build a neural network that realizes a half adder using

© Mai Elshehaly 72


Recommended