diff --git a/examples/example_sine.rs b/examples/example_sine.rs index 09de34c..e968bcf 100644 --- a/examples/example_sine.rs +++ b/examples/example_sine.rs @@ -12,7 +12,7 @@ use rust_nn::layers::activation_layer::ActivationLayer; use rust_nn::layers::fc_layer::{FCLayer, Initializer}; use rust_nn::Network; -fn main() -> Result<(), Box> { +fn main() { // training data let training_interval = (0.0f64, 2.0f64 * PI); let steps = 100000; @@ -71,6 +71,20 @@ fn main() -> Result<(), Box> { // predict test dataset let y_test_pred = network.predict(&x_test); + // show results + if let Ok(()) = draw_results(&training_interval, &x_test, &y_test_true, &y_test_pred) { + println!("results can be seen in ./examples/sine.png"); + } else { + println!("failed to draw results"); + } +} + +fn draw_results( + training_interval: &(f64, f64), + x_test: &[Array1], + y_test_true: &[Array1], + y_test_pred: &[Array1], +) -> Result<(), Box> { // create the chart let buf = BitMapBackend::new("./examples/sine.png", (800, 600)).into_drawing_area(); buf.fill(&WHITE)?;