elara_math/lib.rs
1/*! This crate is a Rust-native tensor and math library,
2developed for [Project Elara](https://github.com/elaraproject). It aims to
3be a basic implementation of common machine learing and scientific computing
4tools in Rust. It tries to give a Rust experience similar to [SciPy](https://scipy.org/),
5[NumPy](https://numpy.org/), and [PyTorch](https://pytorch.org/)/[TensorFlow](https://www.tensorflow.org/),
6offering:
7
8- Tensors: N-dimensional differentiable arrays (via `Tensor`)
9- An implementation of reverse-mode automatic differentiation
10- Numerical solvers for calculus (only numerical integration/quadrature is fully-supported at the moment, the ODE solver has been moved to [`elara-array`](https://github.com/elaraproject/elara-array))
11
12To get started, just run `cargo install elara-math` to add to your project. We offer [several examples](https://github.com/elaraproject/elara-math/tree/main/examples) in our GitHub repository to reference and learn from.
13*/
14
15mod integrate;
16mod nn;
17mod tensor;
18
19pub use nn::*;
20pub use tensor::*;
21
22/// `elara-math` prelude
23pub mod prelude;
24
25/// Mean squared error function
26pub fn mse(predicted: &Tensor, target: &Tensor) -> Tensor {
27 let out = target - predicted;
28 (&out * &out).mean()
29}