Working with a Genetic Algorithm
TensorFlow can also be used to update any iterative algorithm that we can express in a computational graph. One such iterative algorithm is a genetic algorithm, an optimization procedure.
Getting ready
In this recipe, we will illustrate how to implement a simple genetic algorithm. Genetic algorithms are a way to optimize over any parameter space (discrete, continuous, smooth, non-smooth, and so on.). The idea is to create a population of randomly initialized solutions, and apply selection, recombination, and mutation to generate new (and potentially better) child solutions. The whole idea rests on the fact that we can calculate the 'fitness' of an individual solution by seeing how well that individual solves the problem.
Generally, the outline for a genetic algorithm is to start with a randomly initialized population, rank them in terms of their fitness, and select the top fit individuals to randomly recombine (or cross over) to create new child...