diff --git a/crates/ml-alpha/src/trainer/perception.rs b/crates/ml-alpha/src/trainer/perception.rs index b6dca160b..f6914812c 100644 --- a/crates/ml-alpha/src/trainer/perception.rs +++ b/crates/ml-alpha/src/trainer/perception.rs @@ -3941,7 +3941,13 @@ impl PerceptionTrainer { let sl = std::ptr::read_volatile(self.aux_loss_size_long_host_d.host_ptr); let ps = std::ptr::read_volatile(self.aux_loss_prof_short_host_d.host_ptr); let ss = std::ptr::read_volatile(self.aux_loss_size_short_host_d.host_ptr); - pl + sl + ps + ss + let n_pl = std::ptr::read_volatile(self.aux_valid_prof_long_host_d.host_ptr) as f32; + let n_sl = std::ptr::read_volatile(self.aux_valid_size_long_host_d.host_ptr) as f32; + let n_ps = std::ptr::read_volatile(self.aux_valid_prof_short_host_d.host_ptr) as f32; + let n_ss = std::ptr::read_volatile(self.aux_valid_size_short_host_d.host_ptr) as f32; + let prof = if n_pl + n_ps > 0.0 { (pl + ps) / (n_pl + n_ps) } else { 0.0 }; + let size = if n_sl + n_ss > 0.0 { (sl + ss) / (n_sl + n_ss) } else { 0.0 }; + prof + size }; Ok((loss, aux_loss))