davidrmiller / biosim4

Biological evolution simulator
Other
3.21k stars 460 forks source link

Question about handling repeated neuron connections after decoding genome #98

Closed GabrielAttano closed 10 months ago

GabrielAttano commented 10 months ago

Hello!

I have a question about the way you handle the cases where a specific connection is repeated in the genome (Not the weight, but the neurons associated).

Do you take into account only the first time the connection appears in the genome, and use it as the weight? Or each time you find a connection that already existed, it overwrites the weight of the old connection?

What i mean by repeated neuron connection is after decoding two different genes of the same individual, both of them have the same source, sink, and (probably) a different weight.

=============== I know this question can be answered by searching through your code, but i'm trying to recreate and expand the idea you showed in your video without looking at the source... Mostly so i don't end up directly copying anything. I hope i'm not being entitled or anything.

Other than that, thank you for the amazing content you've created, it sparked a new-found love for neural networks, and i'm enjoying every second of it!

davidrmiller commented 10 months ago

Hi @GabrielAttano, that's a good question. I don't recall implementing any special handling for that case. At the beginning of each generation, for each individual, a function converts its list of genes into a list of connections for that individual. The list is roughly organized into inputs first, internal connections next, then output connections last. Then in each simulator step, the connections for each individual are processed in the order they appear in that list. If it happens that the same two neurons are connected multiple times, that's ok -- each connection gets computed individually with its own weight. They might reinforce or cancel out each other. It's like in natural genomes where multiple genes can reinforce or cancel each other in producing polypeptides and proteins.

GabrielAttano commented 10 months ago

That makes sense! Thanks a lot.