Extracted drawing of example_sine into separate fn
This commit is contained in:
parent
e24b05f4bc
commit
9c5b74fb26
1 changed files with 15 additions and 1 deletions
|
@ -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<dyn Error>> {
|
||||
fn main() {
|
||||
// training data
|
||||
let training_interval = (0.0f64, 2.0f64 * PI);
|
||||
let steps = 100000;
|
||||
|
@ -71,6 +71,20 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
// 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<f64>],
|
||||
y_test_true: &[Array1<f64>],
|
||||
y_test_pred: &[Array1<f64>],
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
// create the chart
|
||||
let buf = BitMapBackend::new("./examples/sine.png", (800, 600)).into_drawing_area();
|
||||
buf.fill(&WHITE)?;
|
||||
|
|
Loading…
Reference in a new issue