1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::layers::*;
use ndarray::{arr1, Array1, Array2};
use std::iter::zip;

pub fn train<L>(
    model: &Vec<L>,
    train_data: Array2<f64>,
    train_lbl: Array2<f64>,
    test_data: Array2<f64>,
    test_lbl: Array2<f64>,
) where
    L: Layer1d,
{
    todo!()
}

//noinspection RsBorrowChecker For some reason it says that the item is moved eventhough it isn't
pub fn forward_pass<L>(model: &Vec<L>, data: Array1<f64>) -> (Vec<Array1<f64>>, Vec<Array1<f64>>)
where
    L: Layer1d,
{
    let mut weights_bias_vec: Vec<Array1<f64>> = Vec::with_capacity(model.len());
    let mut activation_vec: Vec<Array1<f64>> = Vec::with_capacity(model.len());

    let mut activation_pass = data;
    let mut weight_pass;

    for layer in model.iter() {
        (weight_pass, activation_pass) = layer.pass(activation_pass.clone());

        weights_bias_vec.push(weight_pass);
        activation_vec.push(activation_pass.clone());
    }

    (weights_bias_vec, activation_vec)
}

pub fn back_propagation<L>(
    model: &Vec<L>,
    weights_bias_vec: Vec<Array1<f64>>,
    activation_vec: Vec<Array1<f64>>,
    target_out: Array1<f64>,
) where
    L: Layer1d,
{
    todo!()
}