yaricom / goNEAT

The GOLang implementation of NeuroEvolution of Augmented Topologies (NEAT) method to evolve and train Artificial Neural Networks without error back propagation
MIT License
75 stars 19 forks source link

Remove nodes and links during mutations #51

Closed chrispytoes closed 2 years ago

chrispytoes commented 2 years ago

I have a larger network with 18 inputs and 3 outputs, and I'm having trouble understanding how hidden nodes, biases, and genes get removed during the process. It seems like no matter what parameters I set for my context, my organisms eventually just expand infinitely with more and more nodes and links, getting slower and slower without making any real fitness improvements.

Digging around in the source code myself, I'm only seeing methods for adding links and nodes but not removing them. Now correct me if I'm wrong but shouldn't it be possible for nodes and links to get deleted during mutation to get rid of unneeded connections?

yaricom commented 2 years ago

Hi @chrispytoes! I'm happy to learn that you are using my library in some project.

Implemented algorithm assumes gradual complexification of the genome. Thus, it is mostly about adding something :) Anyway, there are several ways to manage complexity of the evolved genomes:

Also, it is worth mentioning that depending on your task you can get better results with Novelty Search optimization algorithm implemented here: https://github.com/yaricom/goNEAT_NS

Hope my answer was helpful.

Cheers, Iaroslav

chrispytoes commented 2 years ago

@yaricom Thanks for the answer! I actually closed this because I thought I had fixed it, but after some more testing I don't believe I have. My network peaks out in fitness within about 300 - 500 generations, and just keeps getting more and more complex without getting any better. Then if I restart it from scratch it's able to get back up to the same fitness level again rather quickly without the extra complexity. I know it should be possible to get it higher, because I can make my own guesses and get a better score myself.

I've messed around with a lot of those settings, and it seems all I've been able to do was delay how long it takes for the performance to peak out. I'm going to try out the Novelty Search library you suggested, seems like it might be what I need.

I do have one other question that's been on my mind too. Is it possible/necessary to resume an experiment with a previous population genome dump? I was only able to figure out how to save and reload a single genome, so I'm just saving the best genome to a file and reloading that as the genesis organism to resume training. Does doing this taint the training process in any way? In general, what is the suggested method for saving and resuming long running/infinite experiments? In my particular case I have no "target" fitness to reach, I'm just trying to get it as high as I can.

yaricom commented 2 years ago

Hi @chrispytoes

Regarding your question about starting new experiment using champion organism found before. I believe there can be some benefits with such method. Something similar was already mentioned in the literature. You can read the following interesting article https://www.researchgate.net/publication/6507612_Training_Recurrent_Networks_by_Evolino

They call it burst mutation.

Also, it is worth playing with seed value of the random number generator. The NE is pseudo-stochastic process which depends on initial condition (seed value). With good seed value you can boost the evolutionary process. It is like in natural evolution - with good initial conditions the evolution goes faster :)