Neural network library written in Rust with support for both CPU and Metal GPU backends.
- Multiple Backends: CPU and Metal GPU acceleration for Apple Silicon
- Layer Types:
- Dense (fully connected) - ✅ Tensor-based
- Activation layers - ✅ Tensor-based
- Convolutional, Pooling -
⚠️ Legacy implementation (Tensor migration in progress)
- Activations: ReLU, Softmax, Sigmoid, Tanh
- Optimizers: Gradient Descent (SGD)
- Loss Functions: Cross Entropy, Mean Squared Error
- Metrics: Accuracy, Precision, Recall, F1 Score, and more
The Tensor implementation and Metal backend are largely inspired by Candle.
Additional GPU backends (CUDA, WebGPU) coming soon.
Benchmarked on MNIST (784→256→128→10 MLP, 10 epochs, batch size 128):
| Backend | Time (10 epochs) | Speed | Test Accuracy |
|---|---|---|---|
| Metal (M4 Pro) | 18.57s | 1.86s/epoch | 93.61% |
| CPU | ~211s | ~21s/epoch | - |
# CPU backend
RUST_LOG=info cargo run --example mlp_mnist --release
# Metal backend
RUST_LOG=info cargo run --example mlp_mnist --release --features metalThe example automatically loads and processes the MNIST dataset, trains a simple MLP, and reports training progress and test accuracy.
- Dense (fully connected) layers
- Activation layers (ReLU, Softmax, Sigmoid, Tanh)
- Gradient Descent optimizer
- Cross Entropy and MSE loss functions
- Comprehensive metrics system
- Metal and CPU backends
- Convolutional layers (legacy ndarray implementation)
- Pooling layers (legacy ndarray implementation)
- Reshape layers (legacy ndarray implementation)
These layers currently use the old ndarray-based implementation and will be migrated to the new Tensor system soon.
- Autograd: Automatic differentiation
- Conv/Pooling Tensor Migration: Update convolutional and pooling layers to use Tensor backend
- CUDA Backend: NVIDIA GPU support
- WebGPU Backend: Browser and cross-platform support
- Additional optimizers (Adam, RMSprop, AdamW)
- Dropout and other regularization techniques
- More layer types (LSTM, GRU, Transformer, Attention)
- Model serialization/deserialization
- ONNX export
- Manual gradient computation (autograd coming soon)
- Convolutional and pooling layers not yet migrated to Tensor backend
- Limited to sequential models
- Adrien Pelfresne
- Alexis Vapaille