Skip to content

Commit

Permalink
Use mse to avoid extra smooth in GSOM
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Jan 25, 2025
1 parent d86b1ad commit 5f694a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rosomaxa/src/algorithms/gsom/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ where
}

/// Returns data (weights) dimension.
pub(super) fn dimension(&self) -> usize {
pub fn dimension(&self) -> usize {
self.dimension
}

Expand Down
7 changes: 6 additions & 1 deletion rosomaxa/src/population/rosomaxa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ where
network.set_learning_rate(get_learning_rate(statistics.termination_estimate));

if statistics.generation % config.rebalance_memory == 0 {
network.smooth(external_ctx, 1, |i| i.on_update(external_ctx));
// set the MSE threshold to a fraction of the maximum possible normalized distance
let mse = network.mse();
let threshold = 0.5 / (network.dimension() as Float).sqrt();
if mse > threshold {
network.smooth(external_ctx, 1, |i| i.on_update(external_ctx));
}
}

let keep_size = get_keep_size(config.rebalance_memory, statistics.termination_estimate);
Expand Down

0 comments on commit 5f694a7

Please sign in to comment.