Skip to content

neat 1.0.0

Choose a tag to compare

@HyperCodec HyperCodec released this 23 Feb 21:26
· 8 commits to main since this release
9850a6a

This update involves several rewrites of the virtually the entire crate's internal logic. Here's a list of some (but not all) of the things changed:

  • NeuralNetworkTopology and NeuralNetwork merged into a single type
  • Lockless atomic cache system for prediction. This fixes a major bug with the old version and greatly increases performance.
  • New genetic-rs version allows for custom context in reproduction traits, which is used for additional mutation settings and such.
  • serde feature overhaul, it is now much simpler and completely contained within the NeuralNetwork and ActivationRegistry APIs.
  • Added tons of unit tests, which helped me go step-by-step and avoid having to deal with all the extremely complicated and annoying bugs all at once.
  • crossover and rayon features are now part of the default crate.

Migration Guide

I'm not going to go over the stuff related to the new genetic-rs version, you can see that stuff here. All you really need to know for that migration is that the new NeuralNetwork requires MutationSettings as context for MutateRandomly and ReproductionSettings as context for Mitosis and Crossover.

With that out of the way, all that really changes within fitness testing is using NeuralNetwork directly instead of the topology type:

struct MyAgent {
-   topology: NeuralNetworkTopology<A, B>,
+   brain: NeuralNetwork<A, B>,
}

// you can actually just use `NeuralNetwork` as the entire genome
// now, but we're defining it like this for migration's sake.
fn fitness(agent: &MyAgent) -> f32 {
-   let mut net = NeuralNetwork::from(&agent.topology);
    // ... later in the function
-   let output = net.predict(some_input);
+   let output = agent.brain.predict(some_input);
    // ... rest of the function
}

Additionally, NeuralNetwork is also directly serializable with serde (if you have the feature enabled):

- let net: NeuralNetworkTopology<A, B> = ...;
+ let net: NeuralNetwork<A, B> = ...;
- let json = serde_json::to_string(&NNTSerde::from(&net)).unwrap();
+ let json = serde_json::to_string(&net).unwrap();

You may need to make a small change to your Cargo.toml if you used the features:

- neat = { version = "0.5.1", features = ["crossover", "rayon", "serde"] }
+ neat = { version = "1.0.0",  features = ["serde"] }  

And that's all you really need to change for this update.

What's Changed

  • Docfixes by @HyperCodec in #47
  • write more tests by @HyperCodec in #49
  • plotters example by @HyperCodec in #50
  • Fix references to renamed account. by @HyperCodec in #55
  • Add indicatif progress bars for examples and increase generation count. by @HyperCodec in #57
  • Prevent duplicated neuron inputs by @HyperCodec in #62
  • create custom activations example by @HyperCodec in #54
  • fix custom activation example by @HyperCodec in #66
  • fix contributing guide links by @HyperCodec in #77
  • temp branch for merging changes from #80 by @HyperCodec in #84
  • Secondary Rewrite by @HyperCodec in #104
  • Fix predict deadlock and document claim necessity in eval by @Copilot in #107
  • Fix dfs falsely rejecting valid connections in diamond DAG topologies by @Copilot in #108
  • Fix random_activation_in_scope panic and simplify implementation by @Copilot in #109
  • Fix ActivationRegistry scope handling and ActivationFn deserialization panic by @Copilot in #110
  • Fix remove_cycles_dfs missing cycles due to wrong back-edge parent by @Copilot in #111
  • Update 1.0.0 (massive rewrite) by @HyperCodec in #106

New Contributors

  • @Copilot made their first contribution in #107

Full Changelog: v0.5.1...v1.0.0