newron 0.5.1

A Rust library to train and infer deep learning models.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::{tensor::Tensor, loss::loss::Loss};
pub struct MSE {}

impl Loss for MSE {
    fn compute_loss(&self, y_true: &Tensor, y_pred: &Tensor) -> f64 {
        let loss = (y_pred - y_true).map(|x| x*x).get_mean(0).data[0];
        loss
    }

    fn compute_loss_grad(&self, y_true: &Tensor, y_pred: &Tensor) -> Tensor {
        let loss: Tensor = 2.0 * (y_pred - y_true);
        loss
    }
}