36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
|
#![allow(dead_code)]
|
||
|
|
||
|
use nalgebra::DMatrix;
|
||
|
|
||
|
use dyna3::engine::{Q, DescentHistory, Realization};
|
||
|
|
||
|
pub fn title(title: &str) {
|
||
|
println!("─── {title} ───");
|
||
|
}
|
||
|
|
||
|
pub fn realization_diagnostics(realization: &Realization) {
|
||
|
let Realization { result, history } = realization;
|
||
|
println!();
|
||
|
if let Err(ref message) = result {
|
||
|
println!("❌️ {message}");
|
||
|
} else {
|
||
|
println!("✅️ Target accuracy achieved!");
|
||
|
}
|
||
|
println!("Steps: {}", history.scaled_loss.len() - 1);
|
||
|
println!("Loss: {}", history.scaled_loss.last().unwrap());
|
||
|
}
|
||
|
|
||
|
pub fn gram_matrix(config: &DMatrix<f64>) {
|
||
|
println!("\nCompleted Gram matrix:{}", (config.tr_mul(&*Q) * config).to_string().trim_end());
|
||
|
}
|
||
|
|
||
|
pub fn config(config: &DMatrix<f64>) {
|
||
|
println!("\nConfiguration:{}", config.to_string().trim_end());
|
||
|
}
|
||
|
|
||
|
pub fn loss_history(history: &DescentHistory) {
|
||
|
println!("\nStep │ Loss\n─────┼────────────────────────────────");
|
||
|
for (step, scaled_loss) in history.scaled_loss.iter().enumerate() {
|
||
|
println!("{:<4} │ {}", step, scaled_loss);
|
||
|
}
|
||
|
}
|