NEATeRS is a library for training a genetic neural net through reinforcement learning.

Overview

NEATeRS

ci-workflow codecov

NEATeRS is a library for training a genetic neural net through reinforcement learning.

It uses the NEAT algorithm developed by Ken Stanley which enables the neural net to evolve its own topology. As a result it is not necessary to know the right amount of hidden nodes as the algorithm adds them as needed using evolution with mutation. However it will also take longer to fit to a solution as it does not use prior data and it does not improve the network with backpropagation.

Nowadays there is also HyperNEAT which is an approach more suitable for larger problems and networks. It is still an active field of research and therefore we implemented the standard NEAT algorithm.

Schedule

This is still only an overview of the library and the alpha version is still under development. It is NOT ready to use, not even for any experimental beta testers, as it does not work yet.

Usage Example

= vec![0.7, 0.3]; let res = nn.compute(input); println!("The best neural network gave {} as its result for the given input", res[0]); } // simple fitness function which computes the difference to 0.5 and gives a higher fitness the closer the result is fn compute_fitness(res: Vec ) -> f64 { let expected_value: f64 = 0.5; let value: f64 = res[0]; let mut diff: f64 = expected_value - value; if diff < 0 {diff = diff * -1.0;} if diff == 0 {return f64::MAX;} return 1 / diff; } ">
use neaters::{Solver, NeuralNetwork};

fn main() {
	// Create a new problem solver for a problem with 2 input nodes and one output node:
	let mut solver: Solver = Solver::with_size(2, 1);

	// Train for 200 generations
	for i in 1..=200 {
		// For each neural network in the current generation run and evaluate them by assigning a fitness score:
		for nn in solver.neural_nets() {
			let input: Vec<f64> = vec![0.2, 0.8];
			let res: Vec<f64> = nn.compute(input);
			let fitness: f64 = compute_fitness(res);
			nn.assign_fitness(fitness);
		}
		println!("Average fitness in generation {} was {}", i, solver.average_fitness());
		solver.new_generation();
	}

	// Solver is trained, we can now use it for some tasks:
	let mut nn: NeuralNetwork = solver.best_neural_network();
	let input: Vec<f64> = vec![0.7, 0.3];
	let res = nn.compute(input);
	println!("The best neural network gave {} as its result for the given input", res[0]);
}

// simple fitness function which computes the difference to 0.5 and gives a higher fitness the closer the result is
fn compute_fitness(res: Vec<f64>) -> f64 {
	let expected_value: f64 = 0.5;
	let value: f64 = res[0];
	let mut diff: f64 = expected_value - value;
	if diff < 0 {diff = diff * -1.0;}
	if diff == 0 {return f64::MAX;}
	return 1 / diff;
}

Features

  • creating neural networks
  • storing and loading networks
  • commented most functionality
  • handling errors with io in NeuralNetwork
  • creating a solver
  • storing and loading solver
  • handling errors with io in Solver
  • creating a phenotype
  • compute() function for neural network
  • sanitizing input
  • assign_fitness() function for neural network
  • new_generation() function for solver
  • average_fitness() function for solver
  • best_neural_network() function for solver
  • add advanced logging of stats to solver

Implementation

  • Solver is the main object for training. It contains several stats, all neural networks as well as the fitness of all networks and it performs the evolution process and creates the new generation of networks.
  • NeuralNetwork is the neural network itself. It contains information about the edges and nodes and has functions to compute a result and to mutate itself.
You might also like...
Rust library for genetic algorithms

Spiril Spiril is an implementation of a genetic algorithm for obtaining optimum variables (genetics) for a task through mutation and natural selection

Practice repo for learning Rust. Currently going through "Rust for JavaScript Developers" course.

rust-practice 🦀 Practice repo for learning Rust. Directories /rust-for-js-dev Files directed towards "Rust for JavaScript Developers" course. Thank y

SlintDotnet is a C# bindings project to enable developers to use Slint UI with .NET C#

SlintDotnet (Alpha) Slint is a UI toolkit that supports different programming languages. SlintDotnet is the integration with .NET C#. ⚠️ This is exper

Execute genetic algorithm (GA) simulations in a customizable and extensible way.

genevo genevo provides building blocks to run simulations of optimization and search problems using genetic algorithms (GA). The vision for genevo is

Deduplicating Training Data Makes Language Models Better

Deduplicating Training Data Makes Language Models Better This repository contains code to deduplicate language model datasets as descrbed in the paper

Embedded Rust on Espressif training material.

Embedded Rust Trainings for Espressif This repository contains Training Material for learning to use Embedded Rust with the Espressif ESP32-C3. We sug

Personal experiments with genetic algorithms and neuroevolution, in Rust, with the Bevy engine.

The Tango Problem Personal experiments with genetic algorithms and neuroevolution, in Rust, with the Bevy engine. A number of "Psychics" are placed in

Simple neural network library for classification written in Rust.

Cogent A note I continue working on GPU stuff, I've made some interesting things there, but ultimately it made me realise this is far too monumental a

Owner
TecTrixer
TecTrixer
Training material for the KDAB training day 2023

Rust & Qt workshop This workbook contains the material for a Rust & Qt workshop held by Ferrous Systems, developed and held together with KDAB. It is

Ferrous Systems 4 Nov 17, 2023
Reinforcement learning library written in Rust

REnforce Reinforcement library written in Rust This library is still in early stages, and the API has not yet been finalized. The documentation can be

Niven Achenjang 20 Jun 14, 2022
Border is a reinforcement learning library in Rust

Border Border is a reinforcement learning library in Rust. For reusability of both RL environments and agents, this library provides a reference imple

Taku Yoshioka 1 Dec 15, 2022
A simple neural net implementation.

PROPHET - Neural Network Library Linux Windows Codecov Coveralls Docs Crates.io A simple neural net implementation written in Rust with a focus on cac

Robin Freyler 41 Sep 16, 2022
Rust implementation of real-coded GA for solving optimization problems and training of neural networks

revonet Rust implementation of real-coded genetic algorithm for solving optimization problems and training of neural networks. The latter is also know

Yury Tsoy 19 Aug 11, 2022
A fast, safe and easy to use reinforcement learning framework in Rust.

RSRL (api) Reinforcement learning should be fast, safe and easy to use. Overview rsrl provides generic constructs for reinforcement learning (RL) expe

Thomas Spooner 139 Dec 13, 2022
Reinforcement learning with Rust

ReLearn: A Reinforcement Learning Library A reinforcement learning library and experiment runner. Uses pytorch as the neural network backend via the t

Eric Langlois 10 Jun 14, 2022
A machine learning library for supervised training of parametrized models

Vikos Vikos is a library for supervised training of parameterized, regression, and classification models Design Goals Model representations, cost func

Blue Yonder GmbH 10 May 10, 2022
High performance distributed framework for training deep learning recommendation models based on PyTorch.

PERSIA (Parallel rEcommendation tRaining System with hybrId Acceleration) is developed by AI platform@Kuaishou Technology, collaborating with ETH. It

null 340 Dec 30, 2022
Machine learning Neural Network in Rust

vinyana vinyana - stands for mind in pali language. Goal To implement a simple Neural Network Library in order to understand the maths behind it. This

Alexandru Olaru 3 Dec 26, 2022