introduction to soft computing ece457 applied artificial intelligence spring 2008 lecture #12

54
Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

Upload: georgiana-thomas

Post on 12-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

Introduction to Soft Computing

ECE457 Applied Artificial IntelligenceSpring 2008Lecture #12

Page 2: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 2

Outline Overview of soft computing Fuzzy logic

Russell & Norvig, pages 526-527 Neural networks

Russell & Norvig, sections 20.5 Genetic algorithms

Russell & Norvig, pages 116-120

ECE 493 & ECE 750 (Prof. Karray)

Page 3: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 3

Soft Computing Branch of AI that deals with systems and

methodologies that can perform approximate, qualitative, human-like reasoning

Humans can make intelligent decisions using incomplete and imprecise information “Soft” reasoning

Computer algorithms require complete and precise information “Hard” reasoning

Soft computing aims to bridge this gap

Page 4: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 4

Soft vs. Hard Computing

Hard Computing

Soft Computing

InputComplete and

exact data

Approximate and incomplete

data

OutputOverly-exact

solutionSolution that’s “good enough”

Reasoning

Rational Human-like

Page 5: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 5

Soft Computing Probabilistic reasoning

Human uncertainty and randomness Artificial neural networks (ANN)

Human brain Fuzzy logic (FL)

Human knowledge Evolutionary computing

Genetic algorithms (GA) Biological evolution

Page 6: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 6

Fuzzy Logic In crisp logic, facts are either true

or false Truth value = {0, 1}

This is an unnatural way of doing it

Temperature

1

0

Cold

Warm Hot

Page 7: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 7

Temperature

1

0

Cold

Warm Hot

Fuzzy Logic In fuzzy logic, facts can be partially

true and partially false Truth value = [0, 1]

This is closer to human knowledge

Page 8: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 8

Terminology “Cold”, “warm” and “hot” are fuzzy

set The triangle function mapping a value

of temperature to a value of cold (or warm or hot) is called a fuzzy membership function

The value of cold (or warm or hot) to which a temperature is mapped is called a membership degree

Fz[t Cold] = μCold(t): [0,1]

Page 9: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 9

Fuzzy Sets vs. Probabilities Membership degrees are not

probabilities Both are measures over the range

[0,1] Probabilistic view: x is or is not y,

and we have a certain probability of knowing which

Fuzzy view: x is more or less y, with a certain degree

Page 10: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 10

Fuzzy Rules If-then rules like other logics, but

with fuzzy sets If Cold then VentilationHigh If Warm then VentilationLow If Hot then VentilationMedium

Variables belong partially to antecedent, therefore consequence activated partially

Page 11: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 11

Fuzzy Controller Typical application of fuzzy logic Set of fuzzy rules Define the behaviour of a system

Antecedent: variables that affect the system

Consequent: reaction of the system

Page 12: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 12

Fuzzy Controller Example If Hot and Wet then VentilationLow If Warm and Humid then VentilationMedium

T

1

0

Hot

T

1

0

Warm

H

1

0

H

1

0

S

1

0

S

1

0t h

Wet

Humid

VentilationLow

VentilationMedium

Page 13: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 13

Fuzzy Controller Example Defuzzification using centroid

technique Converts fuzzy consequent into

crisp value that can be used by system

Centroid merges the output fuzzy sets and finds the center of gravity

S

1

0 s

Page 14: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 14

Advantages of Fuzzy Logic Partial activation of multiple rules

at once Achieve complex non-linear

behaviour with simple IF-THEN rules

Use linguistic variables to model words, rules of thumb, human knowledge

Page 15: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 15

Properties of Fuzzy Controllers The rule base must be

Complete Continuous

The rules must Be consistent Not interact

The rule base system must be Robust Stable

Page 16: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 16

Limits of Fuzzy Logic Writing the fuzzy rules Designing the fuzzy membership

functions Often requires work by a domain

expert

Page 17: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 17

Fuzzy Robot Navigation Fuzzy controllers are very popular

for robot navigation Eliminates need for complete world

model and complex reasoning rules Basic robot

Known current position and target Three sensors (front, left, right) Left and right wheels can turn at

different speeds to make robot turn

Page 18: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 18

Fuzzy Robot Navigation Fuzzy linguistic variables of control

system Distance: near, medium, far Direction angle: negative, zero, positive Speed: slow, medium, fast

Distance

1

0

Near Medium

Far

Direction

1

0

Negative

Zero Positive

Speed

1

0

Slow Medium

Fast

Page 19: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 19

Going to target IF (left obstacle is far) and (front obstacle is far) and

(right obstacle is far) and (angle is zero) THEN (left speed is fast) and (right speed is fast)

Avoiding obstacles IF (left obstacle is far) and (front obstacle is near)

and (right obstacle is far) and (angle is zero) THEN (left speed is fast) and (right speed is slow)

Turning corners IF (left obstacle is medium) and (front obstacle is

near) and (right obstacle is near) and (angle is any) THEN (left speed is slow) and (right speed is fast)

Following edges IF (left obstacle is far) and (front obstacle is far) and

(right obstacle is near) and (angle is positive) THEN (left speed is medium) and (right speed is medium)

Fuzzy Robot Navigation

Page 20: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 20

Fuzzy Robot Navigation

Page 21: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 21

Artificial Neural Networks Human Brain

Massively parallel network of neurons

Each individual neuron is not intelligent

Neuron is a simple computing element

But the brain is intelligent!

Page 22: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 22

Human Brain Brain learns by changing and

adjusting the connections between neurons

Information encoded in many ways Connection patterns of neurons Amplification of signals by dendrites Transfer function and threshold

values controlling whether the cell transmits the signal

Page 23: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 23

Neuron Receives electric impulse from

other neurons through dendrites. If impulse strong enough, travels

through axon. Reaches synapses and transmits to

other neurons

Page 24: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 24

Artificial Neuron ith neuron sums inputs a1… aj… an,

weighted by weights wi1… wij… win Threshold value i controls activation If activated, input is transformed by

transfer function fi(.) into output ai

ai = fi( jwijaj - i ) = [0, 1]

aj

wij

i

ai fi(.)

Dendrites

Axon

Synapse

Cell body

Page 25: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 25

Artificial Neural Networks Large arrangement of inter-

connected artificial neurons Different classes of network

Topology of the network Transfer function of the neurons Learning algorithm

Different networks appropriate for different applications

Page 26: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 26

Perceptron Simplest and most

commonly-used ANN

Feed-forward ANN Single-layer

No hidden layer Only linearly-

separable problems Multi-layer

Non-linear problems

x1

x2

x3

o1

o2

Input layer

Hidden

layer

Output layer

Page 27: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 27

Examples

x1

x2

-1.5

1

1o

x1

x2

-0.5

1

1o

x1

x2

o

-0.5

-0.5

-0.5 1

1

1

1

-1

-1

OR Network

AND Network

XOR NetworkAll these neurons use step functions

f(<0) = 0

f(0) = 1

Page 28: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 28

Learning Backpropagation algorithm

Train using a set of input-output vectors

Modify weights of network to minimize the error

Difference between the training output vector and the network’s actual output vector

Supervised learning Using the entire training set = 1

epoch

Page 29: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 29

Backpropagation algorithm Start with random weights For each epoch

Forward propagation of each input vector, to get the network’s output vector

Compare network output to target output of training set, and compute the network error

Starting from output layer and going backwards, back propagate the network error to each layer

Update the input weights of each neuron in each layer to minimise the network error

Repeat until min network error or max epoch

Page 30: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 30

Learning Given

The weight vector w, where w(l) represents the weights of the connections from layer l-1 to layer l

A set of n input-output vectors, each composed of an input a(k) and a target output t(k)

A network with q output neurons Algorithm

Forward propagation of each input vector k in n, to get the network’s output vector o(k)

Compute the network error given each output neuron i in q

Back-propagate and update weight vector w to minimize Ec

n

k

q

iiic koktE

1 1

2)()(2

1

)()(

lcl

w

Ew

Page 31: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 31

ANN Topologies Feed-forward

topology Information can

only move forward through the network

Recurrent topology Information can

loop back to create feedback loop, or network memory

x1

x2

x3

o1

x1

x2

x3

o1

Page 32: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 32

Feed-Forward Networks Perceptron

Basic network Any transfer functions Any number of hidden layers

Radial Basis Function (RBF) Network Special class of multi-layer perceptron Single hidden layer with RBF (typically

Gaussian) transfer function Hidden neuron transformations are

symmetric, bounded and localized Useful for modelling systems with complex

nonlinear behaviour, control systems, audio-video signal processing, …

Page 33: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 33

Feed-Forward Networks Kohonen Self-Organising Map

Fully-connected two-layer network Unsupervised learning

Output neuron compete to activate Neuron with highest output value

wins Winning neuron and its neighbours

have their weights updated Creates a 2D topological mapping

of the input vectors to the output layer

Useful for pattern recognition, image analysis, data mining, …

x1 x2

Page 34: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 34

Recurrent Networks Hopfield Network

First kind of recurrent ANN Implements an associative

memory Previous-stored patterns

“complete” current (noisy or incomplete) pattern

Network is attracted to stable pattern in memory

Useful for information retrieval, pattern/speech recognition, …

x1

x2

x3

o1

o2

o3

Page 35: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 35

Limits of ANN Black box

What does each neuron do? What does each weight do?

No formal design rules How many hidden layers? How many

neurons per layer? Which transfer functions?

Prone to overfitting Backpropagation is slow and can

converge on local optimum

Page 36: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 36

ANN Classifier Typical application of ANN Requires

A set of crisp, mutually-exclusive classes

A set of well-defined, measurable attributes relevant to classification

Correctly-classified training data Compared to Naïve Bayes Classifier

Does not require any probabilities

Page 37: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 37

ANN Classifier Design Pick network architecture based on

problem Or simply pick perceptron

One input neuron per attribute One output neuron per class Add hidden layers if classification is

non-linear function of input space Exact number of layers or neurons

difficult to discover Train network

Page 38: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 38

ANN Classifier Example Paper on website Classification of pixels

in aerial photograph Classes: lake, forest or

land Input: pixel’s RGB value

Data 180 training pixels 300 testing pixels

Page 39: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 39

ANN Classifier Example Perceptron network

Good for complex classification problems

Two hidden layers Number of hidden layers /

neurons per hidden layer discovered by trial-and-error One hidden layer not precise

enough First layer neurons input neurons Second layer neurons

max(input neurons, output neurons)

More hidden neurons give higher precision, need more training time

Page 40: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 40

ANN Classifier Example Classification precision: 93%

Naïve Bayes Classifier: 88% Network later expanded to 7 classes

Water, marsh, farmland, woodland, grassland, residential area, salina

Still has RGB input, two hidden layers 7 output neurons, more neurons on

hidden layers Precision: 97%

Naïve Bayes Classifier: 89%

Page 41: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 41

Genetic Algorithms Biological evolution Species adapt to

better survive in environment

Over generations Pairs of individuals

reproduce Individuals mutate Fittest individuals

survive and go on to reproduceSource: David M. Hillis, Derrick Zwickl, and Robin Gutell, University of Texas.

Page 42: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 42

Evolutionary Computing Introduced by John Holland in

“Adaptation in Natural and Artificial Systems”, 1975

Stochastic search technique Like simulated annealing!

Divided in four main classes (different representation of individuals) Genetic algorithms Evolution strategies Evolutionary programming Genetic programming

Page 43: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 43

Genetic Algorithms Simulating biological evolution in

AIBiology Genetic Algorithms

IndividualsStates

Solutions to a problem

EnvironmentState space to

exploreProblem to solve

Fitness Evaluation function

Changes from one generation to the

nextOperators

Page 44: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 44

Individuals Individuals have a chromosome

String of genes (bits) Encodes the solution represented by

the individual Often binary representation, but can

be anything

Length, nature of bits, meaning, varies according to problem

1 1 0 0 1 0 1 0

Page 45: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 45

Operators To evolve, the population must

change GA typically use three operators to

change the population Crossover (sexual reproduction) Mutation (mutation) Selection (natural selection)

Page 46: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 46

Crossover Select two fittest parents Select (random) splitting point in the

chromosomes Recombine the genes to get children Causes slow move of the population

around state space

1 1 0 0 1 0 1 0 1 1 0 0 0 1 1 0

0 1 0 0 0 1 1 0 0 1 0 0 1 0 1 0

Page 47: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 47

Mutation Select random child Select random gene Switch gene value according to

mutation rule Depends on representation

Typically very rare (low mutation rate) Causes large leap across state space

1 1 0 0 0 1 1 0 1 1 0 1 0 1 1 0

Page 48: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 48

Selection GA population have zero population

growth We can’t keep them all (computer limits)

and we don’t want to (they’re useless) But each crossover operation generates

two more, new individuals Survival of the fittest!

Evaluate fitness of all individuals Kill off (i.e. delete) least fit ones,

keeping only the fittest (best solutions) Each generation, the population improves

Page 49: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 49

Evolution Algorithm Starts with random population Evaluate fitness of all individuals For each generation

Select fittest parents and crossover Mutate children according to mutation rate Evaluate fitness of new individuals Select individuals that survive for next

generation Repeat until

Generation limit reached An individual achieves the target fitness

Page 50: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 50

Evolution Algorithm Individuals are random, but

population converges slowly towards solution

Population

fitness

Generation

x x x

* *

*

*

**

*

*

**

*

***

***

* ***

Page 51: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 51

Genetic Algorithm Example

8-Queen problem Environment: state

space Chromosome:

encodes position of queens

Fitness: number of attacks

2 6 7 1 5 7 2 5

Page 52: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 52

Genetic Algorithm Example

2 6 7 1 5 7 2 5

4 8 5 3 6 5 1 5

2 6 7 3 6 5 1 5

4 8 5 1 5 7 2 5

Crossover operation

Page 53: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 53

Genetic Algorithm Example Possible mutation

operations Complements (1-8, 2-7, 3-

6, 4-5) Swap two random genes

4 8 5 1 5 7 2 5

4 8 5 1 4 7 2 5

4 5 5 1 8 7 2 5

Page 54: Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2008 Lecture #12

ECE457 Applied Artificial Intelligence R. Khoury (2008) Page 54

Limits of Genetic Algorithms Not guaranteed to find the optimal

solution In large complex state spaces, or with a

low mutation rate, might converge to local optimum (premature convergence)

High mutation rate can prevent convergence (mutation interference)

Interdependence between genes makes it hard to find solution (epistasis)