How parm2006/neuralnetworksrust works
NeuralNetworksRust is a pure-Rust deep-learning framework, with an MNIST example demonstrating training, evaluation, inference, and checkpointing. The training workflow loads image and label data, runs a modular model, computes loss and gradients, and updates parameters; evaluation and single-sample inference reuse the model and saved weights. The graph also captures the framework’s tensor/autograd, layer, loss, optimizer, and state-persistence capabilities. The README documents a Python visualizer, but its implementation was not sampled, so its internal wiring is omitted.
Main entry points: mnist.rs Train and inference · sequential.rs Sequential model · tensor.rs Tensor and autograd · cross_entropy.rs Cross entropy
Components 19
MNIST workflows
- Train and inference
mnist.rs - Evaluation
mnist.rs - Single inference
mnist.rs - Python visualizer
infer.py
Tensor runtime
- Tensor and autograd
src/tensor/tensor.rs
Model components
- Module and state API
src/modules/module.rs - Sequential model
src/modules/sequential.rs - Linear layer
src/modules/linear.rs - Flatten layer
src/modules/flatten.rs - Activations
src/modules
Training components
- Loss API
src/losses/loss.rs - Cross entropy
src/losses/cross_entropy.rs - MSE and NLL
src/losses - Optimizer API
src/optim/optimizer.rs - SGD
src/optim/sgd.rs - AdamW
src/optim/adamw.rs
Model persistence
- Binary checkpoint
parm_mnist_model.bin
Other components
- User
- MNIST files
Connections 28
- User → Train and inference: starts
- Train and inference → MNIST files: reads training data
- Train and inference → Sequential model: builds model
- Train and inference → Cross entropy: computes loss
- Train and inference → AdamW: updates parameters
- Train and inference → Evaluation: evaluates after training
- Evaluation → MNIST files: reads test data
- Evaluation → Sequential model: runs forward pass
- Evaluation → Cross entropy: computes test loss
- Train and inference → Single inference: selects sample mode
- Single inference → MNIST files: reads test sample
- Single inference → Sequential model: runs forward pass
- Single inference → Binary checkpoint: loads weights
- Train and inference → Binary checkpoint: saves weights
- Train and inference → Tensor and autograd: creates batches and backpropagates
- Sequential model → Module and state API: implements module API
- Module and state API → Tensor and autograd: tracks parameters and state
- Sequential model → Linear layer: contains layers
- Sequential model → Flatten layer: contains layers
- Sequential model → Activations: contains activations
- Cross entropy → Loss API: implements
- MSE and NLL → Loss API: implements
- Cross entropy → Tensor and autograd: builds differentiable loss
- AdamW → Optimizer API: implements
- SGD → Optimizer API: implements
- AdamW → Tensor and autograd: reads gradients and updates data
- SGD → Tensor and autograd: reads gradients and updates data
- User → Python visualizer: launches optional viewer