| Crates.io | vivalaakam_neuro_neat |
| lib.rs | vivalaakam_neuro_neat |
| version | 0.1.20 |
| created_at | 2024-07-08 04:19:54.905588+00 |
| updated_at | 2025-06-13 04:53:56.449615+00 |
| description | Library for work with neat network |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1295346 |
| size | 79,202 |
A library for working with neuroevolutionary networks using the NEAT (NeuroEvolution of Augmenting Topologies) algorithm.
use vivalaakam_neuro_neat::{Config, Genome, Node, Connection, NeuronType};
let config = Config::default();
let nodes = vec![
Node::new(NeuronType::Input, 0, 0.0, None, Some(1)),
Node::new(NeuronType::Output, 1, 0.0, None, Some(2)),
];
let connections = vec![Connection::new(0, 1, 0.5)];
let genome = Genome::new(nodes, connections).unwrap();
let network = genome.get_network();
let output = network.activate(vec![1.0]);
new(nodes, connections) — Create a genome from nodes and connections.generate_genome(inputs, outputs, hidden, activation, config) — Generate a random genome.mutate(child, config) — Mutate genome (add node, add connection, weights, etc).mutate_add_node(config) — Add a new node via mutation.mutate_add_connection(config) — Add a new connection via mutation.mutate_node_bias(config) — Mutate node bias.mutate_node_activation(config) — Mutate node activation function.mutate_node_enabled(config) — Toggle node enabled/disabled.mutate_connection_weight(config) — Mutate connection weight.mutate_connection_enabled() — Toggle connection enabled/disabled.mutate_crossover(child) — Crossover with another genome.get_network() — Build a Network from the genome.get_nodes() / get_connections() — Get all nodes/connections.get_distance(child) — Levenshtein distance between hidden nodes.as_json() — Serialize genome to JSON.to_weights() / from_weights() — Convert genome to/from flat weights.new(neuron_type, id, bias, activation, position) — Create a node.get_id() / get_type() / get_bias() / get_activation() / get_enabled() — Accessors.set_bias(bias) / set_activation(activation) / toggle_enabled() — Mutators.get_position() / set_position(position) — Node position in network.to_weights() / from_weights() — Convert node to/from weights.new(from, to, weight) — Create a connection.get_from() / get_to() / get_weight() / get_enabled() — Accessors.set_weight(weight) / set_enabled(enabled) / toggle_enabled() — Mutators.get_id() — Unique string id for the connection.to_weights() / from_weights() — Convert connection to/from weights.new(genome) — Create an organism from a genome.activate(inputs) — Run the network on input vector.activate_matrix(matrix) — Run the network on input matrix (batch).set_fitness(f32) / get_fitness() — Set/get fitness value.inc_stagnation() / get_stagnation() — Increase/get stagnation counter.mutate(child, config) — Mutate organism (delegates to genome).get_genotype() — Get genotype (hidden node ids).as_json() — Serialize genome to JSON.set_id(id) / get_id() — Set/get organism id.new(neurons) — Build a network from neurons.activate(inputs) — Run the network on input vector.activate_matrix(matrix) — Run the network on input matrix (batch).new(from_id, to_id, weight) — Create a link.get_from() / get_to() / get_weight() — Accessors.Input, Hidden, Output, Unknown.to_bytes() / from_bytes(byte) — Convert to/from byte.src/config.rs for details and defaults.src/config.rs)Genome::new(nodes, connections) — create a genomeGenome::generate_genome(inputs, outputs, hidden, activation, &config) — generate a random genomegenome.mutate(...) — mutate genomegenome.get_network() — get computational networkgenome.as_json() — serialize to JSONNode::new(NeuronType, id, bias, activation, position)get_id(), get_type(), get_bias(), get_activation(), get_enabled()Connection::new(from, to, weight)get_from(), get_to(), get_weight(), get_enabled()Organism::new(genome)activate(inputs), set_fitness(f32), get_fitness()See tests/genome.rs for usage examples and tests for mutation, crossover, and serialization.
Author: Andrey Makarov viva.la.akam@gmail.com
License: MIT