| Crates.io | neurodna |
| lib.rs | neurodna |
| version | 0.0.2 |
| created_at | 2025-07-12 04:37:52.983448+00 |
| updated_at | 2025-07-12 05:21:13.933049+00 |
| description | High-performance evolutionary neural networks with genetic encoding, SIMD optimizations, and neurodivergent cognitive modeling |
| homepage | |
| repository | https://github.com/ruvnet/ruv-FANN |
| max_upload_size | |
| id | 1748968 |
| size | 684,456 |
A Rust library for evolutionary neural network development using genetic-inspired encoding, mutation, and neurodivergent cognitive patterns.
Add to your Cargo.toml:
[dependencies]
neural-dna = "0.1.0"
use neurodna::*;
// Create a neural DNA instance
let dna = NeuralDNA::random(vec![4, 8, 4, 2], "sigmoid");
// Apply mutations
let mut evolved_dna = dna.clone();
let policy = MutationPolicy::default();
mutate(&mut evolved_dna, &policy, &MutationType::All);
// Evaluate fitness
let scorer = StandardFitnessScorer::new();
let fitness = scorer.evaluate(&evolved_dna);
println!("Fitness: {:.4}", fitness.overall);
// Run evolution
let config = EvolutionConfig::default();
let mut engine = EvolutionEngine::new(config, vec![4, 8, 2], "tanh");
let inputs = vec![vec![0.0, 1.0], vec![1.0, 0.0]];
let targets = vec![vec![1.0], vec![0.0]];
for generation in 0..100 {
engine.evolve_generation(&scorer, &inputs, &targets);
if let Some(stats) = engine.get_statistics() {
println!("Gen {}: Best={:.4}", generation, stats.best_fitness);
}
}
Model cognitive diversity with built-in trait profiles:
use neurodna::*;
// ADHD-inspired traits
let adhd_profile = TraitProfile::adhd_profile();
let hyperfocus_trait = adhd_profile.get_trait("hyperfocus").unwrap();
println!("Hyperfocus strength: {:.2}", hyperfocus_trait.strength);
// Autism spectrum traits
let autism_profile = TraitProfile::autism_profile();
let pattern_trait = autism_profile.get_trait("pattern_recognition").unwrap();
println!("Pattern recognition: {:.2}", pattern_trait.strength);
Train neural networks using evolutionary algorithms:
# Train with 4-8-4-2 topology for 100 generations
cargo run --bin dna-train 4,8,4,2 sigmoid 100
Generate offspring from parent DNA:
# Create 5 mutated offspring from best_dna.json
cargo run --bin dna-spawn best_dna.json 5
Evaluate and analyze DNA fitness:
# Score a DNA file with detailed analysis
cargo run --bin dna-score organism.json
dna.rs: DNA encoding/decoding and validationmutation.rs: Mutation strategies and crossover operationsfitness.rs: Fitness evaluation frameworktraits.rs: Neurodivergent cognitive patternsevolution.rs: Population-based evolution enginepub struct NeuralDNA {
pub weights: Vec<f32>, // Connection weights
pub biases: Vec<f32>, // Neuron biases
pub topology: Vec<usize>, // Layer sizes
pub activation: String, // Activation function
pub generation: u32, // Evolution generation
pub mutation_rate: f32, // Mutation probability
pub fitness_scores: Vec<f32>, // Historical fitness
}
plotting: Visualization capabilities using plotterswasm: WebAssembly support for browser deploymentbenchmarks: Performance benchmarking suiteEnable features in Cargo.toml:
[dependencies]
neural-dna = { version = "0.1.0", features = ["wasm", "benchmarks"] }
Deploy to web environments:
# Build for WebAssembly
wasm-pack build --target web --features wasm
# Use in JavaScript
import init, { WasmNeuralDNA, WasmEvolutionEngine } from './pkg/neural_dna.js';
await init();
const dna = WasmNeuralDNA.random([4, 8, 2], "sigmoid");
const engine = new WasmEvolutionEngine(50, 5, [4, 8, 2], "sigmoid");
Neural DNA is optimized for:
Benchmarks show:
Neural DNA integrates seamlessly with the ruv-FANN ecosystem:
// Convert DNA to FANN network (when available)
// let fann_network = dna.to_fann_network()?;
Supports Model Context Protocol for coordination:
// Use with ruv-swarm for distributed evolution
// let swarm = Swarm::new().with_dna_evolution(config);
Check the examples/ directory for:
Run the complete test suite:
# All tests
cargo test
# With features
cargo test --all-features
# Benchmarks (requires features = ["benchmarks"])
cargo bench
Generate and view documentation:
cargo doc --open --all-features
Licensed under the MIT License. See LICENSE for details.
If you use Neural DNA in academic work, please cite:
@software{neural_dna_2024,
title={Neural DNA: Evolutionary Neural Networks with Neurodivergent Traits},
author={ruv-FANN Contributors},
year={2024},
url={https://github.com/ruvnet/ruv-FANN}
}
🧬 Evolve your neural networks with genetic diversity!