evolvenet
Version, currently master branch1 version
- master branchlatestMay 29, 2022
github.com/drujensen/evolvenet-crystal
simple neural network using evolutionary strategy
Installation
# Add this to your shard.yml
dependencies:
evolvenet:
github: drujensen/evolvenet-crystal
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.2.2- License
- MIT
- Author
- Dru Jensen
Dependencies
Runtime Dependencies
- stumpy_png*github: stumpycr/stumpy_png
README
evolvenet
This project is a testbed to attempt using an evolutionary strategy for machine learning. The examples are fairly simple networks but the solution seems to work quite well and removes all the complexity around back propogation and gradient descent. This also leverages the CPU cores by spawning and distributing the network evaluation. In theory, this could be distributed horizontally on a cluster of servers and use a federated approach.
The network uses a simple evolutionary process:
- create a sample network
- generate a population and randomize the weights and biases
- for several generations:
- evaluate the error rate and sort
- destroy the bottom 25%
- clone the top 25%
- punctuate the top 20%
- keep the best model
- randomize the worst
- mutate the population
- return the top evolved network
Installation
add to your shards.yml
dependencies:
evolvenet:
github: drujensen/evolvenet
Usage
xor example
data = [
[[0, 0], [0]],
[[0, 1], [1]],
[[1, 0], [1]],
[[1, 1], [0]],
]
network = EvolveNet::Network.new
network.add_layer(:input, 2)
network.add_layer(:hidden, 2)
network.add_layer(:output, 1)
network.fully_connect
organism = EvolveNet::Organism.new(network)
network = organism.evolve(data)
puts network.run([0, 0])
See the specs for other examples.
Development
To run specs with threads:
LOG_LEVEL=DEBUG CRYSTAL_WORKERS=16 crystal spec --release -Dpreview_mt
Contributing
- Fork it (https://github.com/drujensen/evolvenet/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Dru Jensen - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- May 29, 2022
- Crystal
1.2.2- Indexed
- yes
Dependents
Repository
github.com/drujensen/evolvenet-crystal
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 1