15. 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:
25. Designing your genetic algorithm
Asexual vs sexual breeding
Breed top performers or all?
How often to cull?
Mutation rate
26. 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
30. 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