MCPcopy Create free account
hub / github.com/daniel-e/rustml / optimize

Method optimize

src/nn.rs:119–129  ·  view source on GitHub ↗
(&self, x: &Matrix<f64>, labels: &Matrix<f64>, p: OptParams<f64>)

Source from the content-addressed store, hash-verified

117 }
118
119 pub fn optimize(&self, x: &Matrix<f64>, labels: &Matrix<f64>, p: OptParams<f64>) -> NeuralNetwork {
120
121 let a = p.alpha.unwrap();
122 let mut n = self.clone();
123
124 for _ in (0..p.iter.unwrap()) {
125 let v = n.derivatives(x, labels).iter().map(|x| x.mul_scalar(-a)).collect::<Vec<_>>();
126 n.update_params(&v);
127 }
128 n
129 }
130
131 fn feedforward(&self, x: &[f64]) -> (Vec<Vec<f64>>, Vec<Vec<f64>>) {
132

Callers 2

mainFunction · 0.80
plot_nnFunction · 0.80

Calls 4

mapMethod · 0.80
update_paramsMethod · 0.80
iterMethod · 0.45
derivativesMethod · 0.45

Tested by

no test coverage detected