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

Method error

src/nn.rs:96–104  ·  view source on GitHub ↗

Computes the error of the net.

(&self, examples: &Matrix<f64>, targets: &Matrix<f64>)

Source from the content-addressed store, hash-verified

94
95 /// Computes the error of the net.
96 pub fn error(&self, examples: &Matrix<f64>, targets: &Matrix<f64>) -> f64 {
97
98 let mut err = 0.0;
99 for (row, t) in examples.row_iter().zip(targets.row_iter()) {
100 let v = self.predict(row).sub(t);
101 err += v.iter().fold(0.0, |acc, val| acc + val * val);
102 }
103 err / (2.0 * examples.rows() as f64)
104 }
105
106 /// Computes the output of the neural network for the given input.
107 pub fn predict(&self, input: &[f64]) -> Vec<f64> {

Callers 2

opt_hypothesisFunction · 0.45
test_errorFunction · 0.45

Calls 5

row_iterMethod · 0.80
subMethod · 0.80
predictMethod · 0.80
rowsMethod · 0.80
iterMethod · 0.45

Tested by 1

test_errorFunction · 0.36