use std::fs::File;
use image::imageops::FilterType::Nearest;
use matrix_kit::dynamic::matrix::Matrix;
use ml_kit::math::activation::AFI;
use ml_kit::math::svd::{self, svd};
use ml_kit::models::neuralnet::NeuralNet;
fn main() {
let relative_path: &'static str = "../data_sets";
let channels = ml_kit::images::util::read_rgba_matrices("testing/files/sheep.png");
println!(
"Image is [{} x {}]",
channels[0].row_count(),
channels[0].col_count()
);
let image_svd_rgba: Vec<(Matrix<f64>, Matrix<f64>, Matrix<f64>)> =
channels.iter().map(|channel| svd(channel)).collect();
for i in 0..4 {
let (u, v, s) = image_svd_rgba[i].clone();
let network = NeuralNet::new(
vec![v.transpose(), s.clone(), u.clone()],
vec![
Matrix::new(v.col_count(), 1),
Matrix::new(s.row_count(), 1),
Matrix::new(u.row_count(), 1),
],
vec![AFI::Identity; 3],
);
let path = format!("testing/files/rgba_sheep_{}.mlk_nn", i);
let mut file = match File::create(path) {
Ok(f) => f,
Err(e) => panic!("Error opening file: {:?}", e),
};
network.write_to_file(&mut file);
}
}