iai revision 2012

69
IAI REVISION 2012

Upload: asabi

Post on 25-Feb-2016

48 views

Category:

Documents


0 download

DESCRIPTION

IAI REVISION 2012. Turing Test. Turing (1950) “Computing machinery and intelligence": Can machines think? Can machines behave intelligently? Predicted that by 2000, a machine might have a 30% chance of fooling a lay person for 5 minutes - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: IAI REVISION 2012

IAI REVISION 2012

Page 2: IAI REVISION 2012

Turing TestTuring (1950) “Computing machinery

and intelligence":Can machines think? Can machines

behave intelligently?Predicted that by 2000, a machine might

have a 30% chance of fooling a lay person for 5 minutes

Suggested major components of AI: knowledge, reasoning, language understanding, learning

Problems: Turing test is not reproducible, constructive, or

amenable to mathematical analysis

Page 3: IAI REVISION 2012

AI is not trying to copy humans

• “artificial flight” was successful because the Wright brothers stopped mimicking birds.

• We don’t want to copy pigeons. • Where else is the idea of a “gliding wing” and

a propeller used in nature?

Page 4: IAI REVISION 2012

Laws of Thought

“Socrates is a man; all men are mortal; therefore Socrates is mortal.” LOGIC

In 1965 computer programs existed that could in principle solve any solvable problem described in logical notation (however if no solution exists, the program would not terminate).

How to we formally state real-world problems.Some problems take too long to solve exactly.

Page 5: IAI REVISION 2012

Economics

• How do we make decisions to maximize payoff (utility, money, happiness).

• How do we do this when others cooperate or do not cooperate (criminals).

• What about if the reward is not immediate, but maybe delayed far into the future.

• Decision theory/game theory/operations research.

Page 6: IAI REVISION 2012

History of AI

McCulloch and Pitts (1943) on/off perceptron. Hebb (1949) Hebbian learning rule.Turing (1950) “Computing Machinery and

Intelligence”Newell and Simon (1976) physical symbol

system hypothesisSamuel (1952) checkers player; the program

leaned to play better than its creator I CAN TELL YOU HOW IN THE DISCUSSION THIS AFTERNOON

Page 7: IAI REVISION 2012

Game playing• IBM’s Deep Blue defeated the world

champion Garry Kasparov.• “a new kind of intelligence”• IBM’s stock increased by $18 billion USD.• By studying this, chess players could draw!!!• Recently the computer is much better. • But what about “GO”, or other games?

Page 8: IAI REVISION 2012

Vacuum-Cleaner• Vacuum agent perceives • which square (A or B) • and if clean or dirty.• It has actions; move left/right, suck, do nothing. • One simple function; if current square dirty, then

suck, else move to other square. • We can write perceived state and action pairs• [A, Clean] right (if in A && clean, then move right) • [A, Dirty] suck (if in A && dirty, then suck)

Page 9: IAI REVISION 2012

States and Actions

• A state is a description of the world now. • An action is a transition from one state to

another. • Not exactly the same but in java – instance

variables are like state e.g. person = {name, age}

• An action (java Method) changes the state with get/set methods.

Page 10: IAI REVISION 2012

Formulation of Problem Domain

• State: [l, c, d] robot=left, left room is clean, right room is dirty. Or in Binary [0,1,0]

• Initial state:[l, d, d]• Action: move Left/right, suck. • Transition diagram: next slide• Goal states: {[l, c, c], [r, c, c]}• Path cost: number of actions (maybe sucking

takes twice as much energy as moving??)

Page 11: IAI REVISION 2012

State transition diagram for vacuum cleaner world.

Note – some actions Are reversible and someAre not - which?

Page 12: IAI REVISION 2012

2.3.2 Properties of task environment

• Fully observable vs. partially observable. • Single agent vs. multiple agent. (competitive

vs. cooperative)• Deterministic vs. stochastic.• Episodic vs. sequential.• Discrete vs. continuous. • Known vs. unknown.

Page 13: IAI REVISION 2012

2.4.2 simple reflex agents

IF condition THEH action.Human reflexes e.g.

blinking, knee jerk. A fly avoid getting

squatted by a humanOther examples.

Page 14: IAI REVISION 2012

2.4.3 model-based reflex agentsExample; we gasp for breath, even under water. A fly will move if we try to swat it. BLUSHING.

Page 15: IAI REVISION 2012

2.4.4 goal-based

• There is a desirable goal state of the world.

• goal eg crossing a road.

• Children and orange juice in tall/short glass

Page 17: IAI REVISION 2012

Search

UNIFORMED SEARCH• Depth first and breath first search. • Uniform cost search (expands the cheapest

cost – how far travelled so far). h(n)INFORMED SEARCH • Greedy (expand first closest to goal according

to some information). Funciton g(n) • A* (A star) f(n)= h(n)+g(n)

Page 18: IAI REVISION 2012

Differences in Search methods

• All of them work the same way!!!• The only difference is the order in which they sort

the list• Depth first – FIFO, breath first FILO• Greedy g(n), uniform f(n), A* f(n)+g(n) • Uniformed search – looks in all directions (no

knowledge of where the goal is)• Informed search – is directed toward the goal by

information e.g. straight line distance to goal city.

Page 19: IAI REVISION 2012

Map of Romania

Page 20: IAI REVISION 2012

Breath First Search

Page 21: IAI REVISION 2012

Depth First Search

Page 22: IAI REVISION 2012

Greedy Search

Page 23: IAI REVISION 2012

A *search

• Expand cheapest according to distance travelled so far + expected distance to travel.

Page 24: IAI REVISION 2012

Resolution - summary

If we know (knowledge base)• A or B• Not BThen we can conclude (the knowledge base resolves to)• AThe propositions must be in CNF (conjunctive normal form). We add the negation of what we want to prove.If we get a contradiction (false), then the theorem/proposition is true. (this is called proof by contraditction. )

Page 25: IAI REVISION 2012

Resolution Algorithm

Small exampleIs it sunny? sunny = TRUE? Prove sunnyKnowledge base:sunny daytimesunny V night

Page 26: IAI REVISION 2012

Resolution Algorithm

Small exampleIs it sunny? sunny = TRUE? Prove sunnyKnowledge base:sunny daytimesunny V night¬sunny

Negate it Add it to the knowledge base

CONTRADICTION¬sunny = FALSE

Therefore: sunny = TRUE

Page 27: IAI REVISION 2012

Procedure for converting to CNF

• (a) To eliminate ↔, – (a ↔ b) ≡ (a → b) Λ (b→ a)

• (b) To eliminate →, – (a → b) ≡ ¬ a ν b

• (c) Double negation ¬ (¬a) ≡ a• (d) De Morgan

– ¬ (a Λ b) ≡ (¬a ν ¬b) ¬(a ν b) ≡ (¬a Λ ¬b)

• (e) Distributivity of Λ over ν – (a Λ (b ν c )) ≡ ((a Λ b) ν (a Λ c))

• (f) Distributivity of ν over Λ – (a ν (b Λ c )) ≡ ((a ν b) Λ (a ν c))

Page 28: IAI REVISION 2012

Two player games

Page 29: IAI REVISION 2012

MinMax

Page 30: IAI REVISION 2012

Alpha beta pruning

• Pruning – means cutting off redundant parts• Typically we “prune a tree”• MinMax considers all possibelities, however,

using

Page 31: IAI REVISION 2012

α-β pruning example

Page 32: IAI REVISION 2012

α-β pruning example

Page 33: IAI REVISION 2012

α-β pruning example

Page 34: IAI REVISION 2012

α-β pruning example

Page 35: IAI REVISION 2012

α-β pruning example

Page 36: IAI REVISION 2012

Learning By Example

• Perceptrons (single layer) – linearly seperable data.

• Artificial Neural Networks (multilayer perceptrons – usually 2 or 3)

• Support Vector Machines – linearly separable data.

• Project/transform into higher dimensional space e.g. 2D to 3D and re-represent – then apply a Support Vector Machine.

Page 37: IAI REVISION 2012

G51IAI – Introduction to AI

The First Neural Networks

It consisted of:A set of inputs - (dendrites)A set of weights – (synapses)A processing element - (neuron)A single output - (axon)

Page 38: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

The activation of a neuron is binary. That is, the neuron either fires (activation of one) or does not fire (activation of zero).

Page 39: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

Output function:If (input sum < Threshold) output 0Else output 1

θ = threshold

Page 40: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

Each neuron has a fixed threshold. If the net input into the neuron is greater than or equal to the threshold, the neuron fires

Page 41: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

Neurons in a McCulloch-Pitts network are connected by directed, weighted paths

Page 42: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

If the weight on a path is positive the path is excitatory, otherwise it is inhibitory

x1 and x2 encourage the neuron to firex3 prevents the neuron from firing

Page 43: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

The threshold is set such that any non-zero inhibitory input will prevent the neuron from firing(This is only a rule for McCulloch-Pitts Networks!!)

Page 44: IAI REVISION 2012

G51IAI – Introduction to AI

McCulloch and Pitts Networks

-1

2

2X1

X2

X3

Y

It takes one time step for a signal to pass over one connection.

Page 45: IAI REVISION 2012

G51IAI – Introduction to AI

Worked Examples on Handout 1

1.5

0.5

21

0

1

?

Inputs

Threshold(θ) = 4

Does this neuron fire?Does it output a 0 or a 1?

1)Multiply the inputs to the neuron by the weights on their paths

2)Add the inputs

3)Apply the threshold function

2

0

1.5

3.5

3.5 < 4So neuron outputs 0

Threshold Function:If input sum < Threshold return 0Else return 1

Page 46: IAI REVISION 2012

G51IAI – Introduction to AI

Answers

• Using McCulloch-Pitts model we can model some logic functions• In the exercise, you have been working on logic functions• AND• OR • NOT AND

Page 47: IAI REVISION 2012

G51IAI – Introduction to AI

Answers

X

Y

Z

Threshold(θ) = 21

1

X Y Z1 1 11 0 00 1 00 0 0

AND Function

Threshold Function:If input sum < Threshold return 0Else return 1

Page 48: IAI REVISION 2012

G51IAI – Introduction to AI

Answers

X

Y

Z

Threshold(θ) = 22

2

X Y Z1 1 11 0 10 1 10 0 0

OR Function

Threshold Function:If input sum < Threshold return 0Else return 1

Page 49: IAI REVISION 2012

G51IAI – Introduction to AI

Answers (This one is not a McCulloch-Pitts Network)

X

Y

Z

Threshold(θ) = -1-1X Y Z1 1 01 0 10 1 10 0 1

NOT AND (NAND) Function

-1

Threshold Function:If input sum < Threshold return 0Else return 1

Page 50: IAI REVISION 2012

G51IAI – Introduction to AI

One additional example

X

Y

Z

Threshold(θ) = 22X Y Z1 1 01 0 10 1 00 0 0

AND NOT Function

-1

Threshold Function:If input sum < Threshold return 0Else return 1

Page 51: IAI REVISION 2012

Multi-Layer Neural Networks

G51IAI – Introduction to AI

Page 52: IAI REVISION 2012

G51IAI – Introduction to AI

Modelling Logic Functions

X1 XOR X2 = (X1 AND NOT X2) OR (X2 AND NOT X1)

XOR Function

2

2

2

2

-1

-1

Y1

Y2

Z

X1

X2

X1 X2 Z1 1 01 0 10 1 10 0 0

XOR

Page 53: IAI REVISION 2012

G51IAI – Introduction to AI

Modelling Logic Functions

X1 XOR X2 = (X1 AND NOT X2) OR (X2 AND NOT X1)

22

-1

Y2

Z

X1

X2 X1 X2 Y2

1 1 01 0 00 1 10 0 0

ANDNOT

Page 54: IAI REVISION 2012

G51IAI – Introduction to AI

Modelling Logic Functions

X1 XOR X2 = (X1 AND NOT X2) OR (X2 AND NOT X1)

22

-1

Y1Z

X1

X2 ANDNOT

X1 X2 Y1

1 1 01 0 10 1 00 0 0

Page 55: IAI REVISION 2012

G51IAI – Introduction to AI

Modelling Logic Functions

X1 XOR X2 = (X1 AND NOT X2) OR (X2 AND NOT X1)

2

2

Y1

Y2

Z

XOR

Y1 Y2 Z1 1 11 0 10 1 10 0 0

OR

X1 X2 Z1 1 01 0 10 1 10 0 0

Page 56: IAI REVISION 2012

X1 X2 Y1 Y2 Z1 1 0 0 01 0 1 0 10 1 0 1 10 0 0 0 0

G51IAI – Introduction to AI

Modelling Logic Functions

X1 XOR X2 = (X1 AND NOT X2) OR (X2 AND NOT X1)

Page 57: IAI REVISION 2012

G51IAI – Introduction to AI

Key Idea!

• Perceptrons cannot learn (cannot even represent) the XOR function• Multi-Layer Networks can, as we have

just shown

Page 58: IAI REVISION 2012

First training step

• We wanted 1• We got 0• Error = 1 – 0 = 1

X Y Z1 1 11 0 00 1 00 0 0

While epoch produces an errorPresent network with next inputs (pattern) from epoch Err = T – OIf Err <> 0 then

Wj = Wj + LR * Ij * ErrEnd If

End While

If there IS an error, then we change ALL the weights in the network

Page 59: IAI REVISION 2012

Finding the weights.

• The weights w0 and w1 have a smooth (continuously and differentiable) error surface. w.x

• The best value is unique. • We can gradually move

toward the global optima.

• LOSS= error

Small learning rate

Large learning rate

Page 60: IAI REVISION 2012

Transform from 2D to 3D

A 2D (x1, x2) coordinate maps to a 3D coordinate (f1, f2, f3)CLASS EXERSISE – DO THE FOLLOWING EXAMPLES – NEXT SLIDEf1 = x1*x1 f2 = x2*x2 f3 = 1.41*x1*x2(0,0) -> (?,?,?) (0,1) -> (?,?,?) (-1, -1) -> (?,?,?)

A linear decision boundaryA non-linear decision boundary

Page 61: IAI REVISION 2012

1, 2 or 3 layer Neural Networks

• One layer (a perceptron) defines a linear surface.

• Two layers can define convex hulls (and therefore any Boolean function)

• Just Three layers can define any function!!

In the general for the 2- and 3- layers cases, there is no simple way to determine the weights.

Page 62: IAI REVISION 2012

Terminology of Support Vector Machines

x

x

x

x

x

xx

xx

xx x

o

o

oo

o

oo o

o

o

o

marginSupport vectors

Maximum MarginSeparator

Page 63: IAI REVISION 2012

disadvantages of ANN

• We can look at someone else’s java program and try and understand it (it may not have comments and correct indentation – but we should understand it a little).

• An ANN is a jumble of numbers and is difficult to understand. Sometimes humans do not have confidence in them because they are difficult to explain.

Page 64: IAI REVISION 2012

Advantages of SVM

A perceptron depends on the initial weights and the learning rate. A perceptron may give a different answer each time – a SVM gives a unique and best answer. A perceptron can oscillate when training – and will not converge if the data is not linearly separable. A SVM will find the best solution it can – given the data it has.

Page 65: IAI REVISION 2012

Evolution and Genetic Algorithms• Evolution occurs in 3 part • Selection, inheritance, mutation.• We could artificially select e.g. tall

people – and over time – people would probably get taller. If we do not select in one direction – there would be no reason to change. Usually caused by the environment or man.

• Inheritance means you look like your parents.

• Mutation – introduces new genetic material into the gene pool.

Page 66: IAI REVISION 2012

Examples of “Problem Solving” ability of Evolution

• How can we eat meat but we are not digesting ourselves?

• How do ants find their way back to a nest – or birds migrate over vast distances?

• Bear + other animals hibernate in the winter to save energy.

• Symbiotic relationships…

Page 67: IAI REVISION 2012

GA and state space• The state space is the space of bit-strings. • FORMUATE THE PROBLEM • State: 0110 in knapsack – include 2 and 3 items and not

items 1 and 4• Initial state: any random starting point 1101• Action: generate new bit string (select-mutate) • Transition diagram: next slide – one bit mutation• Goal states: the ones with the best value. • Path cost: number of actions (maybe sucking takes twice

as much energy as moving??)

Page 68: IAI REVISION 2012

GA as search

• We can enumerate bit strings in different ways!• A GA can be thought of as a search process –

however unlike un/informed search methods – it is stochastic so does not give the same answer each time.

• With un/informed search we ORDER or SORT the list by g(n) + h(n).

• With GA we let evolution provide the ordering for us.

Page 69: IAI REVISION 2012

Genetic Algorithms and Artificial Neural Networks.

• We can code a ANN as a bit-string.

• We have a population of ANN. • (1.2, 4.1, -2.5, ….)• Is a list describing the weights

in a network.• Each number is changed a little

bit – so the network behaves like its parents did (i.e. not totally different).

• “Like father like son”• (Boys …look at your girlfriends

mother)

(1.2, 4.1, -2.5, ….)A linear list of numbers Represents the weights In an neural network.