Git Product home page Git Product logo

rustneat's Introduction

Working-in-progress

Rust NEAT

travis-ci Gitter

Implementation of NeuroEvolution of Augmenting Topologies NEAT http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf

This implementations uses a CTRNN based onOn the Dynamics of Small Continuous-Time Recurrent Neural Network (Beer, 1995) http://www.cs.uvm.edu/~jbongard/2014_CS206/Beer_CTRNNs.pdf

telemetry

Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env

Run test

To speed up tests, run them with --release (XOR classification/simple_sample should take less than a minute)

cargo test --release

Run example

cargo run --release --example simple_sample --features=telemetry

then go to http://localhost:3000 to see how neural network evolves

telemetry

Run openai tests

telemetry

Install python dependencies

sudo apt install python3
sudo apt install python3-pip
sudo apt install libpython3.8-dev
sudo apt-get remove swig
sudo apt-get install swig3.0
sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
sudo pip3 install gym
sudo pip3 install gym[box2d]
sudo apt install python3-opengl

Run test

cargo run --release --example openai --features=openai,telemetry

Windows Openai

openai/gym#11 (comment)

Update to the latest version of Windows (>version 1607, "Anniversary Update")
Enable Windows Subsystem for Linux (WSL)
Open cmd, run bash
Install python & gym (using sudo, and NOT PIP to install gym). So by now you should probably be able to run things and get really nasty graphics related errors. This is because WSL doesn't support any displays, so we need to fake it.
Install vcXsrv, and run it (you should just have a little tray icon)
In bash run "export DISPLAY=:0" Now when you run it you should get a display to pop-up, there may be issues related to graphics drivers. Sadly, this is where the instructions diverge if you don't have an NVIDIA graphics card.
Get the drivers: "sudo apt-get install nvidia-319 nvidia-settings-319 nvidia-prime"
Run!

Sample usage

Create a new cargo project:

Add rustneat to Cargo.toml

[dependencies]
rustneat = "0.2.1"

Then use the library i.e. to implement the above example, use the library as follows:

extern crate rustneat;
use rustneat::Environment;
use rustneat::Organism;
use rustneat::Population;

struct XORClassification;

impl Environment for XORClassification {
    fn test(&self, organism: &mut Organism) -> f64 {
        let mut output = vec![0f64];
        let mut distance: f64;
        organism.activate(&vec![0f64, 0f64], &mut output);
        distance = (0f64 - output[0]).abs();
        organism.activate(&vec![0f64, 1f64], &mut output);
        distance += (1f64 - output[0]).abs();
        organism.activate(&vec![1f64, 0f64], &mut output);
        distance += (1f64 - output[0]).abs();
        organism.activate(&vec![1f64, 1f64], &mut output);
        distance += (0f64 - output[0]).abs();
        (4f64 - distance).powi(2)
    }
}

fn main() {
    let mut population = Population::create_population(150);
    let mut environment = XORClassification;
    let mut champion: Option<Organism> = None;
    while champion.is_none() {
        population.evolve();
        population.evaluate_in(&mut environment);
        for organism in &population.get_organisms() {
            if organism.fitness > 15.9f64 {
                champion = Some(organism.clone());
            }
        }
    }
    println!("{:?}", champion.unwrap().genome);
}

Develop

Check style guidelines with:

rustup component add rustfmt-preview cargo fmt

Thanks

Thanks for the icon nerves by Delwar Hossain from the Noun Project

References:

NeuroEvolution of Augmenting Topologies NEAT http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf

On the Dynamics of Small Continuous-Time Recurrent Neural Network (Beer, 1995) http://www.cs.uvm.edu/~jbongard/2014_CS206/Beer_CTRNNs.pdf

An Investigation into the Dynamics of a Continuous Time Recurrent Neural Network Node http://www.tinyblueplanet.com/easy/FCSReport.pdf

http://indy9000.github.io/posts/analysis-of-a-simple-ctrnn.html http://indy9000.github.io/posts/analysis-of-a-simple-ctrnn.html

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.