| Component | Description |
|---|---|
| RAM | Tensor-like in-memory storage for multi-dimensional numerical data. |
| Compute | Highly optimized arithmetic and matrix operations implemented in pure Rust. |
| Machine Learning | Support for neural network training, evaluation, and inference. |
| Rust | Memory-safe, high-performance systems language for deterministic execution. |
| Syntax | Ergonomic API design with method-chaining and operator overloading. |
RCMLRS is a lightweight, low-level machine learning framework written entirely in Rust. It provides the fundamental computational building blocks required to construct and train models such as Recurrent Neural Networks (RNNs), without relying on heavyweight dependencies or external bindings. By implementing core tensor operations, activation functions, optimizers, and normalization methods from scratch, RCMLRS enables full transparency of the machine learning process, critical for both research and systems-level optimization.
The framework is intentionally minimal yet extensible, serving as a testbed for experimenting with neural architectures, optimization algorithms, and memory management in high-performance environments. Unlike Python based ML frameworks, RCMLRS compiles natively to multiple platforms and offers deterministic, low-latency execution.
Machine learning frameworks in Rust remain scarce compared to Python ecosystems such as TensorFlow and PyTorch. Existing Rust options often suffer from:
- Installation complexity Many require fragile bindings to C/C++ libraries, which can fail on macOS or ARM architectures.
- Platform limitations Some frameworks exclude macOS or Windows support altogether.
- Opaque internals High-level abstractions hide critical computational details from developers.
RCMLRS addresses these limitations by:
- Full native Rust implementation (no external bindings).
- Crossplatform support, verified on macOS and Linux.
- Fine grained control over every tensor operation and learning step.
At the core is the RamTensor structure, which stores numerical data in a three dimensional vector (Vec<Vec<Vec<f32>>>). This design supports:
- Multilayer neural networks with arbitrary shapes.
- Constant time indexing for element access.
- Method chaining for concise operations (for example,
tensor1 + tensor2).
Key operations include:
- Matrix multiplication (
matmul) with optional zero padding (pad_matmul_to_another). - Elementwise arithmetic (
add,sub,powi,powf). - Reduction functions (
mean,median,find_min,find_max). - Shape transformations (
flatten,transpose,pad).
All major activation functions are implemented with their derivatives for backpropagation:
| Function | Equation | Derivative | Use Case |
|---|---|---|---|
| ReLU |
|
Sparse activations, avoiding vanishing gradients | |
| Leaky ReLU | Same with slope |
Small gradients for negative inputs | |
| Sigmoid | Binary classification | ||
| Tanh | Normalized outputs in |
||
| Softmax | Jacobian matrix | Multi-class classification | |
| Swish | Complex, smooth gradients | State-of-the-art deep nets | |
| GELU | Differentiable smooth step | Transformer architectures |
RCMLRS currently supports:
-
Adam Optimizer Implements both default and customizable hyperparameters (
$\beta_1, \beta_2, \epsilon$ ). - Loss functions Mean Squared Error (MSE), Mean Absolute Error (MAE), with analytic derivatives for gradient-based learning.
The training loop involves:
- Forward pass Sequential layer multiplications + activations.
- Loss computation —
mse_lossormae_loss. - Backward pass Activation derivatives + optimizer update.
- Min-Max Scaling:
- Z-Score Normalization:
These are implemented as in place tensor methods for preprocessing input datasets.
RCMLRS supports binary and JSON serialization of trained model weights and biases, enabling reproducibility across sessions:
save_tensors_binary("model.bin", vec![weights, biases]);
let model_state = load_state_binary("model.bin");Binary format offers faster load times, while JSON enables human-readable inspection.
Using RCMLRS, an RNN layer can be built from scratch:
let z1 = weights.matmul(input.clone()).unwrap();
let a1 = z1.sigmoid();Here:
weights.matmul(input)performs the linear transformation..sigmoid()applies the non-linear activation.
This low-level access ensures full control over architectural experimentation, essential for research.
RCMLRS is not intended as a replacement for high level ML frameworks but as an experimental platform for:
- Understanding deep learning internals.
- Testing unconventional architectures.
- Building Rust-native AI systems for embedded or real-time applications.
Its transparency, portability, and deterministic execution make it a strong candidate for research projects, educational purposes, and performance critical AI systems.
- Implementation of Convolutional Neural Networks (CNNs).
- GPU acceleration via Vulkan or WGPU.
- Expanded dataset loaders for CSV and image formats.
- Automatic differentiation engine.
- Keras Impl.