Giter VIP home page Giter VIP logo

modeling_evolution_with_tensorflowjs's Introduction

Overview

This is the code for this video on Youtube by Siraj Raval on Modeling Evolution with Tensorflow.js.

DEMO

Evolution Simulator

  • Neural Network
  • Genetic Algorithm
  • Physics Environment

Project Structure

  • Environments : Various Environment Models
  • Creatures : Various Creature Models
  • NeuroEvolution : Neural Network and Genetic Algorithm library
  • Lib : p5.js, Matter.js and Tensorflow.js

System Design

1. Neural Network

All creatures have a 3 layer feed-forward Neural Network as their brain. The topology is 4 - 100 - X, where the number of nodes X in the output layer depend on the number of muscles of the creature. The input data fed to the network are:

  • Horizontal velocity
  • Vertical Velocity
  • Torque
  • Height above the ground level

2. Genetic Algorithm Design

a. Score:

A creature can gain points based on the distance it travels from the starting point. The further it travels in the correct direction, the more point it gains. Traveling in the opposite direction, will reduce the point.

b. Fitness Function:

The further the creatures go to the right the more they are rewarded.

c. Selection Algorithm:

The creatures are selected for breeding based on their fitness value. The fitness value acts like a probability of being chosen for reproduction. Creatures that perform better have higher fitness value and hence has higher chance of reproducing.

d. Crossover:

The objective of this function is to generate a new child by combining the genes of two parents.

Two creatures (parents) are selected using the selection algorithm. Their weights are interchanged randomly bit wise as shown in the picture below to form a new set of weights. In our case, a single bit represents a single weight. This new set of weights is used to form a new creature (child).

e. Mutation:

The objective of this function is to introduce randomness in the population by tweaking the weights in the Neural network (brain) of a creature.

This function accepts a mutation rate as its parameter. The mutation rate, which is usually about 1 - 2%, is in fact the probability of introduction of randomness.

Credits

The credits for this code go to adityathebe. I've merely created a wrapper to get people started.

modeling_evolution_with_tensorflowjs's People

Contributors

llsourcell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.