1fn main() {
2 let mut run = photon::Run::builder()
3 .endpoint("[::1]:50051")
4 .max_points_per_batch(50)
5 .start()
6 .expect("failed to start run");
7
8 println!("Run: {}", run.id());
9
10 for step in 0..200 {
12 let loss = 1.0 / (1.0 + step as f64 * 0.05);
13 let accuracy = 1.0 - loss;
14
15 run.log("train/loss", loss, step).unwrap();
16 run.log("train/accuracy", accuracy, step).unwrap();
17
18 if step % 10 == 0 {
19 let lr = 0.001 * 0.95_f64.powi(step as i32 / 10);
20 run.log("train/lr", lr, step).unwrap();
21 }
22 }
23
24 println!("Logged: {} points", run.points_logged());
25
26 let stats = run.finish().expect("finish failed");
27
28 println!("\n--- Results ---");
29 println!("Points: {}", stats.points);
30 println!("Dropped: {}", stats.points_dropped);
31 println!("Batches: {}", stats.batches);
32 println!("Bytes (raw): {}", stats.bytes_uncompressed);
33 println!("Bytes (wire): {}", stats.bytes_compressed);
34 println!("Sent: {}", stats.batches_sent);
35 println!("Acked: {}", stats.batches_acked);
36
37 assert!(stats.batches > 0);
38 assert_eq!(stats.points, 420);
39 assert_eq!(stats.points_dropped, 0);
40
41 println!("\nAll checks passed!");
42}