Docsity

Perceptron Learning Rule and Winnow Algorithm in On-line Machine Learning - Prof. Dan Roth, Study notes of Computer Science

Partial preview of the text

Download Perceptron Learning Rule and Winnow Algorithm in On-line Machine Learning - Prof. Dan Roth and more Study notes Computer Science in PDF only on Docsity!

On-line Learning

CS446-Spring

Linear Functions

f

(x)

if

w

x

w

x

w

n

x

n

Otherwise

• Disjunctions:

y

x

x

x

y

x

x

x

• At least m of n:

y

= at least 2 of {

x

x

x

y

x

x

x

• Exclusive-OR:

y

= (x

x

) v (

x

x

• Non-trivial DNF:

y

x

x

) v (

x

x

On-line Learning

CS446-Spring

w

x = 0


- - 

w

x =

On-line Learning

CS446-Spring

4

Perceptron learning rule

We learn f:X

→

{-1,+1}

represented as

f = sgn{w

x)

Where X=

or X=

w

∈

n

{0,1}

n

R

n

R

m m 2 2 1 1 •

Given Labeled examples:

)}

y

,

(x

),...,

y

,

(x

),

y

,

{(x

Initialize w=

∈

Cycle through all examplesa. Predict the label of instance x to be y’ = sgn{w

x)

b. If y’

≠

y, update the weight vector:

w = w + r y x

(r - a constant, learning rate)

Otherwise, if y’=y, leave weights unchanged.

n

R

On-line Learning

CS446-Spring

5

Footnote About the Threshold

  • On previous slide, Perceptron has no threshold • But we don’t lose generality:

⇔

θ

−

⇔

∀

⇔

, 1

, w

w

x

x

x

0

x

1

x

x

w

0

x

1

x

θ

x

w

On-line Learning

CS446-Spring

On-line Learning

CS446-Spring

On-line Learning

CS446-Spring

Perceptron learning rule

Initialize w=

∈

Cycle through all examplesa. Predict the label of instance x to be y’ = sgn{w

x)

b. If y’

≠

y, update the weight vector to

w = w + r y x

(r - a constant, learning rate)

Otherwise, if y’=y, leave weights unchanged.

n

R

If x is Boolean, only weights of active features are updated.

1/

x)

exp(w

1

1

to

equivalent

is

0

x

w

On-line Learning

CS446-Spring

Perceptron Learnability

Obviously can’t learn what it can’t represent

  • Only linearly separable functions

Minsky and Papert (1969) wrote an influential bookdemonstrating Perceptron’s representationallimitations

  • Parity functions can’t be learned (XOR) – In vision, if patterns are represented with local features, can’t

represent symmetry, connectivity

Research on Neural Networks stopped for years

Rosenblatt himself (1959) asked,

“What pattern recognition problems can be transformed soas to become linearly separable?”

On-line Learning

CS446-Spring

Perceptron Convergence

  • Perceptron Convergence Theorem:

If there exist a set of weights that are consistent with the (I.e., the data is linearly separable) the perceptron learning algorithm will converge

-- How long would it take to converge?

  • Perceptron Cycling Theorem: If the training data is not linearly

the perceptron learning algorithm will eventually repeat the same set of weights and therefore enter an infinite loop.

-- How to provide robustness, more expressivity?

On-line Learning

CS446-Spring

Maintains a weight vector w

R

N

w

Upon receiving an example

x

R

N

Predicts according to the linear threshold function w•x

Theorem [Novikoff,1963]

Let

(x

; y

),…,: (x

t

; y

t

be a sequence of

labeled examples with

x

i

R

N

x

i

R

and y

i

∈

{-1,1} for all i.

Let u

∈

R

N

γ

> 0 be such that, ||

u

|| = 1 and y

i

u

xi

≥

γ

for all i.

Then Perceptron makes at most

u

R

γ

mistakes on this

example sequence.

(see additional notes)

MarginComplexityParameter

Perceptron: Mistake Bound Theorem

On-line Learning

CS446-Spring

Perceptron for Boolean Functions

  • How many mistakes will the Perceptron algorithms make

when learning a k-disjunction?

  • Try to figure out the bound • Find a sequence of examples that will cause Perceptron to

make O(n) mistakes on k-disjunction on n attributes.

On-line Learning

CS446-Spring

17

Winnow Algorithm

  • The Winnow Algorithm learns Linear Threshold Functions. • For the class of disjunction,

instead of demotion

we can use elimination

.

(demotion)

1)

x

(if

/

w

w

,

x

but

w

0

f(x)

If

)

(promotion

1)

x

(if

2w

w

,

x

w

but

1

f(x)

If

nothing

do

:

mistake

no

If

x

w

iff

1

is

Prediction

w

:

Initialize

i

i

i

i

i

i

i

=

←

≥

=

=

←

<

=

≥

=

=

1

n;

θ

θ

θ

θ

On-line Learning

CS446-Spring

19

Winnow - Example

  • Notice that the same algorithm will learn a conjunction over

these variables (

w

=(256,256,0,…32,…256,256) )

hypothesis

(final

version)

on

(eliminati

mistake

ok

variable)

good

each

(for

log(n/2)

mistake

mistake

mistake

ok

ok

ok

Initialize

1024

1023

2

1

w

w

x

w

w

x

w

w

w

x

w

w

x

w

w

x

w

w

x

w

w

x

w

w

x

w

w x x x x f

On-line Learning

CS446-Spring

20

Winnow - Mistake Bound

Claim

: Winnow makes O(k log n) mistakes on k-disjunctions

u - # of mistakes on positive examples (promotions)v - # of mistakes on negative examples (demotions)

(demotion)

1)

x

(if

/

w

w

,

x

but

w

0

f(x)

If

)

(promotion

1)

x

(if

2w

w

,

x

w

but

1

f(x)

If

nothing

do

:

mistake

no

If

x

w

iff

1

is

Prediction

w

:

Initialize

i

i

i

i

i

i

i

=

←

≥

=

=

←

<

=

≥

=

=

1

n;

θ

θ

θ

θ