RustingBrain
RustingBrain is a small neural-network library for learning how inference and training work under the hood.
The crate keeps the core pieces visible: matrices, dense layers, activations, loss functions, optimizers, batches, and model weights. It is not trying to replace PyTorch or TensorFlow. It is for experiments, study, and small models where readable Rust code matters more than having every deep-learning feature.
Features
- Dense feedforward networks
- Regression, binary classification, multiclass classification, and XOR examples
- ReLU, sigmoid, tanh, softmax, and linear activations
- Mean squared error, binary cross entropy, and cross entropy losses
- SGD and Adam optimizers
- Mini-batch training with reproducible shuffling
- JSON save/load for RustingBrain models
- ONNX inference for models trained elsewhere
- Optional CUDA/cuBLAS matrix benchmark
Install
Add the crate from crates.io:
Or clone and run the examples:
Quick Example
use ;
Examples
Save And Load
model.save_json?;
let loaded = load_json?;
The saved JSON contains the network shape, activations, loss, weights, biases, and file format version. Optimizer state is not stored yet, so saved models are mainly for inference and reproducible examples.
Import Models
RustingBrain can run ONNX models for inference:
Some TensorFlow exports leave the input shape dynamic. In that case, pass the shape and input values explicitly:
See IMPORT_MODELS.md for the TensorFlow/Keras to ONNX flow.
CUDA Benchmark
CUDA is optional. The normal crate build does not require CUDA, nvcc, or an
NVIDIA GPU.
To compile the CUDA benchmark support:
To run the benchmark on a CUDA machine:
See INSTALL_CUDA.md for driver, toolkit, and cuBLAS setup.
Scope
The current focus is dense neural networks and inference interop. Convolution layers, transformer experiments, mixed precision, and full GPU training are future work.
License
RustingBrain is released under the RustingBrain License 1.0. You can use, modify, and distribute it, including in commercial projects, but redistributed copies must keep the license and credit Vasyl Trefilov as the original author.
See LICENSE.md for the full terms.