NEAT (NeuroEvolution of Augmenting Topologies) implemented in Go

Overview

alt text GoDoc Go Report Card cover.run go

CURRENTLY NOT WORKING! There will be a further notice when it's updated.

NEAT (NeuroEvolution of Augmenting Topologies) is a neuroevolution algorithm by Dr. Kenneth O. Stanley which evolves not only neural networks' weights but also their topologies. This method starts the evolution process with genomes with minimal structure, then complexifies the structure of each genome as it progresses. You can read the original paper from here.

Installation

To install neat run the following:

$ go get -u github.com/jinyeom/neat

Usage

This NEAT package is as simple as plug and play. All you have to do is to create a new instance of NEAT, given the configuration from a JSON file, for which the template is provided below, and an evaluation method of a neural network, and run.

{
	"experimentName": "XOR Test",
	"verbose": true,
	"numInputs": 3,
	"numOutputs": 1,
	"fullyConnected": false,
	"numGenerations": 50,
	"populationSize": 100,
	"initFitness": 9999.0,
	"minimizeFitness": true,
	"survivalRate": 0.5,
	"stagnationLimit": 5,
	"ratePerturb": 0.2,
	"rateAddNode": 0.2,
	"rateAddConn": 0.2,
	"rateMutateChild": 0.5,
	"distanceThreshold": 20.0,
	"coeffUnmatching": 1.0,
	"coeffMatching": 1.0,
	"cppnActivations": [],
}

Now that you have the configuration JSON file is ready as config.json, we can start experiment with NEAT. Below is an example XOR experiment.

package main

import (
	"log"
	"math"

	// Import NEAT package after installing the package through
	// the instruction provided above.
	"github.com/jinyeom/neat"
)

func main() {

	// First, create a new instance of Config from the JSON file created above.
	// If there's a file import error, the program will crash.
	config, err := neat.NewConfigJSON("config.json")
	if err != nil{
		log.Fatal(err)
	}

	// Then, we can define the evaluation function, which is a type of function
	// which takes a neural network, evaluates its performance, and returns some
	// score that indicates its performance. This score is essentially a genome's
	// fitness score. With the configuration and the evaluation function we
	// defined, we can create a new instance of NEAT and start the evolution 
	// process.
	neat.New(config, neat.XORTest()).Run()
}

License

This package is under GNU General Public License.

Issues
  • Inifinite recursion

    Inifinite recursion

    https://github.com/jinyeom/neat/blob/7aa4ca49072822816508b2aa18ddf04b33b7e1ae/genome.go#L297

    If the function always returns false, it is infinitely called, leading to a runtime: goroutine stack exceeds 1000000000-byte limit error and a stack overflow

    opened by shingtaklam1324 2
  • Fix multiple bugs and make it compilable - tests passed

    Fix multiple bugs and make it compilable - tests passed

    Hello ! First of all, thanks for this amazing library.

    I'm trying to get into machine learning, and I saw on youtube a guy that used the NEAT algorythm ( I don't know if it's called like that ^^' ), so I'm wanted to create a sort of AI-only pong. Your library seemt the most complete, but I wasn't able to go get-it.

    I'm a complete noob when it comes to machine learning, and I'm still learning golang, but today, I'm glad I think I've fixed the many bugs that made this library not compilable and made the test to not pass.

    I don't know if I removed some usefull changes ( did I just reverted the library to an old state ? I don't really know ). I've put some // +build ignore to completely ignore files, so I don't know.

    There are comments explaining changes. If they're not clear, just tell me, and I'll explain what was the problem.

    Also, tell me if you want me to remove these ugly github/@jesuiscamille: comments :) !

    Have a good day !

    PS: I don't know what the normal go test results should be. I'll do a simple XOR manual test, and write here if nothing got wrong 😄

    opened by clouedoc 0
  • Run data through trained network

    Run data through trained network

    Hi! First i wanted to thank you for the effort you put into this project. I'm having issues evaluating even the example you posted (XOR). So i trained the network until the avg Fitness was around 1.5 and the best Fitness = 0 (which should solve all possible xor cases). But when i create a Network using the best genome and run some data through it, it doesn't seem to work. Am i doing something wrong or is there some kind of a bug regarding retrieving the best individual? Here's the code i use for the test:

    package main
    
    import (
    	neat "github.com/jinyeom/neat"
    	"log"
    	"math"
    
    )
    
    func main(){
    	// First, create a new instance of Config from the JSON file created above.
    	// If there's a file import error, the program will crash.
    	config, err := neat.NewConfigJSON("config.json")
    	if err != nil{
    		log.Fatal(err)
    	}
    	
    	neatInst := neat.New(config, neat.XORTest())
    	neatInst.Run()
    	log.Printf("Fitness: %f\n", neatInst.Best.Fitness)
    	nn := neat.NewNeuralNetwork(neatInst.Best)
    	
    	inputs := make([]float64, 3)
    	inputs[0] = 1.0 // bias	
    	b := []bool{true,false}
    	for i := 0; i < len(b); i++{
    		for j := 0; j < len(b); j++{
    			a := b[i]
    			b := b[j]
    			if a{inputs[1] = 1.0}else{inputs[1] = 0.0}
    			if b{inputs[2] = 1.0}else{inputs[2] = 0.0}
    			output, _ := nn.FeedForward(inputs)
    			log.Printf("%t, %t = %f\n",a,b,output[0])
    		}
    	}
    }
    

    The output of this is in most cases:

    2017/07/01 03:09:31 Fitness: 0.000000 2017/07/01 03:09:31 true, true = 0.000000 2017/07/01 03:09:31 true, false = 0.000000 2017/07/01 03:09:31 false, true = 0.000000 2017/07/01 03:09:31 false, false = 0.000000

    But sometimes it also goes for all of it: 2017/07/01 03:22:18 Fitness: 0.000000 2017/07/01 03:22:18 true, true = 1.000000 2017/07/01 03:22:18 true, false = 1.000000 2017/07/01 03:22:18 false, true = 1.000000 2017/07/01 03:22:18 false, false = 1.000000

    I'd appreciate your feedback on this issue. Chances are i'm simply too dumb/tired to use it :)

    opened by azaryc2s 11
  • Loading and saving

    Loading and saving

    Is there a way to save and load prior trained models?

    Forgive my ignorance as I am new but would it be as simple as serializing/deserializing the neat instance?

    opened by kevinhead 3
Owner
Jin Yeom
Applied ML Engineer @hudl
Jin Yeom
A neat wrapper around the 4chan API for content scraping.

moonarch A neat wrapper around the 4chan API for content scraping. How-To First, get the repository: go get github.com/lazdotdigital/fourscrape. fours

Laz 0 Nov 27, 2021
Enable dynamic and seamless Kubernetes multi-cluster topologies

Enable dynamic and seamless Kubernetes multi-cluster topologies Explore the docs » View Demo · Report Bug · Request Feature About the project Liqo is

LiqoTech 642 Jun 29, 2022
Topology-tester - Application to easily test microservice topologies and distributed tracing including K8s and Istio

Topology Tester The Topology Tester app allows you to quickly build a dynamic mi

Bas van Beek 1 Jan 14, 2022
A CLI tool implemented by Golang to manage `CloudComb` resource

CloudComb CLI tool: comb Get Started comb is a CLI tool for manage resources in CloudComb base on cloudcomb-go-sdk. Support Mac, Linux and Windows. We

Bingo Huang 22 Jan 4, 2021
Adaptive Radix Trees implemented in Go

An Adaptive Radix Tree Implementation in Go This library provides a Go implementation of the Adaptive Radix Tree (ART). Features: Lookup performance s

Pavel Larkin 233 May 23, 2022
High-performance minimalist queue implemented using a stripped-down lock-free ringbuffer, written in Go (golang.org)

This project is no longer maintained - feel free to fork the project! gringo A high-performance minimalist queue implemented using a stripped-down loc

Darren Elwood 126 Jun 8, 2022
A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.

go-mysql-server is a SQL engine which parses standard SQL (based on MySQL syntax) and executes queries on data sources of your choice. A simple in-memory database and table implementation are provided, and you can query any data source you want by implementing a few interfaces.

DoltHub 816 Jun 26, 2022
BGP implemented in the Go Programming Language

GoBGP: BGP implementation in Go GoBGP is an open source BGP implementation designed from scratch for modern environment and implemented in a modern pr

null 2.9k Jun 28, 2022
A persistent queue implemented in Go.

goq goq is a persistent queue implemented in Go. Features Communication over HTTP RESTful with JSON responses (trivial to write client libraries) Mini

Kunal Anand 29 Feb 10, 2022
URI Templates (RFC 6570) implemented in Go

uritemplates -- import "github.com/jtacoma/uritemplates" Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf

Joshua Tacoma 71 Jan 15, 2022
A multilayer perceptron network implemented in Go, with training via backpropagation.

Neural Go I'm in the process of making significant changes to this package, particularly, to make it more modular, and to base it around an actual lin

Schuyler Erle 63 Mar 5, 2022
GNU GSL Statistics library (v1.15, GPLv3) implemented in Go

Statistics Pure Go implementation of the GSL Statistics library. For the API overview see Godoc. Why create this repository when there is also "github

grd 77 Nov 23, 2021
FreeDesktop.org (xdg) Specs implemented in Go

xdg Package xdg provides access to the FreeDesktop.org (XDG) specs. Documentation Documentation is available via godoc. Here are direct links to the d

Ryan Koesters 28 May 4, 2022
Firebase Cloud Messaging for application servers implemented using the Go programming language.

Firebase Cloud Notifications Client Firebase Cloud Messaging for application servers implemented using the Go programming language. It's designed for

Mad Devs 47 Jun 16, 2022
Google Cloud Messaging for application servers implemented using the Go programming language.

gcm The Android SDK provides a nice convenience library (com.google.android.gcm.server) that greatly simplifies the interaction between Java-based app

Adriano Orioli 30 Nov 16, 2021
A collection of well-known string hash functions, implemented in Go

This library is a collection of "well-known" 32-bit string hashes, implemented in Go. It includes: Java string hash ELF-32 Jenkins' One-A

Damian Gryski 64 Mar 3, 2022
Germanium is an alternative to Carbon and Silicon implemented in Go.

Germanium is an alternative to Carbon and Silicon implemented in Go. Germanium can work without browser and internet like Silicon.

Masaya Watanabe 180 May 22, 2022
This project is a collection of many of the basic tools used on Unix-like operating systems implemented in Go as a learning exercize.

GoUnix This project is a collection of many of the basic tools used on Unix-like operating systems implemented in Go as a learning exercize. The idea

Tom Hanson 66 Jun 6, 2022
character-set conversion library implemented in Go

mahonia character-set conversion library implemented in Go. Mahonia is a character-set conversion library implemented in Go. All data is compiled into

axgle 765 Jun 19, 2022
SQL Parser implemented in Go

sqlparser Go package for parsing MySQL SQL queries. Notice The backbone of this repo is extracted from vitessio/vitess. Inside vitessio/vitess there i

Wenbin Xiao 1.1k Jun 22, 2022
Powerful workflow engine and end-to-end pipeline solutions implemented with native Kubernetes resources. https://cyclone.dev

Cyclone Cyclone is a powerful workflow engine and end-to-end pipeline solution implemented with native Kubernetes resources, with no extra dependencie

Caicloud 1k Jun 13, 2022
CHANGELOG generator implemented in Go (Golang).

git-chglog CHANGELOG generator implemented in Go (Golang). Anytime, anywhere, Write your CHANGELOG. Table of Contents git-chglog Table of Contents Fea

git chglog 2.1k Jun 24, 2022
Starlark in Go: the Starlark configuration language, implemented in Go

Starlark in Go This is the home of the Starlark in Go project. Starlark in Go is an interpreter for Starlark, implemented in Go. Starlark was formerly

Google 1.6k Jun 30, 2022
Snake game implemented in golang

little_pineapple(Snake game implemented in golang) 贪吃蛇golang实现 Snake game implemented in golang 数据结构:链表&数组 Data structures used: linked list&array 使用方

null 7 Aug 18, 2020
communicate with iOS devices implemented with Golang

Golang-iDevice much more easy to use ?? electricbubble/gidevice-cli Installation go get github.com/electricbubble/gidevice Devices package main impor

雷系泡泡 184 Jun 23, 2022
Kafka implemented in Golang with built-in coordination (No ZooKeeper, single binary install, Cloud Native)

Jocko Distributed commit log service in Go that is wire compatible with Kafka. Created by @travisjeffery, continued by nash. Goals: Protocol compatibl

Nash.io 104 Aug 9, 2021
A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.

go-mysql-server go-mysql-server is a SQL engine which parses standard SQL (based on MySQL syntax) and executes queries on data sources of your choice.

DoltHub 817 Jun 28, 2022
fim is a collection of some popular frequent itemset mining algorithms implemented in Go.

fim fim is a collection of some popular frequent itemset mining algorithms implemented in Go. fim contains the implementations of the following algori

Paul Fedorow 8 Jun 15, 2022