/// Load a set of inputs and outputs (rust-csv can probably do this directly)
Load a set of inputs and outputs (rust-csv can probably do this directly)
Load a set of inputs and outputs ( rust - csv can probably do this directly )
fn load_data(
    inputs_file: &str,
    labels_file: &str,
    expected: u32,
) -> Vec<(network::Input, network::Label)> {
    let mut inputs_reader = csv::ReaderBuilder::new()
        .has_headers(false)
        .from_path(inputs_file)
        .unwrap();
    let mut labels_reader = csv::ReaderBuilder::new()
        .has_headers(false)
        .from_path(labels_file)
        .unwrap();
    let pb = ProgressBar::new(expected as u64);
    pb.set_style(ProgressStyle::default_bar().template("[{elapsed_precise}] {wide_bar} ({eta})"));
    let mut data = Vec::new();
    for (input, label) in inputs_reader.deserialize().zip(labels_reader.deserialize()) {
        let input: Vec<f64> = input.unwrap();
        let label: u32 = label.unwrap();
        // Convert into inputs/labels
        let input = network::vector_to_input(input);
        let label = network::Label::from_num(label);
        data.push((input, label));
        pb.inc(1);
    }
    pb.finish_with_message("Done loading");
    // assert!(data.len() == expected as usize);
    data
}
fn load_data ( inputs_file : & str , labels_file : & str , expected : u32 , ) -> Vec < ( network :: Input , network :: Label ) > { let mut inputs_reader = csv :: ReaderBuilder :: new ( ) . has_headers ( false ) . from_path ( inputs_file ) . unwrap ( ) ; let mut labels_reader = csv :: ReaderBuilder :: new ( ) . has_headers ( false ) . from_path ( labels_file ) . unwrap ( ) ; let pb = ProgressBar :: new ( expected as u64 ) ; pb . set_style ( ProgressStyle :: default_bar ( ) . template ( " " ) ) ; let mut data = Vec :: new ( ) ; for ( input , label ) in inputs_reader . deserialize ( ) . zip ( labels_reader . deserialize ( ) ) { let input : Vec < f64 > = input . unwrap ( ) ; let label : u32 = label . unwrap ( ) ; // Convert into inputs/labels let input = network :: vector_to_input ( input ) ; let label = network :: Label :: from_num ( label ) ; data . push ( ( input , label ) ) ; pb . inc ( 1 ) ; } pb . finish_with_message ( " " ) ; // assert!(data.len() == expected as usize); data }
Load a set of inputs and outputs (rust-csv can probably do this directly)
Load a set of inputs and outputs ( rust - csv can probably do this directly )
inputs_file
&str
labels_file
&str
expected
u32