crystal-fann
Version, currently 1.1.04 versions
- 1.2.0latestNov 28, 2021
- 1.1.1not indexedJan 15, 2026
- 1.1.0not indexedJan 15, 2026
- 1.0.0not indexedJan 15, 2026
github.com/NeuraLegion/crystal-fann
FANN (Fast Artifical Neural Network) binding in Crystal
88 stars
0 dependents
License: MIT
Nothing has been indexed for 1.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
crystal-fann:
github: NeuraLegion/crystal-fann
version: ~> 1.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 1.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# crystal-fann
[](https://gitter.im/crystal-fann/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://travis-ci.org/NeuraLegion/crystal-fann)
Crystal bindings for the FANN C lib
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
crystal-fann:
github: NeuraLegion/crystal-fann
```
## Usage
Look at the spec for most functions
```crystal
ann = Fann::Network::Standard.new(2, [2], 1)
ann.randomize_weights(0.0, 1.0)
3000.times do
ann.train_single([1.0, 0.0], [0.5])
end
result = ann.run([1.0, 0.0])
# Remember to close the network when done to free allocated C memory
ann.close
(result < [0.55] && result > [0.45]).should be_true
```
```crystal
# Work on array of test data (batch)
ann = Fann::Network::Standard.new(2, [3], 1)
input = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]
output = [[0.0], [1.0], [1.0], [0.0]]
train_data = Fann::TrainData.new(input, output)
data = train_data.train_data
ann.randomize_weights(0.0, 1.0)
if data
ann.train_batch(data, {:max_runs => 8000, :desired_mse => 0.001, :log_each => 1000})
end
result = ann.run([1.0, 1.0])
ann.close
(result < [0.15]).should be_true
```
```crystal
# Work on array of test data using the Cascade2 algorithm (no hidden layers, net will build it alone)
ann = Fann::Network::Cascade.new(2, 1)
input = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]
output = [[0.0], [1.0], [1.0], [0.0]]
train_data = Fann::TrainData.new(input, output)
data = train_data.train_data
ann.train_algorithm(LibFANN::TrainEnum::TrainRprop)
ann.randomize_weights(0.0, 1.0)
if data
ann.train_batch(data, {:max_neurons => 500, :desired_mse => 0.001, :log_each => 10})
end
result = ann.run([1.0, 1.0])
ann.close
(result < [0.1]).should be_true
```
## Development
All C lib docs can be found here -> http://libfann.github.io/fann/docs/files/fann-h.html
- [x] Add TrainData class
- [x] Add network call method to train on train data
- [x] Add binding to the 'Parallel' binding to work on multi CPU at same time
- [ ] Clean unneeded bindings in the LibFANN binding
- [ ] Add specific Exceptions
- [ ] Add binding and checks for lib errors
I guess more stuff will be added once more people will use it.
## Contributing
1. Fork it ( https://github.com/NeuraLegion/crystal-fann/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [bararchy](https://github.com/bararchy) - creator, maintainer
- [libfann](https://github.com/libfann/fann) - c lib creators
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.1.0- Tagged
- Jan 15, 2026
- Commit
b6b337e0ae1b- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/NeuraLegion/crystal-fann
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 4