CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

76
CPSC 322 Introduction to Artificial Intelligence December 3, 2004

Transcript of CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Page 1: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

CPSC 322Introduction to Artificial Intelligence

December 3, 2004

Page 2: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Things...

Slides for the last couple of weekswill be up this weekend.

Did I mention that you have a final exam at noon on Friday,December 10, in MCML 166?

Check the announcements part ofthe web page occasionally betweennow and then in case anythingimportant comes up.

Page 3: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

This should be funArtificial Intelligence and Interactive Digital EntertainmentFirst Annual ConferenceJune 1-3, 2005 in Marina Del Rey, Californiawww.aiide.org

Page 4: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

LearningDefinition: learning is the adaptive changes that occur in a system which enable that system to perform the same task or similar tasks more efficiently or more effectively over time.

This could mean: • The range of behaviors is expanded: the agent can do more • The accuracy on tasks is improved: the agent can do things better • The speed is improved: the agent can do things faster

Page 5: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning is about choosing the best representation

That’s certainly true in a logic-based AI world.

Our arch learner started with some internal representationof an arch. As examples were presented, the arch learnermodified its internal representation to either make therepresentation accommodate positive examples (generalization) or exclude negative examples (specialization).

There’s really nothing else the learner could modify...the reasoning system is what it is. So any learningproblem can be mapped onto one of choosing thebest representation...

Page 6: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning is about search

...but wait, there’s more!

By now, you’ve figured out that the arch learner wasdoing nothing more than searching the space ofpossible representations, right?

So learning, like everything else, boils down to search.

If that wasn’t obvious, you probably will want to do a little extra preparation for the final exam....

Page 7: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Same problem - different representation

The arch learner could have represented thearch concept as a decision tree if we wanted

Page 8: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Same problem - different representation

The arch learner could have represented thearch concept as a decision tree if we wanted

arch

Page 9: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Same problem - different representation

The arch learner could have represented thearch concept as a decision tree if we wanted

do upright blockssupport sideways block?

no yes

not arch arch

Page 10: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Same problem - different representation

The arch learner could have represented thearch concept as a decision tree if we wanted

do upright blockssupport sideways block?

no yes

not arch do upright blocks touch each other?

arch not arch

no yes

Page 11: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Same problem - different representation

The arch learner could have represented thearch concept as a decision tree if we wanted

do upright blockssupport sideways block?

no yes

not arch do upright blocks touch each other?

is the not arch top block either a rectangle or a wedge?

no yes

no yes

not arch arch

Page 12: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Other issues with learning by example

The learning process requires that there is someone to say which examples are positive andwhich are negative.

This approach must start with a positive exampleto specialize or generalize from.

Learning by example is sensitive to the order inwhich examples are presented.

Learning by example doesn’t work well with noisy, randomly erroneous data.

Page 13: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningLearning operator sequences based on rewardor punishment

Let’s say you want your robot to learn how to vacuum the living room

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (Uncompressed) decompressor

are needed to see this picture.

iRobot Roomba 4210 Discovery Floorvac Robotic Vacuum $249.99It’s the ideal Christmas gift!

Page 14: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningLearning operator sequences based on rewardor punishment

Let’s say you want your robot to learn how to vacuum the living room

goto livingroomvacuum floorgoto trashcanempty bag

Good Robot!

Page 15: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningLearning operator sequences based on rewardor punishment

Let’s say you want your robot to learn how to vacuum the living room

goto livingroom goto trashcanvacuum floor vacuum floorgoto trashcan goto livingroomempty bag empty bag

Good Robot! Bad Robot!

Page 16: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningLearning operator sequences based on rewardor punishment

Let’s say you want your robot to learn how to vacuum the living room

goto livingroom goto trashcanvacuum floor vacuum floorgoto trashcan goto livingroomempty bag empty bag

Good Robot! Bad Robot!

(actually, there are no bad robots, there is only badbehavior...and Roomba can’t really empty its own bag)

Page 17: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningShould the robot learn from success? How doesit figure out which part of the sequence ofactions is right (credit assignment problem)?

goto livingroom goto trashcanvacuum floor vacuum floorgoto trashcan goto livingroomempty bag empty bag

Good Robot! Bad Robot!

Page 18: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningShould the robot learn from failure? How doesit figure out which part of the sequence ofactions is wrong (blame assignment problem)?

goto livingroom goto trashcanvacuum floor vacuum floorgoto trashcan goto livingroomempty bag empty bag

Good Robot! Bad Robot!

Page 19: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Reinforcement learningHowever you answer those questions, the learning task again boils down to thesearch for the best representation.

Here’s another type of learning that searchesfor the best representation, but the representationis very different from what you’ve seen so far.

Page 20: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

The perceptron is one of the earliest neural network models, dating to the early 1960s.

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 21: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

The perceptron can’t compute everything, but what it cancompute it can learn to compute.Here’s how it works.

Inputs are 1 or 0.Weights are reals (-n to +n).Each input is multiplied by its corresponding weight.If the sum of the products is greater than the threshold, then the perceptron outputs 1, otherwise the output is 0.

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 22: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

The perceptron can’t compute everything, but what it cancompute it can learn to compute.Here’s how it works.

The output, 1 or 0, is aguess or prediction aboutthe input: does it fall intothe desired classification(output = 1) or not(output = 0)?

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 23: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

That’s it? Big deal. No, there’s more to it....

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 24: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

That’s it? Big deal. No, there’s more to it....

Say you wanted your perceptronto classify arches.

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 25: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

That’s it? Big deal. No, there’s more to it....

Say you wanted your perceptronto classify arches.That is, you present inputsrepresenting an arch, andthe output should be 1.

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 26: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

That’s it? Big deal. No, there’s more to it....

Say you wanted your perceptronto classify arches.That is, you present inputsrepresenting an arch, andthe output should be 1.You present inputs notrepresenting an arch,and the output shouldbe 0.

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 27: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

That’s it? Big deal. No, there’s more to it....

Say you wanted your perceptronto classify arches.That is, you present inputsrepresenting an arch, andthe output should be 1.You present inputs notrepresenting an arch,and the output shouldbe 0. If your perceptrondoes that correctly forall inputs, it knows theconcept of arch.

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 28: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

But what if you present inputs for an arch, and yourperceptron outputs a 0???

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 29: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

But what if you present inputs for an arch, and yourperceptron outputs a 0???What could be done tomake it more likely thatthe output will be 1 thenext time the ‘tron seesthose same inputs?

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 30: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

But what if you present inputs for an arch, and yourperceptron outputs a 0???What could be done tomake it more likely thatthe output will be 1 thenext time the ‘tron seesthose same inputs?

You increase the weights. Which ones?How much?

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 31: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

But what if you present inputs for not an arch, and yourperceptron outputs a 1?

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 32: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

But what if you present inputs for not an arch, and yourperceptron outputs a 1?What could be done tomake it more likely thatthe output will be 0 thenext time the ‘tron seesthose same inputs?

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 33: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Learning in neural networks

But what if you present inputs for not an arch, and yourperceptron outputs a 1?What could be done tomake it more likely thatthe output will be 0 thenext time the ‘tron seesthose same inputs?

You decrease the weights. Which ones?How much?

x1

x2

x3

xn

.

.

.

w1

w2

w3

wn

inputs

weights

sum threshold

Page 34: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...First we need to come up with a representation language.We’ll abstract away most everything to make it simple.

Page 35: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...First we need to come up with a representation language.We’ll abstract away most everything to make it simple.

All training examples have three blocks. A and B are upright blocks. A is always left of B.C is a sideways block. Our language will assume thosethings always to be true. The only things our languagewill represent are the answers to these five questions...

Page 36: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...yes = 1, no = 0

Does A support C?

Does B support C?

Does A touch C?

Does B touch C?

Does A touch B?

Page 37: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...yes = 1, no = 0

Does A support C? 1

Does B support C? 1

Does A touch C? 1

Does B touch C? 1

Does A touch B? 0

A B

C

arch

Page 38: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...yes = 1, no = 0

Does A support C? 1

Does B support C? 1

Does A touch C? 1

Does B touch C? 1

Does A touch B? 1

A B

C

not arch

Page 39: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...yes = 1, no = 0

Does A support C? 0

Does B support C? 0

Does A touch C? 1

Does B touch C? 1

Does A touch B? 0

A B

C

not arch

Page 40: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Let’s make one...yes = 1, no = 0

Does A support C? 0

Does B support C? 0

Does A touch C? 1

Does B touch C? 1

Does A touch B? 0

A B

C

not arch

and so on.....

Page 41: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

x1

x2

x3

x5

x4

Page 42: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

x1

x2

x3

x5

x4

- 0.5

0

0.5

0

-0.5

0.5

Page 43: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

0

1

- 0.5

0

0.5

0

-0.5

0.5

A B

C

arch

Page 44: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

0

1

- 0.5

0

0.5

0

-0.5

0.5

A B

C

arch

sum = 1*-0.5 + 1*0 + 1*0.5 + 1*0 + 0*0.5

Page 45: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

0

1

- 0.5

0

0.5

0

-0.5

0.5

A B

C

arch

sum = -0.5 + 0 + 0.5 + 0 + 0 = 0 which is not > threshold so output is 0

0

Page 46: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

0

1

- 0.5

0

0.5

0

-0.5

0.5

A B

C

arch

sum = -0.5 + 0 + 0.5 + 0 + 0 = 0 which is not > threshold so output is 0‘tron said no when it should say yes so increase weights where input = 1

0

Page 47: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

0

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A B

C

arch

sum = -0.5 + 0 + 0.5 + 0 + 0 = 0 which is not > threshold so output is 0so we increase the weights where the input is 1

0

Page 48: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

1

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A B

C

not arch

now we look at the next example

Page 49: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

1

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A B

C

not arch

sum = -0.4 + 0.1 + 0.6 + 0.1 - 0.5 = -0.1 which is not > 0.5 so output is 0

0

Page 50: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

1

1

1

1

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A B

C

not arch

sum = -0.4 + 0.1 + 0.6 + 0.1 - 0.5 = -0.1 which is not > 0.5 so output is 0that’s the right output for this input, so we don’t touch the weights

0

Page 51: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

0

0

1

0

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A BC

not arch

now we look at the next example

Page 52: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

0

0

1

0

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A BC

not arch

sum = 0 + 0 + 0.6 + 0.1 + 0 = 0.7 which is > 0.5 so output = 1

1

Page 53: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

0

0

1

0

1

- 0.4

0.1

0.6

0.1

-0.5

0.5

A BC

not arch

the ‘tron said yes when it should have said no, so we decreasethe weights where the inputs = 1

1

Page 54: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Our very simple arch learner

0

0

1

0

1

- 0.4

0.1

0.5

0

-0.5

0.5

A BC

not arch

the ‘tron said yes when it should have said no, so we decreasethe weights where the inputs = 1

1

Page 55: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

We could do this for days......but let’s have the computer do it all for us.

First, take a look at the training examples we’veconstructed...

Page 56: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Training Set a b a b ain class? supports supports touches touches touches c c c c b

yes 1 1 1 1 0

no 1 1 1 1 1

no 0 0 0 0 0

no 0 0 1 1 0

no 1 0 1 0 1

Page 57: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Training Set a b a b ain class? supports supports touches touches touches c c c c b

no 1 0 1 0 0

no 0 1 0 1 1

no 0 1 0 1 0

no 0 0 1 0 0

no 0 0 0 1 0

Page 58: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Now let’s look at the program

The program isn’t in CILOG!

Page 59: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

What’s going on?

The perceptron goes through the training set,making a guess for each example and comparingit to the actual answer.

Based on that comparison, the perceptron adjustsweights up, down, or not at all.

For some concepts, the process converges ona set of weights such that the perceptron guessescorrectly for every example in the training set --that’s when the weights stop changing.

Page 60: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

What’s going on?

Another way of looking at it:Each of the possible inputs (25 in our case)maps onto a 1 or a 0. The perceptronis trying to find a set of weights such that itcan draw a line through the set of all inputsand say “these inputs belong on one side ofthe line (output = 1) and those belong on the other side (output = 0)”.

Page 61: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

What’s going on?one set of weights

Page 62: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

What’s going on?another set of weights

Page 63: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

What’s going on?still another set of weights

Page 64: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

What’s going on?still another set of weights

The perceptron looks for linear separability.That is, in the n-space defined by the inputs, it’slooking for a line or plane that divides the inputs.

Page 65: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Observations

This perceptron can learn concepts involving “and”and “or”

This perceptron can’t learn “exclusive or” (try ex3in the Scheme code). Not linearly separble...it won’t converge

Even a network of perceptrons arranged in a singlelayer can’t compute XOR (as well as other things)

Page 66: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Observations

The representation for the learned concept (e.g., the arch concept) is just five numbers.What does that say about the physical symbol system hypothesis?

However, if you know which questions or relationseach individual weight is associated with, you still have a sense of what the numbers/weightsmean.

Page 67: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Observations

This is another example of intelligence as searchfor the best representation.

The final set of weights that was the solution tothe arch-learning problem is not the only solution.In fact, there are infinitely many solutions, corresponding to the infinitely many ways to drawthe line or plane.

Page 68: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Beyond perceptrons

Perceptrons were popular in the 1960s, and somefolks thought they were the key to intelligent machines.

But you needed multiple-layer perceptron networksto compute some things, but to make those workyou had to build them by hand. Multiple-layerperceptron nets don’t necessarily converge, andwhen they don’t converge, they don’t learn. Building big nets by hand was too time consuming,so interest in perceptrons died off in the 1970s.

Page 69: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

The return of the perceptron

In the 1980s, people figured out that with somechanges, multiple layers of perceptron-like unitscould compute anything.

First, you get rid of the threshold -- replace the step function that generated output with a continuous function.

Then you put hidden layers between the inputsand the output(s).

Page 70: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

The return of the perceptron

input layer

hidden layer

output layer

Page 71: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

The return of the perceptron

Then for each input example you let the activationfeed forward to the outputs, compare outputsto desired outputs, and then backpropagate theinformation about the differences to inform decisions about how to adjust the weights in themultiple layers of network. Changes to weightsgive rise to immediate changes in output, becausethere’s no threshold.

Page 72: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

The return of the perceptron

This generation of networks is called neuralnetworks, or backpropagation nets, or connectionist networks (don’t use perceptron now)

They’re capable of computing anything computableThey learn wellThey degrade gracefullyThey handle noisy input wellThey’re really good at modelling low-level perceptual processing and simple learning

but...

Page 73: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

The return of the perceptron

This generation of networks is called neuralnetworks, or backpropagation nets, or connectionist networks (don’t use perceptron now)

They can’t explain their reasoningNeither can we, easily...what the pattern of weights in the hidden layers correspond to is opaqueNot a lot of success yet in modelling higher levels of cognitive behavior (planning, story understanding, etc.)

Page 74: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

The return of the perceptron

But this discussion of perceptrons should putyou in a position to read Chapter 11.2 andsee how those backprop networks came about.

Which leads us to the end of this term...

Page 75: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Things...

Good bye!

Thanks for being nice to the new guy.

We’ll see you at noon on Friday, December 10, in MCML 166 for thefinal exam

Have a great holiday break, and come visit next term.

Page 76: CPSC 322 Introduction to Artificial Intelligence December 3, 2004.

Questions?

QuickTime™ and aDV/DVCPRO - NTSC decompressor

are needed to see this picture.