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

Method from

src/datasets.rs:123–137  ·  view source on GitHub ↗
(vectors_fname: &str, labels_fname: &str)

Source from the content-addressed store, hash-verified

121 }
122
123 pub fn from(vectors_fname: &str, labels_fname: &str) -> Result<(Matrix<u8>, Vec<u8>), &'static str> {
124
125 let labels = try!(MnistDigits::read_labels(labels_fname));
126 let values = try!(MnistDigits::read_examples(vectors_fname));
127
128 match Matrix::from_vec(values, labels.len(), 784) {
129 Some(matrix) => {
130 match matrix.rows() == labels.len() {
131 true => Ok((matrix, labels)),
132 false => Err("Number of examples are different.")
133 }
134 }
135 _ => Err("Invalid matrix.")
136 }
137 }
138
139 fn path(fname: &str) -> Result<String, &'static str> {
140

Callers

nothing calls this directly

Calls 2

rowsMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected