outline introduction to soft computingpami.uwaterloo.ca/~khoury/ece457s07/lecture12.pdf · 1...

12
1 Introduction to Soft Computing ECE457 Applied Artificial Intelligence Spring 2007 Lecture #12 ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 2 Outline Overview of soft computing Neural networks Russell & Norvig, sections 20.5 Fuzzy logic Russell & Norvig, pages 526-527 Genetic algorithms Russell & Norvig, pages 116-120 ECE 493 & ECE 750 (Prof. Karray) ECE457 Applied Artificial Intelligence R. Khoury (2007) 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 ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 4 Soft vs. Hard Computing Human-like Rational Reasoning Output Input Solution that’s “good enough” Overly-exact solution Approximate and incomplete data Complete and exact data Soft Computing Hard Computing

Upload: truongthuy

Post on 19-Apr-2018

226 views

Category:

Documents


4 download

TRANSCRIPT

1

Introduction to Soft Computing

ECE457 Applied Artificial IntelligenceSpring 2007 Lecture #12

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

OutlineOverview of soft computingNeural networks

Russell & Norvig, sections 20.5

Fuzzy logicRussell & Norvig, pages 526-527

Genetic algorithmsRussell & Norvig, pages 116-120

→ ECE 493 & ECE 750 (Prof. Karray)

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

Soft ComputingBranch of AI that deals with systems and methodologies that can perform approximate, qualitative, human-like reasoningHumans 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

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

Soft vs. Hard Computing

Human-likeRationalReasoning

Output

Input

Solution that’s “good enough”

Overly-exact solution

Approximate and incomplete data

Complete and exact data

Soft ComputingHard Computing

2

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

Soft ComputingProbabilistic reasoning

Human randomness

Artificial neural networks (ANN)Human brain

Fuzzy logic (FL)Human knowledge

Evolutionary computing Genetic algorithms (GA)Biological evolution

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

Artificial Neural NetworksHuman Brain

Massively parallel network of neuronsEach individual neuron is not intelligent

Neuron is a simple computing element

But the brain is intelligent!

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

Human BrainBrain learns by changing and adjusting the connections between neuronsInformation encoded in many ways

Connection patterns of neuronsAmplification of signals by dendritesTransfer function and threshold values controlling whether the cell transmits the signal

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

NeuronsReceives electric impulse from other neurons through dendrites.If impulse strong enough, travels through axon.Reaches synapses and transmits to other neurons

3

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

Artificial Neuronith neuron sums inputs a1… aj… an, weighted by weights wi1… wij… winThreshold value θi controls activationIf 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

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

Artificial Neural NetworksLarge arrangement of inter-connected artificial neuronsDifferent classes of network

Topology of the networkTransfer function of the neuronsLearning algorithm

Different networks appropriate for different applications

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

PerceptronSimplest and most commonly-used ANNFeed-forward ANNSingle-layer

No hidden layerOnly linearly-separable problems

Multi-layerNon-linear problems

x1

x2

x3

o1

o2

Input layer

Hidden layer

Output layer

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

Examples

x1

x2

-1.5

1

1o

x1

x2

-0.5

1

1o

x1

x2

o

-0.5

-0.5

-0.51

1

1

1

-1

-1

OR Network

AND Network

XOR NetworkAll these neurons use step functions

f(<0) = 0

f(≥0) = 1

4

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

LearningBackpropagation algorithm

Train using a set of input-output pairsUsing the entire set = 1 epochSupervised learning

AlgorithmStart with random weightsForward propagation of each input, to get the network’s output and compute the network errorBack propagate the network error to the output of each neuron, to get the neuron errorUpdate the weights of the input of the neuron to minimise the neuron errorRepeat until min error or max training epoch

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

ANN TopologiesFeed-forward topology

Information can only move forward through the network

Recurrent topologyInformation can loop back to create feedback loop, or network memory

x1

x2

x3

o1

x1

x2

x3

o1

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

Feed-Forward NetworksPerceptron

Basic networkAny transfer functionsAny number of hidden layers

Radial Basis Function (RBF) NetworkSpecial class of multi-layer perceptronSingle hidden layer with RBF (typically Gaussian) transfer functionHidden neuron transformations are symmetric, bounded and localizedUseful for modelling systems with complex nonlinear behaviour, control systems, audio-video signal processing, …

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

Feed-Forward NetworksKohonen Self-Organising Map

Fully-connected two-layer networkUnsupervised learning

Output neuron compete to activateNeuron with highest output value winsWinning neuron and its neighbours have their weights updated

Creates a 2D topological mapping of the input vectors to the output layerUseful for pattern recognition, image analysis, data mining, …

x1 x2

5

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

Recurrent NetworksHopfield Network

First kind of recurrent ANNImplements an associative memory

Previous-stored patterns “complete” current (noisy or incomplete) pattern

Network is attracted to stable pattern in memoryUseful for information retrieval, pattern/speech recognition, …

x1

x2

x3

o1

o2

o3

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

Limits of ANNBlack box

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

No formal design rulesHow many hidden layers? How many neurons per layer? Which transfer functions?

Prone to overfittingBackpropagation is slow and can converge on local optimum

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

Fuzzy LogicIn 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

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

Temperature

1

0

Cold Warm Hot

Fuzzy LogicIn fuzzy logic, facts can be partially true and partially false

Truth value = [0, 1]

This is closer to human knowledge

6

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

Terminology“Cold”, “warm” and “hot” are fuzzy setThe triangle function mapping a value of temperature to a value of cold (or warm or hot) is called a fuzzy membership functionThe value of cold (or warm or hot) to which a temperature is mapped is called a membership degreeFz[t ∈ Cold] = µCold(t): ℜ → [0,1]

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

Fuzzy Sets vs. ProbabilitiesMembership degrees are notprobabilitiesBoth are measures over the range [0,1]Probabilistic view: x is or is not y, and we have a certain probability of knowing whichFuzzy view: x is more or less y, with a certain degree

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

Fuzzy RulesIf-then rules like other logics, but with fuzzy sets

If Cold then VentilationHighIf Warm then VentilationLowIf Hot then VentilationMedium

Variables belong partially to antecedent, therefore consequence activated partially

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

Fuzzy ControllerTypical application of fuzzy logicSet of fuzzy rulesDefine the behaviour of a system

Antecedent: variables that affect the systemConsequent: reaction of the system

7

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

Fuzzy Controller ExampleIf Hot and Wet then VeryCoolIf Warm and Humid then Cool

T

1

0

Hot

T

1

0

WarmH

1

0

H

1

0

C

1

0

C

1

0t h

Wet

Humid

VeryCool

Cool

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

Fuzzy Controller ExampleDefuzzification using centroid techniqueConverts fuzzy consequent C into crisp value that can be used by systemCentroid merges the output fuzzy sets and finds the center of gravity

C

1

0 c

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

Advantages of Fuzzy LogicPartial activation of multiple rules at onceAchieve complex non-linear behaviour with simple IF-THEN rulesUse linguistic variables to model words, rules of thumb, human knowledge

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

Properties of Fuzzy ControllersThe rule base must be

CompleteContinuous

The rules mustBe consistentNot interact

The rule base system must beRobustStable

8

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

Limits of Fuzzy LogicWriting the fuzzy rulesDesigning the fuzzy membership functions

Often requires work by a domain expert

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

Fuzzy Robot NavigationFuzzy controllers are very popular for robot navigationEliminates need for complete world model and complex reasoning rulesBasic robot

Known current position and targetThree sensors (front, left, right)Left and right wheels can turn at different speeds to make robot turn

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

Fuzzy Robot NavigationFuzzy linguistic variables of control system

Distance: near, medium, farDirection angle: negative, zero, positiveSpeed: slow, medium, fast

Distance

1

0

Near Medium Far

Direction

1

0

Negative Zero Positive

Speed

1

0

Slow Medium Fast

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

Fuzzy Robot NavigationGoing to target

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

Avoiding obstaclesIF (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 cornersIF (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 edgesIF (left obstacle is far) and (front obstacle is far) and (rightobstacle is near) and (angle is positive) THEN (left speed is medium) and (right speed is medium)

9

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

Fuzzy Robot Navigation

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

Genetic AlgorithmsBiological evolutionSpecies adapt to better survive in environmentOver generations

Pairs of individuals reproduceIndividuals mutateFittest individuals survive and go on to reproduce

Source: David M. Hillis, Derrick Zwickl, and Robin Gutell, University of Texas.

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

Evolutionary ComputingIntroduced by John Holland in “Adaptation in Natural and Artificial Systems”, 1975Stochastic search technique

Like simulated annealing!

Divided in four main classes (different representation of individuals)

Genetic algorithmsEvolution strategiesEvolutionary programmingGenetic programming

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

Genetic AlgorithmsSimulating biological evolution in AI

Evaluation functionFitness

OperatorsChanges from one generation to the next

State space to exploreProblem to solve

Environment

StatesSolutions to a problem

Individuals

Genetic AlgorithmsBiology

10

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

IndividualsIndividuals have a chromosome

String of genes (bits)Encodes the solution represented by the individualOften binary representation, but can be anything

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

01010011

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

OperatorsTo evolve, the population must changeGA typically use three operators to change the population

Crossover (sexual reproduction)Mutation (mutation)Selection (natural selection)

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

CrossoverSelect two fittest parentsSelect (random) splitting point in the chromosomesRecombine the genes to get childrenCauses slow move of the population around state space

01010011 01100011

01100010 01010010→

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

MutationSelect random childSelect random geneSwitch gene value according to mutation rule

Depends on representationTypically very rare (low mutation rate)Causes large leap across state space

01100011 01101011→↑

11

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

SelectionGA 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 individualsSurvival of the fittest!

Evaluate fitness of all individualsKill off (i.e. delete) least fit ones, keeping only the fittest (best solutions)

Each generation, the population improvesECE457 Applied Artificial Intelligence R. Khoury (2007) Page 42

Evolution AlgorithmStarts with random populationEvaluate fitness of all individualsFor each generation

Select fittest parents and crossoverMutate children according to mutation rateEvaluate fitness of new individualsSelect individuals that survive for next generation

Repeat untilGeneration limit reachedAn individual achieves the target fitness

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

Evolution AlgorithmIndividuals are random, but population converges slowly towards solution

Populationfitness

Generation

x x x* *

*

*

**

*

*

**

*

***

***

* ***

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

Genetic Algorithm Example8-Queen problemEnvironment: state spaceChromosome: encodes position of queensFitness: number of attacks

52751762

12

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

Genetic Algorithm Example

52751762

51563584

51563762

52751584

Crossover operation

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

Genetic Algorithm ExampleMutation operation

Complements (1-8, 2-7, 3-6, 4-5)Swap two random genes

52751584

52741584

52781554↑

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

Limits of Genetic AlgorithmsNot guaranteed to find the optimal solutionIn 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)