neat

package
v0.0.0-...-e2110b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: MIT Imports: 10 Imported by: 10

Documentation

Overview

Package neat implements NeuroEvolution of Augmenting Topologies (NEAT) method which can be used to evolve Artificial Neural Networks to perform specific task using genetic algorithms.

Index

Constants

View Source
const Num_trait_params = 8

The number of parameters used in neurons that learn through habituation, sensitization, or Hebbian-type processes

Variables

View Source
var (
	// The current log level of the context
	LogLevel LoggerLevel

	// The logger to output all messages
	DebugLog = func(message string) {
		if LogLevel <= LogLevelDebug {
			loggerDebug.Output(2, message)
		}
	}
	// The logger to output messages with Info and up level
	InfoLog = func(message string) {
		if LogLevel <= LogLevelInfo {
			loggerInfo.Output(2, message)
		}
	}
	// The logger to output messages with Warn and up level
	WarnLog = func(message string) {
		if LogLevel <= LogLevelWarning {
			loggerWarn.Output(2, message)
		}
	}
	// The logger to output messages with Error and up level
	ErrorLog = func(message string) {
		if LogLevel <= LogLevelError {
			loggerError.Output(2, message)
		}
	}
)
View Source
var (
	ErrTraitsParametersCountMismatch = errors.New("traits parameters number mismatch")
)

Functions

This section is empty.

Types

type LoggerLevel

type LoggerLevel byte

LoggerLevel type to specify logger output level

const (
	// The Debug log level
	LogLevelDebug LoggerLevel = iota
	// The Info log level
	LogLevelInfo
	// The Warning log level
	LogLevelWarning
	// The Error log level
	LogLevelError
)

type NeatContext

type NeatContext struct {
	// Probability of mutating a single trait param
	TraitParamMutProb float64
	// Power of mutation on a single trait param
	TraitMutationPower float64
	// The power of a link weight mutation
	WeightMutPower float64

	// These 3 global coefficients are used to determine the formula for
	// computing the compatibility between 2 genomes.  The formula is:
	// disjoint_coeff * pdg + excess_coeff * peg + mutdiff_coeff * mdmg.
	// See the compatibility method in the Genome class for more info
	// They can be thought of as the importance of disjoint Genes,
	// excess Genes, and parametric difference between Genes of the
	// same function, respectively.
	DisjointCoeff float64
	ExcessCoeff   float64
	MutdiffCoeff  float64

	// This global tells compatibility threshold under which
	// two Genomes are considered the same species
	CompatThreshold float64

	// How much does age matter? Gives a fitness boost up to some young age (niching).
	// If it is 1, then young species get no fitness boost.
	AgeSignificance float64
	// Percent of average fitness for survival, how many get to reproduce based on survival_thresh * pop_size
	SurvivalThresh float64

	// Probabilities of a non-mating reproduction
	MutateOnlyProb         float64
	MutateRandomTraitProb  float64
	MutateLinkTraitProb    float64
	MutateNodeTraitProb    float64
	MutateLinkWeightsProb  float64
	MutateToggleEnableProb float64
	MutateGeneReenableProb float64
	MutateAddNodeProb      float64
	MutateAddLinkProb      float64
	MutateConnectSensors   float64 // probability of mutation involving disconnected inputs connection

	// Probabilities of a mate being outside species
	InterspeciesMateRate  float64
	MateMultipointProb    float64
	MateMultipointAvgProb float64
	MateSinglepointProb   float64

	// Prob. of mating without mutation
	MateOnlyProb float64
	// Probability of forcing selection of ONLY links that are naturally recurrent
	RecurOnlyProb float64

	// Size of population
	PopSize int
	// Age when Species starts to be penalized
	DropOffAge int
	// Number of tries mutate_add_link will attempt to find an open link
	NewLinkTries int

	// Tells to print population to file every n generations
	PrintEvery int

	// The number of babies to stolen off to the champions
	BabiesStolen int

	// The number of runs to average over in an experiment
	NumRuns int

	// The number of epochs (generations) to execute training
	NumGenerations int
	// The epoch's executor type to apply
	EpochExecutorType int
	// The genome compatibility testing method to use (0 - linear, 1 - fast (make sense for large genomes))
	GenCompatMethod int

	// The neuron nodes activation functions list to choose from
	NodeActivators []utils.NodeActivationType
	// The probabilities of selection of the specific node activator function
	NodeActivatorsProb []float64
}

The NEAT execution context holding common configuration parameters, etc.

func LoadContext

func LoadContext(r io.Reader) *NeatContext

Loads context configuration from provided reader

func NewNeatContext

func NewNeatContext() *NeatContext

Creates new empty NEAT context

func (*NeatContext) LoadContext

func (c *NeatContext) LoadContext(r io.Reader) error

Loads context configuration from provided reader as YAML

func (*NeatContext) RandomNodeActivationType

func (c *NeatContext) RandomNodeActivationType() (utils.NodeActivationType, error)

Returns next random node activation type among registered with this context

type Trait

type Trait struct {
	// The trait ID
	Id int
	// The learned trait parameters
	Params []float64
}

TRAIT: A Trait is a group of parameters that can be expressed as a group more than one time. Traits save a genetic algorithm from having to search vast parameter landscapes on every node. Instead, each node can simply point to a trait and those traits can evolve on their own.

func NewTrait

func NewTrait() *Trait

func NewTraitAvrg

func NewTraitAvrg(t1, t2 *Trait) (*Trait, error)

Special Constructor creates a new Trait which is the average of two existing traits passed in

func NewTraitCopy

func NewTraitCopy(t *Trait) *Trait

The copy constructor

func (*Trait) Mutate

func (t *Trait) Mutate(trait_mutation_power, trait_param_mut_prob float64)

Perturb the trait parameters slightly

func (*Trait) String

func (t *Trait) String() string

Directories

Path Synopsis
Package genetics holds data holders and helper utilities used to implement genetic evolution algorithm
Package genetics holds data holders and helper utilities used to implement genetic evolution algorithm
The package network provides data holders and utilities to describe Artificial Neural Network
The package network provides data holders and utilities to describe Artificial Neural Network
Holds collection of utils commonly used across various packages
Holds collection of utils commonly used across various packages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL