#neural-network #neuro-evolution #neat #algorithm #genetic-algorithm #genetic #aumenting-topologies

rustneat

Implementation of NeuroEvolution of Augmenting Topologies NEAT http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf with a Continuous-Time Recurrent Neural Networks

11 releases

Uses old Rust 2015

0.2.1 May 28, 2018
0.2.0 May 15, 2018
0.1.8 Nov 20, 2016
0.1.6 Oct 17, 2016
0.1.0 Jul 31, 2016

#561 in Machine learning

44 downloads per month

MIT license

59KB
1.5K SLoC

Rust 1K SLoC // 0.0% comments JavaScript 211 SLoC

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 Continuous-Time Recurrent Neural Network (CTRNN) (Yamauchi and Beer, 1994).

telemetry

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

Sample usage

Create a new cargo project:

Add rustneat to Cargo.toml

[dependencies]
rustneat = "0.1.5"

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 -- --write-mode=diff

Thanks

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

Dependencies

~1.3–4MB
~77K SLoC