Genetic Algorithm Implementation in tensorflow

Genetic Algorithm Implementation in tensorflow

Tensorflow is a machine learning library launched by Google 2 years ago. It has gained popularity quite early and is being used widely by many ML experts. I started experimenting with it by implementing very interesting project. Program automates playing of popular dinosaur game on Chrome when there is no network connection. After many iterations of playing, program improves itself using genetic algorithm and becomes a Ninja player.

There are 12 neural networks(Genome) representing a generation. Each Genome is tested by playing the game and its success is measured by number of cactuses jumped. When an entire generation is completed, I remove the worst genomes until achieving 4 genomes. With those 4 genomes, I then select two randomly, and cross-over their configurations creating 6 new genomes. After that, I apply random mutations in the configurations of the Neural Network, creating 2 new genomes. Thus, all 12 genomes tested again and all the process is applied after running each generation.

I have implemented the project using tensorflow, flask(to feed sensor data to program from browser), redis for improving performance, scanner. Neural network is built of multiplayer perceptron.

Entire code is available at https://github.com/ajaiswal-ht/imdino . Follow the instructions to run the program.

To view or add a comment, sign in

Explore content categories