neuratron
Version, currently master branch1 version
- master branchlatestFeb 27, 2020
github.com/alex-lairan/neuratron
Machine learning framework
Installation
# Add this to your shard.yml
dependencies:
neuratron:
github: alex-lairan/neuratron
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.33.0- License
- MIT
- Author
- Alexandre Lairan
- Target
neuratronfrom src/neuratron.cr
Dependencies
Runtime Dependencies
- linalg*github: konovod/linalg, commit: a897b9ba81d3b2e9f026ae72eeeabdf3f3aecc34
README
Neuratron
Neuratron is a machine learning framework inspired by the Keras API.
With Neuratron, you can build, fit and use a deep neural network.
Looking for contributors
A project of this scale cannot be done alone. I'm looking to anyone who loves Crystal and Machine learning to provide some implementations.
The more implementation we have, the more this framework and Crystal will be attractive to data scientists.
Installation
Neuratron is a fully crystal implementation. There is no special requirement here.
Usage
For this usage, we will take a full dense neural network that works for MNIST
You first need to create a model.
Currently, only the sequential model works.
model = Neuratron::Models::Sequential.new
Then, you must add some layers to your model
model.add(
Neuratron::Layers::Dense.new(16, input_shape: [784],
initializer: Neuratron::Initializers::Random.new(range: (-1.0..1.0)),
activation: Neuratron::Activations::Tanh.new
)
)
model.add(
Neuratron::Layers::Dense.new(10,
initializer: Neuratron::Initializers::Random.new(range: (-1.0..1.0)),
activation: Neuratron::Activations::Tanh.new
)
)
We use a Tanh activation, so the random initializer range should be (-1.0..1.0).
We have to compile our model to build all weight and biases for our model.
model.compile(
loss: Neuratron::Losses::MAE.new,
optimizer: Neuratron::Optimizers::SGD.new(momentum: 0.80),
metrics: [Neuratron::Metrics::CategoricalAccuracy.new] of Neuratron::Metric
)
We use the sgd optimizer.
All set, let's train our model!
model.fit(
images, # Array(LA::GMat(1, 764))
labels, # Array(LA::GMat(1, 10))
epochs: 10,
batch_size: 2048,
)
After that, our model is ready to predict some numbers
model.predict(images[0])
# => LA::GMat(1, 10)
Development
If you have any knowledge of machine learning, don't hesitate to propose a new feature via issues, or contribute to current issues.
Contributing
- Fork it (https://github.com/alex-lairan/neuratron/fork)
- Create your feature branch (
git checkout -b branch_name) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin branch_name) - Create a new Pull Request
Contributors
- Alexandre Lairan - 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
- Feb 27, 2020
- Crystal
0.33.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/alex-lairan/neuratron
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 1