File Formats

File formats used by SharpNEAT for saving and loading of genomes and populations of genomes



SharpNEAT 4.0 uses a custom file format for storing genome data; this format is designed to strike a balance between compactness and human readability, allowing for easy editing with a text editor.

Form comparison, SharpNEAT 1.x and 2.x employed an XML-based file format, reflecting XML's popularity in the early 2000s. For SharpNEAT 4.x, JSON was considered, given its current widespread use and its position as the successor to XML for self-descriptive data formats in many cases. However, the self-descriptive nature of JSON (and XML) results in lots of repeated property names, and therefore the custom format described below was chosen instead.


Genome File Format

Here is an example of a file SharpNEAT 4.0 genome file:


    # Input and output node counts.
    4 1
    
    # Cyclic/acyclic indicator.
    acyclic
    
    # Connections (source target weight).
    3 4 0.54541057893432454
    1 4 0.15195519160615445
    0 4 -0.0502328519854705
    2 5 0.19291160459252371
    5 4 5.0
    1 5 -0.15965014531430288
    
    # Activation functions (functionId functionCode).
    0 LeakyReLU


The format contains four sections:

The lines beginning with `#` are comments; these are not required, but SharpNEAT will write the comments as shown above to help make the files reasonably self-descriptive.

Input and output node counts

In the above example the file describes a neural net with four inputs and one output. The input nodes/neurons will have node IDs 0-3, and the output node will be assigned ID 4. Arranging nodes and IDs in the order of inputs, outputs, and hidden nodes is a convention used by SharpNEAT (all versions), and was originally chosen as an optimisation, as the input and outputs nodes are fixed and are allocated a contiguous range of nodes ID starting at zero, whereas hidden nodes can be added and deleted as evolution progresses, resulting in a variable number of hidden nodes, and gaps in the node IDs defined for a given neural net.

Cyclic/acyclic indicator

In the above example neural net definition file, the single word acyclic indicates that the file is describing an acyclic neural net. I.e., a network that does not contain any connectivity cycles; as such the nodes can be arranged in layers that can be evaluated one layer at a time in a feedforward manner. When 'acyclic' is specified, SharpNEAT checks for cycles in the connectivity graph upon loading a file and will throw an exception if one is detected. For cyclic network, the word cyclic is used. This must be followed by a single number, indicating how many neural net time-steps are executed per activation of the neural net. E.g.
            cyclic 2
            

Connections

In this section, each line represents a single connection. The first two integer numbers are the IDs of the source and target nodes respectively. The next number is the connection's weight.

Activation functions

Currently this is a single line that describes the activation function to use for all nodes in the neural net. In future SharpNEAT may extended to support specifying the activation function to use at each node. Hence the activation in the above example as an ID assigned of '0'; this 0 must be specified, but serves no purpose at this time.

Population File Format

SharpNEAT 4.x allows for saving of genome populations. The file format used for this is a ZIp file containing one file per genome in the population, where each file is as described above.




Contact: Colin Green
SharpNEAT is a Heliosphan.org project.