Neural Network Genome Help Please :'(

Started by
12 comments, last by CryoGenesis 12 years, 1 month ago

So my problem is Number 5.


Okay tell me if I'm wrong but your problem is that you want to take two parent networks, and combine them to form a child network as some sort of simulation of sexual reproduction? How you do this depends entirely on what kind of neural network you're using.

If you're using a fixed topology (meaning the graph-structure), that never changes and thus every one of the creatures neural networks is the same then it's super easy to get the child's neural network (or geneome). All you have to do is run through the child's genome and select genes for it's father or mother randomly to fill the same location the gene would have filled in the parent, like

Father: A, B, C, D
Mother: 1, 2, 3, 4
Child: A, 2, 3, D or 1, B, C,4 or any random configuration.

If the topology of the neural network evolves along with the weights of the network then things are a little more difficult. You would need to use what is called the NEAT algorithm, it's a little tedious to read up but if you just google it you should find pdf documents explaining it. I would suggest just sticking with fixed topologies. I don't know Java so I can't actually help you out with code, but I could explain algorithms maybe in more detail.
Advertisement
Artificial life simulators often use two mechanisms called "crossover" and "mutation" when combining genomes, which are simplifications of the biological processess similarly named.

Crossover is simply splitting the genome (or gene, or chromosome) of each parent at a random position, and combining them together to form a new one. An example of a simple crossover:

Parent 1: ABAB|BBAA
Parent 2: AAAB|BBBA
where the "|" is a randomly determined position, could produce 2 children:

child 1: ABABBBBA
child 2: AAABBBAA

Mutation, which usually has only a small chance of occuring, is just a single random change (for example, flipping an A to a B somehwere in the genome).

The point of crossover is to keep successful genes in the population, while mutation would supposedly create entirely new genes.

I'm no expert on NN, but I would guess one of the challenges would be how to implement the crossover function properly. This would probably depend on whether your goal is training (in which case this is probably a bad method for that) or alife simulation. Assuming the latter, I would personally start here: http://en.wikipedia....able_simulators and see how other NN based simulators are doing it. Framsticks in particular, IIRC, has pretty thorough documentation.
Cryo,

There are a number of problems that you're going to run into along the way using this approach. I think that other posts have addressed most of the issues quite well, but I want to add a few details.

First, refer to Dagz's post regarding the topology of the networks. If the network structure does not change, then it should be quite easy to recombine two networks to get a child network. If you are also trying to evolve the network structure - number of nodes, specific connections, and weights - follow Dagz's advice to look at NEAT here: http://www.cs.ucf.edu/~kstanley/ He has a number of very good publications that describe NEAT itself, applications of NEAT, and extensions. The reading is somewhat technical, though.

Assuming that your network structure is not changing, crossover is only part of the story. If you only use crossover to recombine your networks, you will only be shuffling the existing weights around from place to place. You will want some sort of additional mechanism to apply changes to those weights. You could do crossover to generate your child network and then run backpropagation to optimize it, keeping the resulting weights for future generations. You could apply a mutation operator that modifies a very few weights slightly. You could specify a crossover operator that does this weight modification for you - maybe averaging some of the parent weights instead of copying them directly. There are many, many different ways to approach this, and you'll need to do a lot of experimenting to get the one that works for you.

Speaking of cross over, there are lots of different ways to do this. The one mentioned by laztrezort is the most common method, but in practice it does perform very well. A better option is 2-point crossover where you specify to random positions within each the genome, and swap the middles. Note that the sizes must be the same. Something like this:

ABAB | ABABA | BABAB
CDCD | CDCDC | DCDCD

gives ABAB | CDCDC | BABAB
and CDCD | ABABA | DCDCD

Another commonly used crossover operator is one that randomly swaps single elements between genes. You might get something like this using the first two genomes I mentioned above:

ABCBCDABABADAB
CDADABCDCDCBAB

And there are dozens of other ways to do this.

Finally, the behavior you're shooting for - entities that learn to seek food - will require a fairly long time to evolve. You'll need to be very patient and it may come down to just the right crossover and mutation operators run for an adequately long time.

Feel free to ask questions if you have them.

-Kirk
Thanks for all the replies guys, Really helped. I'm going to have to rewrite the code so I'll get back to you if I run into any more problems.
I'll be sure to give you guys +1 rep :)

This topic is closed to new replies.

Advertisement