use topos::Network;
fn main() {
let network = Network::new();
let a = network.leaf(2.0_f64);
let b = network.leaf(3.0);
let c = network.leaf(4.0);
println!("allocated {} leaves", network.len());
let sum = a + b;
let product = sum * c;
let expression = -product + a * c;
println!("chained -((a + b) * c) + a * c as {expression:?}");
println!("the network now holds {} values", network.len());
let run = network.forward();
println!("forward: expression = {}", run.of(expression));
let gradients = run.backward(expression);
println!(
"gradients: d/da = {}, d/db = {}, d/dc = {}",
gradients.of(a),
gradients.of(b),
gradients.of(c)
);
}