neuroflow/estimators/mod.rs
1
2
3
4/// # Widrow's rule of thumb
5/// This is an empirical rule that shows the size of training sample
6/// in order to get good generalization.
7/// ## Example
8/// For network architecture [2, 1] and allowed error 0.1 (10%)
9/// the size of training sample must exceed the amount of free
10/// network parameters in 10 times
11pub fn widrows(architecture: &[i32], allowed_error: f64) -> f64 {
12 let mut s = architecture[0]*(architecture[0] + 1);
13
14 for i in 1..architecture.len(){
15 s += architecture[i] * architecture[i - 1] + architecture[i];
16 }
17
18 (s as f64) / allowed_error
19}