1 perceptron as one type of linear discriminants introductionintroduction design of primitive...

30
1 Perceptron as one Type of Linear Discriminants Introduction Introduction Design of Primitive Units Design of Primitive Units Perceptrons Perceptrons

Upload: tamsyn-mccarthy

Post on 18-Jan-2018

219 views

Category:

Documents


0 download

DESCRIPTION

3 Introduction Neural Network Representation Input nodes Internal nodes Output nodes LeftStraightRight

TRANSCRIPT

Page 1: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

1

Perceptron as one Type of Linear Discriminants

• IntroductionIntroduction

• Design of Primitive UnitsDesign of Primitive Units

• PerceptronsPerceptrons

Page 2: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

2

Introduction

Artificial Neural Networks are crude attempts to model the Artificial Neural Networks are crude attempts to model the highly massive parallel and distributed processing we believe highly massive parallel and distributed processing we believe takes place in the brain. takes place in the brain.

Consider: Consider: 1) the speed at which the brain recognizes images; 1) the speed at which the brain recognizes images; 2) the many neurons populating a brain; 2) the many neurons populating a brain; 3) the speed at which a single neuron transmits signals. 3) the speed at which a single neuron transmits signals.

Page 3: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

3

IntroductionNeural Network Representation

Input nodesInput nodes

Internal nodesInternal nodes

Output nodesOutput nodes

Left Left StraightStraight RightRight

Page 4: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

4

IntroductionProblems for Neural Networks

Examples may be described by a large number of attributesExamples may be described by a large number of attributes (e.g., pixels in an image).(e.g., pixels in an image). The output value can be discrete, continuous, or a vector of The output value can be discrete, continuous, or a vector of either discrete or continuous values. either discrete or continuous values. Data may contain errors.Data may contain errors. The time for training may be extremely long.The time for training may be extremely long. Evaluating the network for a new example is relatively fast.Evaluating the network for a new example is relatively fast. Interpretability of the final hypothesis is not relevant (the Interpretability of the final hypothesis is not relevant (the NN is treated as a black box). NN is treated as a black box).

Page 5: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

5

Perceptron as one Type of Linear Discriminants

• IntroductionIntroduction

• Design of Primitive UnitsDesign of Primitive Units

• PerceptronsPerceptrons

Page 6: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

6

Perceptron as one Type of Linear Discriminants

(image copied from wikipedia, entry on “neuron”)

Nucleus

Soma

Dendrites

Axon

Axon Terminal

Page 7: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

7

Perceptron as one Type of Linear Discriminants

(image copied from wikipedia, entry on “neuron”)

Page 8: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

8

Design of Primitive UnitsPerceptrons

Definition.- It’s a step function based on a linear combination Definition.- It’s a step function based on a linear combination of real-valued inputs. If the combination is above a threshold of real-valued inputs. If the combination is above a threshold it outputs a 1, otherwise it outputs a –1. it outputs a 1, otherwise it outputs a –1.

xx11

xx22

xxnn

{1 or –1}{1 or –1}

XX00=1=1

ww00

ww11

ww22

wwnn

ΣΣ

Page 9: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

9

Design of Primitive Units Learning Perceptrons

O(xO(x11,x,x22,…,x,…,xnn) = ) = 1 if w1 if w00 + w + w11xx11 + w + w22xx22 + … + w + … + wnnxxnn > 0 > 0-1 otherwise-1 otherwise

To simplify our notation we can represent the function as follows:To simplify our notation we can represent the function as follows:

O(O(XX) = sgn() = sgn(WXWX) where) where

sgn(y) = sgn(y) = 1 if y > 01 if y > 0-1 otherwise-1 otherwise

Learning a perceptron means finding the right values for W.Learning a perceptron means finding the right values for W.The hypothesis space of a perceptron is the space of all The hypothesis space of a perceptron is the space of all weight vectors. weight vectors.

Page 10: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

10

Design of Primitive Units Representational Power

A perceptron draws a hyperplane as the decision boundaryA perceptron draws a hyperplane as the decision boundaryover the (n-dimensional) input space. over the (n-dimensional) input space.

++++

++

----

--

Decision boundary (Decision boundary (WXWX = 0) = 0)

Page 11: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

11

Design of Primitive Units Representational Power

A perceptron can learn only examples that are called A perceptron can learn only examples that are called ““linearly separable”. These are examples that can be perfectly linearly separable”. These are examples that can be perfectly separated by a hyperplane. separated by a hyperplane.

++++

++

----

--

++++

++--

--

--

Linearly separableLinearly separable Non-linearly separableNon-linearly separable

Page 12: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

12

Design of Primitive Units Functions for Perceptrons

Perceptrons can learn many boolean functions:Perceptrons can learn many boolean functions:AND, OR, NAND, NOR, but not XOR AND, OR, NAND, NOR, but not XOR

AND: AND: xx11

xx22

XX00=1=1WW00 = -0.8 = -0.8

WW11=0.5=0.5

WW22=0.5=0.5ΣΣ

Every boolean function can be represented with a Every boolean function can be represented with a perceptron network that has two levels of depth or more. perceptron network that has two levels of depth or more.

Page 13: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

13

Design a two-input perceptron that implements the Boolean function X1 OR ~X2 (X1 OR not X2). Assume the independent weight is always +0.5 (assume W0 = +0.5 and X0 = 1). You simply have to provide adequate values for W1 and W2.

xx11

xx22

xx00=1=1WW00 = +0.5 = +0.5

WW11=?=?

WW22=?=?ΣΣ

Design of Primitive Units

Page 14: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

14

X1 OR ~X2 (X1 OR not X2).

xx11

xx22

xx00=1=1WW00 = +0.5 = +0.5

WW11=?=?

WW22=?=?ΣΣ

Design of Primitive Units

Page 15: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

15

There are different solutions, but a general solution is that: W2 < -0.5W1 > |W2| - 0.5 where |x| is the absolute value of x.

xx11

xx22

xx00=1=1WW00 = +0.5 = +0.5

WW11=1=1

WW22= -1= -1ΣΣ

(X1 OR not X2).

Design of Primitive Units

Page 16: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

16

Design of Primitive Units Perceptron Algorithms

How do we learn the weights of a single perceptron?How do we learn the weights of a single perceptron?A.A. Perceptron rulePerceptron ruleB.B. Delta ruleDelta rule

Algorithm for learning using the perceptron rule:Algorithm for learning using the perceptron rule:

1.1. Assign random values to the weight vectorAssign random values to the weight vector2.2. Apply the perceptron rule to every training exampleApply the perceptron rule to every training example3.3. Are all training examples correctly classified?Are all training examples correctly classified?

a.a. Yes. QuitYes. Quitb.b. No. Go back to Step 2.No. Go back to Step 2.

Page 17: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

17

Design of Primitive Units A. Perceptron Rule

The perceptron training rule:The perceptron training rule:

For a new training example X = (xFor a new training example X = (x11, x, x22, …, x, …, xnn), ), update each weight according to this rule:update each weight according to this rule:

wwii = w = wii + Δw + Δwii

Where ΔwWhere Δwii = η (t-o) x = η (t-o) xii

t: target outputt: target outputo: output generated by the perceptrono: output generated by the perceptronη: constant called the learning rate (e.g., 0.1)η: constant called the learning rate (e.g., 0.1)

Page 18: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

18

Design of Primitive Units A. Perceptron Rule

Comments about the perceptron training rule:Comments about the perceptron training rule:

• If the example is correctly classified the term (t-o) equals If the example is correctly classified the term (t-o) equals zero, and no update on the weight is necessary.zero, and no update on the weight is necessary.• If the perceptron outputs –1 and the real answer is 1, If the perceptron outputs –1 and the real answer is 1, the weight is increased.the weight is increased.• If the perceptron outputs a 1 and the real answer is -1, If the perceptron outputs a 1 and the real answer is -1, the weight is decreased.the weight is decreased.• Provided the examples are linearly separable and a small Provided the examples are linearly separable and a small value for η is used, the rule is proved to classify all training value for η is used, the rule is proved to classify all training examples correctly (i.e, is consistent with the training data). examples correctly (i.e, is consistent with the training data).

Page 19: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

Historical Background

Early attempts to implement artificial neural networks:

McCulloch (Neuroscientist) and Pitts (Logician) (1943)

• Based on simple neurons (MCP neurons)• Based on logical functions

Walter Pitts (right)(extracted from Wikipedia)

Page 20: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

Historical Background

Donald Hebb (1949)

The Organization of Behavior.

“Neural pathways are strengthened every time they are used.”

Picture of Donald Hebb(extracted from Wikipedia)

Page 21: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

21

Design of Primitive Units B. The Delta Rule

What happens if the examples are not linearly separable? What happens if the examples are not linearly separable? To address this situation we try to approximate the realTo address this situation we try to approximate the realconcept using the delta rule.concept using the delta rule.

The key idea is to use a The key idea is to use a gradient descent searchgradient descent search. .

We will try to minimize the following error:We will try to minimize the following error:

E = ½ ΣE = ½ Σii (t (tii – o – oii) ) 22

where the sum goes over all training examples.where the sum goes over all training examples.Here oHere oii is the inner product WX and not sgn(WX) is the inner product WX and not sgn(WX)as with the perceptron algorithm. as with the perceptron algorithm.

Page 22: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

22

Design of Primitive Units B. The Delta Rule

The idea is to find a minimum in the space of weights and The idea is to find a minimum in the space of weights and the error function E:the error function E:

ww11

ww22

E(E(WW))

Page 23: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

23

Design of Primitive Units Derivation of the Rule

The gradient of E with respect to weight vector W,The gradient of E with respect to weight vector W,denoted as E(W) :denoted as E(W) :

E(W) is a vector with the partial derivatives of E with respect E(W) is a vector with the partial derivatives of E with respect to each weight wto each weight wii. .

Key concept:Key concept:The gradient vector points in the direction with the The gradient vector points in the direction with the steepest increase in E. steepest increase in E.

ΔΔ

ΔΔ

nwE

wE

wE ',...,','E(W)

10

Page 24: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

24

Design of Primitive Units B. The Delta Rule

The delta rule:The delta rule:

For a new training example X = (xFor a new training example X = (x11, x, x22, …, x, …, xnn), ), update each weight according to this rule:update each weight according to this rule:

wwii = w = wii + Δw + Δwii

WhereWhere

η: learning rate (e.g., 0.1)η: learning rate (e.g., 0.1)i

i wWEw )('

Page 25: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

25

Design of Primitive Units The gradient

How do we compute E(W)?How do we compute E(W)?

It is easy to see that It is easy to see that

So that gives us the following equation:So that gives us the following equation:

∆ ∆ wwii = η Σ = η Σi i (t(tii – o – oii) x) xii

ΔΔ

i iiii

xotwWE ))(()('

Page 26: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

26

Design of Primitive Units The algorithm using the Delta Rule

Algorithm for learning using the delta rule:Algorithm for learning using the delta rule:

1.1. Assign random values to the weight vectorAssign random values to the weight vector2.2. Continue until the stopping condition is metContinue until the stopping condition is met

a)a) Initialize each ∆wInitialize each ∆wii to zero to zerob)b) For each example:For each example:

Update ∆wUpdate ∆wii:: ∆ ∆wwii = ∆w = ∆wii + n (t – o) x + n (t – o) xii

c)c) Update wUpdate wii::wwii = w = wii + ∆w + ∆wii

3.3. Until error is smallUntil error is small

Page 27: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

Historical Background

Picture of Marvin Minsky (2008)(extracted from Wikipedia)

Frank Rosenblatt (1962)

He showed how to make incrementalchanges on the strength of the synapses.

He invented the Perceptron.

Minsky and Papert (1969)

Criticized the idea of the perceptron. Could not solve the XOR problem. In addition, training time grows exponentiallywith the size of the input.

Page 28: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

28

Design of Primitive Units Difficulties with Gradient Descent

There are two main difficulties with the gradient descentThere are two main difficulties with the gradient descentmethod:method:

1.1. Convergence to a minimum may take a long time.Convergence to a minimum may take a long time.

2. There is no guarantee we will find the global minimum. 2. There is no guarantee we will find the global minimum.

Page 29: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

29

Design of Primitive Units Stochastic Approximation

Instead of updating every weight until all examples have beenInstead of updating every weight until all examples have beenobserved, we update on every example:observed, we update on every example:

∆ ∆ wwii = η (t-o) x = η (t-o) xii

In this case we update the weights “incrementally”. In this case we update the weights “incrementally”. Remarks:Remarks:-) When there are multiple local minima stochastic gradient descent-) When there are multiple local minima stochastic gradient descent may avoid the problem of getting stuck on a local minimum. may avoid the problem of getting stuck on a local minimum. -) Standard gradient descent needs more computation but can be -) Standard gradient descent needs more computation but can be used with a larger step size. used with a larger step size.

Page 30: 1 Perceptron as one Type of Linear Discriminants IntroductionIntroduction Design of Primitive UnitsDesign of Primitive Units PerceptronsPerceptrons

30

Design of Primitive Units Difference between Perceptron and Delta Rule

The perceptron is based on an output from a step function, The perceptron is based on an output from a step function, whereas the delta rule uses the linear combination of inputswhereas the delta rule uses the linear combination of inputsdirectly. directly.

The perceptron is guaranteed to converge to a consistent The perceptron is guaranteed to converge to a consistent hypothesis assuming the data is linearly separable. The delta hypothesis assuming the data is linearly separable. The delta rules converges in the limit but it does not need the condition rules converges in the limit but it does not need the condition of linearly separable data. of linearly separable data.