colgreen / sharpneat

SharpNEAT - Evolution of Neural Networks. A C# .NET Framework.
https://sharpneat.sourceforge.io/
Other
388 stars 100 forks source link

SharpNeat.Windows.App: Add missing generic functionality #50

Closed colgreen closed 1 year ago

colgreen commented 3 years ago

Some missing bits are:

Play about with the app to find any other missing bits.

aeonova commented 3 years ago

Hi Colin -

Amazing work. Is there another location in the source with the load pop\genome parsing and syntax? The older version was XML based otherwise I'd just port it. Thanks for all your hard work.

colgreen commented 3 years ago

Hi, thanks for kind comments.

I don't think there are sample files, but it's a good call so I will make a note to add some. For now if you run the windows app, create a random population, and save the best genome, you will get a text file as below. Which I will briefly try to explain.

It's a text file (so not xml or json) with fields within a line being separated by one or more whitespace characters, i.e., a space or a tab - and as few or as many whitespace chars as you like; mixed tabs/spaces are allowed.

Lines starting with a # are comment lines. You can put these anywhere, or leave them out entirely. The standard 'save' code puts comments in to indicate the start of each of the three separate sections...

Section 1: A single line with two integers values, describing the number of input and output nodes respectively.

Section 2: One line per edge (i.e. connection). The format is:

sourceNodeId targetCodeId connectionWeight

Section3: Right now this is a single line that describes the activation function to use for all nodes. The format is:

0 functionIdString

In future, if HyperNEAT and CPPNs are supported, then this section can be expanded to multiple activation functions. There would then need to be a fourth section that describes which activation function to use for each node. But for now there is single row with two fields, and the first field is always a zero.

# Input and output node counts.
12  1

# Connections (source target weight).
0   12  0.24397165761669748
1   12  -0.06417473045305701
2   12  -0.011776672995407703
5   12  0.09247813557627703
6   12  0.11284243050657788
7   12  0.08484827360210143
8   12  0.09108443865607947
10  12  0.07335671181078114
11  12  0.1043046016690127

# Activation functions (functionId functionCode).
0   LeakyReLU

Populations are either a zip file containing multiple files, each with the above format; or simply a folder with multiple genome files. Hope that helps a little.

alkirah commented 2 years ago

I've tried to save and reload the population on a test example.

The zip file is correctly created, same for the load, it creates a List<NeatGenome> with correct number of genomes in it.

Thing is that when I copy the array to the _neatPop.GenomeList, it will crash on subsequent generation while creating childs.

A working example of a population save/load would be great, test file is only comparing it and not reloading it from scratch.

I suspect that the metagenomes or previous genome history is required for the AI to resume properly.