Genome<T>
Models & Types · AiDotNet.NeuralNetworks
Represents a genome in a neuroevolutionary algorithm, containing a collection of connections between nodes.
For Beginners
A Genome is like a blueprint for a neural network.
Think of a Genome as:
- A DNA-like structure that defines how a neural network is built
- A collection of connections (wires) between nodes (neurons)
- Each connection has a weight (strength) and can be enabled or disabled
- Instead of training this network with examples, it evolves through generations
Just as biological organisms evolve through natural selection, these neural network blueprints can evolve to solve problems through a process of selection, mutation, and reproduction. The best-performing blueprints are selected to create the next generation.
How It Works
A Genome is a fundamental data structure in neuroevolutionary algorithms like NEAT (NeuroEvolution of Augmenting Topologies). It encodes the structure and weights of a neural network as a set of connections between nodes. Each connection has a weight, an enabled/disabled state, and an innovation number that tracks its evolutionary history. Genomes can be mutated, crossed over, and evaluated for fitness, allowing neural networks to evolve over generations rather than being trained through traditional gradient-based methods.
Constructors
| Constructor | Summary |
|---|---|
Genome(int inputSize, int outputSize) |
Initializes a new instance of the Genome class with the specified network dimensions. |
Properties
| Property | Summary |
|---|---|
List<Connection<T>> Connections { get; set; } |
Gets the list of connections that make up this genome. |
T Fitness { get; set; } |
Gets or sets the fitness score of this genome. |
int InputSize { get; set; } |
Gets the number of input nodes in the neural network. |
int OutputSize { get; set; } |
Gets the number of output nodes in the neural network. |
Methods
| Method | Summary |
|---|---|
Genome<T> Clone() |
Creates a deep copy of this genome. |
Vector<T> Activate(Vector<T> input) |
Activates the neural network encoded by this genome with the given input vector. |
void AddConnection(int fromNode, int toNode, T weight, bool isEnabled, int innovation) |
Adds a new connection to this genome. |
void Deserialize(BinaryReader reader) |
Deserializes this genome from a binary stream. |
void DisableConnection(int innovation) |
Disables a connection with the specified innovation number. |
void Serialize(BinaryWriter writer) |
Serializes this genome to a binary stream. |