際際滷

際際滷Share a Scribd company logo
Genetic Algorithms
David Mack
david@octavian.ai
https://octavian.ai
David Mack
https://octavian.ai
david@octavian.ai
A little story...
Failing to train a recommendation system
Test
accuracy
Time
16%
Recommender
Learned
embedding
Lots of hyper-parameters
Embedding size
Learning rate
Number of deep layers
etc....
Picking an
embedding
size
0.01 ?
0.03 ?
0.05 ?
1.0 ?
10.0 ?
Help!!
So lets try a genetic algorithm!
An introduction to Genetic Algorithms (Dublin Data Science)
What are genetic
algorithms?
argmaxx f(x)
x1 x2 x3 x4
x5 x6 x7 x8
We create a population...
1. Remove the weakest
2. Spawn mutated copies
Repeat many
times!
This two-step algorithm is
able to maximise f(x)
The population fans-out over time
DeepMind: Population based training of neural networks
while True:
stack = population.sort(key=fitness) # Sort by fitness
fittest = stack[n_cull:] # Delete the weakest
population = []
for i in range(n_cull):
# Spawn mutated copies
population.append(random.choice(fittest).mutate())
population.extend(fittest)
in 7 lines of python:
Benefits of genetic algorithms
They can be applied to diverse problems
Neural networks antenna
Race car humans
They often come up with designs humans
wouldnt have thought of
They can navigate large and complex
state spaces
They dont require functions to be
differentiable
And the downside?
They take a lot of time/compute
6 million
years =
Q&A
https://octavian.ai
David Mack
david@octavian.ai
Appendix
Designing your genetic algorithm
 Asexual vs sexual breeding
 Breed top performers or all?
 How often to cull?
 Mutation rate
Bonus: Population based training
 Lets combine gradient descent with genetic algorithms for fun and
profit
 Good efficiency trade-off between trying many options and not
discarding work done
diagram
Population based training
Population based training
Population based training
Genetic algorithm vs Gradient descent
Genetic algorithm Gradient descent
Works for any function Function must be differentiable
Slower Faster
Requires you to design a random mutation function
Good for generating answers to unknown spaces Good for generating answers to well modelled spaces
Very easy to distribute Harder to distribute
They help escape your God complex

More Related Content

An introduction to Genetic Algorithms (Dublin Data Science)