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.

You might also like...
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

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

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

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

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

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

Germanium is an alternative to Carbon and Silicon implemented in Go.
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.

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

Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy是golang实现的高性能http,https,websocket,tcp,socks5代理服务器,支持内网穿透,链式代理,通讯加密,智能HTTP,SOCKS5代理,黑白名单,限速,限流量,限连接数,跨平台,KCP支持,认证API。
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

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

Powerful workflow engine and end-to-end pipeline solutions implemented with native Kubernetes resources. https://cyclone.dev
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

CHANGELOG generator implemented in Go (Golang).
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

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

Snake game implemented in golang

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

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

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

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.

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

Comments
  • 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 755 Dec 30, 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 252 Dec 30, 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 129 Oct 24, 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 947 Dec 27, 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 3.1k Dec 31, 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