Expand description
§Tensors
Tensors is a lightweight machine learning library in Rust. It provides a simple and efficient way to create and train machine learning models with minimal dependencies.
§Dependencies
The library uses the following dependencies:
- rayon - for parallel computations on CPU.
- rand - for random number generation.
- serde - for saving models.
- serde_json - for loading models.
§Example
use tensorrs::activation::Function;
use tensorrs::DataType;
use tensorrs::linalg::{Matrix, Vector};
use tensorrs::nn::{Linear, Sequential};
use tensorrs::optim::Adam;
use tensorrs::loss::MSE;
use tensorrs::loss::Loss;
let x = Matrix::from(Vector::range(-1.0, 1.0, 0.125).unwrap());
let y:Matrix<f32> = 8.0 * &x - 10.0;
let layers: Vec<Box< dyn Function<f32>>> = vec![Box::new(Linear::new(1, 1, true))];
let mut optim = Adam::new(0.001, &layers);
let mut model = Sequential::new(layers);
let loss = MSE::new(DataType::f32());
for _ in 0..1000 {
model.train(x.transpose(), y.transpose(), &mut optim, &loss);
}
Thanks for using Tensors!!!
Modules§
- activation
- Activation Functions
- linalg
- Linear Algebra
- loss
- Loss functions
- nn
- Building Blocks for Neural Networks
- optim
- Optimization algorithms
- utils
Macros§
Structs§
- Data
Type - Structure to improve readability