genetic algorithms for neural networks an introduction

30
Genetic algorithms for neural networks An introduction

Post on 20-Dec-2015

235 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Genetic algorithms for neural networks An introduction

Genetic algorithms for neural networks

An introduction

Page 2: Genetic algorithms for neural networks An introduction

Genetic algorithms

• Why use genetic algorithms?– “What aren’t genetic algorithms?”

• What are genetic algorithms?

• What to avoid

• Using genetic algorithms with neural networks

Page 3: Genetic algorithms for neural networks An introduction

Why use genetic algorithms?

Page 4: Genetic algorithms for neural networks An introduction

What aren’t genetic algorithms?

• Hill-climbing algorithms

• Enumerative algorithms

• Random searches– Guesses– Ask an expert

• Educated guesses

Page 5: Genetic algorithms for neural networks An introduction

Hill-climbing

• Calculus based approach

Page 6: Genetic algorithms for neural networks An introduction

But…

?

?

Page 7: Genetic algorithms for neural networks An introduction

But…

?

?

?

?

?

?

Page 8: Genetic algorithms for neural networks An introduction

More realistically?

?

?

?

?

?

?

?

?

?

?

?

?

•Noisy?

•Discontinuous?

Page 9: Genetic algorithms for neural networks An introduction

Robust scheme

Page 10: Genetic algorithms for neural networks An introduction

Genetic algorithms

• Cope with non-linear functions

• Cope with large numbers of variables efficiently

• Cope with modelling uncertainties

• Do not require knowledge of the function

Page 11: Genetic algorithms for neural networks An introduction

What are genetic algorithms?

Chromosome

Population

Page 12: Genetic algorithms for neural networks An introduction

Circle of life

Good

Bad

Page 13: Genetic algorithms for neural networks An introduction

Chromosome

• A collection of genes

[xi1, xi2, xi3, xi4, …]

Page 14: Genetic algorithms for neural networks An introduction

Fitness

• Ranked by a fitness factor

• Proportional to the likelihood of breeding

• Action of the algorithm is to maximise fitness

Page 15: Genetic algorithms for neural networks An introduction

Breeding and crossover

• Parents selected randomly with a probability proportional to fitness– Roulette wheel algorithm

• Genes are crossed over between parents

[x11, x12, x13, x14]

[x21, x22, x23, x24]

[x11, x22, x23, x24]

[x21, x12, x13, x14]

Page 16: Genetic algorithms for neural networks An introduction

Mutation

• Small (random) variation in a gene:

[xi1, xi2, xi3, xi4] --> [xi1, xi2, xi3+∂, xi4]

Page 17: Genetic algorithms for neural networks An introduction

Circle of life

Good

Bad

Page 18: Genetic algorithms for neural networks An introduction

Genetic algorithms

• Work on populations, not single points• Use an objective function (fitness) only,

rather than derivatives or other information• Use probabilistic rules rather than

deterministic rules• Operate on an encoded set of values (a

chromosome) rather than the values themselves

Page 19: Genetic algorithms for neural networks An introduction

Potential problems

• GA deceptive functions

• Premature and postmature convergence

• Excessive mutation

• Application to constrained problems– Neural networks, particularly

• The meaning of fitness

Page 20: Genetic algorithms for neural networks An introduction

Deceptive functions and premature convergence

• A function which selects for one gene when a combination would be better

• Can eliminate “better” genes• Avoided by

– Elitism– Multiple populations– Mutation (which reintroduces genes)– Fitness scaling

Page 21: Genetic algorithms for neural networks An introduction

Postmature convergence

• When all of a population performs well, selection pressures wane

• Avoided by fitness scaling (be careful!)

Page 22: Genetic algorithms for neural networks An introduction

Excessive mutation

• Too little mutation = loss of genes

• Too much mutation = random walk

Page 23: Genetic algorithms for neural networks An introduction

Application to constrained problems

• Neural networks and genetic algorithms are by nature unconstrained– i.e they can take any value

• Must avoid unphysical values

• Restrict mutation

• Punish through fitness function

Page 24: Genetic algorithms for neural networks An introduction

The meaning of fitness

• Genetic algorithms maximise fitness

• Therefore fitness must be carefully defined

• What are you actually trying to do?

Page 25: Genetic algorithms for neural networks An introduction

When to stop?

• How long do we run the algorithm for?– Until we find a solution– Until a fixed number of generations has been

produced– Until there is no further improvement– Until we run out of time or money…?

Page 26: Genetic algorithms for neural networks An introduction

Genetic algorithms for Bayesian neural networks

• Generally want to find an optimised input set for a particular defined output

Page 27: Genetic algorithms for neural networks An introduction

Define “fitness”

• Need a function that includes target and uncertainty:

Fi =1

σ i

σ i2 = σ y

2 + (t − f i)2

Page 28: Genetic algorithms for neural networks An introduction

Define the chromosome

• Set of inputs to the network except– Derived inputs must be removed

• e.g. if you have both t and ln(t), or T and exp(-1/T), only one can be included– Prevents unphysical input sets being found

Page 29: Genetic algorithms for neural networks An introduction

Create the populations

• Chromosomes are randomly generated– (avoid non-physical values)– Population size must be considered– 20 is a good start

• Best to use more than one population– Trade-off between coverage and time– Three is good

Page 30: Genetic algorithms for neural networks An introduction

Run the algorithm!

1. Decode chromosomes to NN inputs (i.e. calculate any other inputs)

2. Make predictions for each chromosome• if the target is met or enough generations have

happened, stop3. Calculate fitness for each chromosome4. Preserve the best chromosome (elitism)5. Breed 18 new chromosomes by crossbreeding6. Mutate one (non-elite) gene at random7. Create new chromosome at random8. Go back to 1